SkyWalking链路追踪+K8S、
# 服务器部署
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: skywalking
name: skywalking
namespace: iot-dev
spec:
replicas: 1
selector:
matchLabels:
app: skywalking
template:
labels:
app: skywalking
spec:
containers:
- envFrom:
- configMapRef:
name: skywalking-cm
prefix: SW_
image: 'apache/skywalking-oap-server:8.9.1'
imagePullPolicy: IfNotPresent
name: skywalking
ports:
- containerPort: 12800
name: http
protocol: TCP
- containerPort: 11800
name: grpc
protocol: TCP
volumeMounts:
- mountPath: /etc/localtime
name: volume-localtime
volumes:
- hostPath:
path: /etc/localtime
type: ''
name: volume-localtime
---
apiVersion: v1
kind: Service
metadata:
annotations: {}
labels:
app: skywalking
name: skywalking
namespace: iot-dev
spec:
ports:
- name: http
port: 12800
protocol: TCP
targetPort: 12800
- name: grpc
port: 11800
protocol: TCP
targetPort: 11800
selector:
app: skywalking
type: ClusterIP
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
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
# 前端部署
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: skywalking-ui
k8s.kuboard.cn/name: skywalking-ui
name: skywalking-ui
namespace: iot-dev
spec:
replicas: 1
selector:
matchLabels:
app: skywalking-ui
template:
metadata:
labels:
app: skywalking-ui
spec:
containers:
- env:
- name: SW_OAP_ADDRESS
value: 'http://skywalking:12800'
image: 'apache/skywalking-ui:8.9.1'
imagePullPolicy: IfNotPresent
name: skywalking-ui
ports:
- containerPort: 8080
name: http
protocol: TCP
volumeMounts:
- mountPath: /etc/localtime
name: volume-localtime
volumes:
- hostPath:
path: /etc/localtime
type: ''
name: volume-localtime
---
apiVersion: v1
kind: Service
metadata:
labels:
app: skywalking-ui
name: skywalking-ui
namespace: iot-dev
spec:
ports:
- name: http
nodePort: 31234
port: 8080
protocol: TCP
targetPort: 8080
selector:
app: skywalking-ui
type: NodePort
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
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
# Agent部署
先启动一个初始化容器,把Agent.jar复制出来。
再通过环境变量让java -jar 通过JVM代理Agent.jar启动。
挂载Skywalking后的java yaml模板如下:
---
apiVersion: apps/v1
kind: Deployment
metadata:
annotations: {}
labels:
k8s.kuboard.cn/name: #{appname}
name: #{appname}
namespace: iot-dev
spec:
replicas: 1
selector:
matchLabels:
k8s.kuboard.cn/name: #{appname}
template:
metadata:
creationTimestamp: null
labels:
k8s.kuboard.cn/name: #{appname}
spec:
initContainers:
- name: agent-container
image: apache/skywalking-java-agent:8.9.0-alpine
volumeMounts:
- name: skywalking-agent
mountPath: /agent
command: [ "/bin/sh" ]
args: [ "-c", "cp -R /skywalking/agent /agent/" ]
containers:
- name: #{appname}
image: '192.168.1.177:30303/#{appname}:#{apptag}'
volumeMounts:
- name: skywalking-agent
mountPath: /skywalking
imagePullPolicy: IfNotPresent
env:
- name: JAVA_TOOL_OPTIONS
value: "-javaagent:/skywalking/agent/skywalking-agent.jar"
- name: SW_AGENT_NAME
value: '#{appname}'
- name: SW_AGENT_COLLECTOR_BACKEND_SERVICES
value: "skywalking:11800"
ports:
- containerPort: 8080
name: http
protocol: TCP
- containerPort: 30652
name: debug
protocol: TCP
imagePullSecrets:
- name: mydocker
restartPolicy: Always
volumes:
- name: skywalking-agent
emptyDir: { }
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
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
# SpringCloud Gateway
因为SpringCloud使用WebFlux,需要加载插件才能正常收集。
配置文件如下(区别在于多复制一个Gateway插件):
---
apiVersion: apps/v1
kind: Deployment
metadata:
annotations: {}
labels:
k8s.kuboard.cn/name: #{appname}
name: #{appname}
namespace: iot-dev
spec:
selector:
matchLabels:
k8s.kuboard.cn/name: #{appname}
template:
metadata:
labels:
k8s.kuboard.cn/name: #{appname}
spec:
initContainers:
- name: agent-container
image: apache/skywalking-java-agent:8.9.0-alpine
volumeMounts:
- name: skywalking-agent
mountPath: /agent
command: [ "/bin/sh" ]
args: [ "-c", "cp /skywalking/agent/optional-plugins/apm-spring-cloud-gateway-3.x-plugin-8.9.0.jar /skywalking/agent/plugins/ && cp -R /skywalking/agent /agent/"]
containers:
- name: #{appname}
image: '192.168.1.177:30303/#{appname}:#{apptag}'
volumeMounts:
- name: skywalking-agent
mountPath: /skywalking
imagePullPolicy: IfNotPresent
env:
- name: JAVA_TOOL_OPTIONS
value: "-javaagent:/skywalking/agent/skywalking-agent.jar"
- name: SW_AGENT_NAME
value: '#{appname}'
- name: SW_AGENT_COLLECTOR_BACKEND_SERVICES
value: "skywalking:11800"
ports:
- containerPort: 8080
name: http
protocol: TCP
- containerPort: 30652
name: debug
protocol: TCP
imagePullSecrets:
- name: mydocker
volumes:
- name: skywalking-agent
emptyDir: { }
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
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
上次更新: 10/23/2024