在kubernetes运行分布式追踪zipkin

前言

Zipkin是一个开放源代码分布式的跟踪系统,每个服务向zipkin报告计时数据,zipkin会根据调用关系通过Zipkin UI生成依赖关系图。简单的来说就是个http服务器
它支持多种后端存储(”cassandra”,”mysql”,”elasticsearch”)持久化客户端推送过来的数据.

部署zipkin使用ES存储

使用ES作为后端存储需要先搭建一个ES环境。可以参考我的另一篇文章在kubernetes上运行elasticsearch集群

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

---
apiVersion: v1
kind: Service
metadata:
name: zipkin-service
labels:
app: zipkin-service
spec:
ports:
- port: 9411
name: zipkin-service
clusterIP: 10.96.0.13
selector:
app: zipkin-service
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: zipkin-service
spec:
strategy:
type: Recreate
selector:
matchLabels:
app: zipkin-service
template:
metadata:
labels:
app: zipkin-service
spec:
containers:
- name: zipkin-service
image: openzipkin/zipkin
imagePullPolicy: IfNotPresent
livenessProbe:
tcpSocket:
port: 9411
timeoutSeconds: 5
readinessProbe:
tcpSocket:
port: 9411
timeoutSeconds: 5
ports:
- containerPort: 9411
env:
- name: STORAGE_TYPE
value: elasticsearch
- name: STORAGE_PORT_9200_TCP_ADDR
value: "es-m1"

部署zipkin使用Mysql存储

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

---
apiVersion: v1
kind: Service
metadata:
name: zipkin-service
labels:
app: zipkin-service
spec:
ports:
- port: 9411
name: zipkin-service
clusterIP: 10.96.0.12
selector:
app: zipkin-service
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: zipkin-service
spec:
strategy:
type: Recreate
selector:
matchLabels:
app: zipkin-service
template:
metadata:
labels:
app: zipkin-service
spec:
containers:
- name: zipkin-service
image: openzipkin/zipkin
imagePullPolicy: IfNotPresent
livenessProbe:
tcpSocket:
port: 9411
timeoutSeconds: 5
readinessProbe:
tcpSocket:
port: 9411
timeoutSeconds: 5
ports:
- containerPort: 9411
env:
- name: STORAGE_TYPE
value: mysql
- name: MYSQL_DB
value: zipkin
- name: MYSQL_USER
value: root
- name: MYSQL_PASS
value: "root"
- name: MYSQL_HOST
value: "192.168.3.202"
- name: MYSQL_TCP_PORT
value: "3306"

推荐文章