DevilKing's blog

冷灯看剑,剑上几分功名?炉香无需计苍生,纵一穿烟逝,万丈云埋,孤阳还照古陵

0%

Centralized logging in K8s

原文链接

采用logstash作为sidecar的方式,去收集日志,类似于当前的filebeat的模式

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: wso2apim
spec:
replicas: 1
minReadySeconds: 30
strategy:
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
type: RollingUpdate
template:
metadata:
labels:
deployment: wso2apim
spec:
initContainers:
- name: init-wso2-elasticsearch-service
image: busybox
command: ['sh', '-c', 'until nc -z wso2-elasticsearch-service 9200; do echo waiting for wso2-elasticsearch-service; sleep 2; done;']
containers:
- name: wso2apim
image: wso2/wso2am:2.6.0
livenessProbe:
exec:
command:
- /bin/bash
- -c
- nc -z localhost 9443
initialDelaySeconds: 150
periodSeconds: 10
readinessProbe:
exec:
command:
- /bin/bash
- -c
- nc -z localhost 9443
initialDelaySeconds: 150
periodSeconds: 10
imagePullPolicy: Always
ports:
-
containerPort: 8280
protocol: "TCP"
-
containerPort: 8243
protocol: "TCP"
-
containerPort: 9763
protocol: "TCP"
-
containerPort: 9443
protocol: "TCP"
-
containerPort: 5672
protocol: "TCP"
-
containerPort: 9711
protocol: "TCP"
-
containerPort: 9611
protocol: "TCP"
-
containerPort: 7711
protocol: "TCP"
-
containerPort: 7611
protocol: "TCP"
volumeMounts:
- name: shared-logs
mountPath: /home/wso2carbon/wso2am-2.6.0/repository/logs/
- name: logstash
image: maanadev/logstash:6.5.3-custom
volumeMounts:
- name: shared-logs
mountPath: /usr/share/logstash/mylogs/
- name: logstash-yml
mountPath: /usr/share/logstash/config/logstash.yml
subPath: logstash.yml
- name: logstash-conf
mountPath: /usr/share/logstash/pipeline/logstash.conf
subPath: logstash.conf
env:
- name: NODE_ID
value: "wso2-apim"
- name: NODE_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
volumes:
- name: shared-logs
emptyDir: {}
- name: logstash-yml
configMap:
name: logstash-yml
- name: logstash-conf
configMap:
name: logstash-conf

采用伴生容器的方式