k8s简单部署zabbix监控系统
k8s部署zabbix监控系统1.创建mysql部署文件vim mysql-deploy.yamlapiVersion: apps/v1kind: Deploymentmetadata:name: mysqlspec:replicas: 1selector:matchLabels:app: mysqlstrategy:type: Recreatetemplate:metadata:labels:.
k8s部署zabbix监控系统
1.创建mysql部署文件
vim mysql-deploy.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: mysql
spec:
replicas: 1
selector:
matchLabels:
app: mysql
strategy:
type: Recreate
template:
metadata:
labels:
app: mysql
spec:
containers:
- image: mysql:5.7
name: mysql
imagePullPolicy: IfNotPresent
env:
- name: MYSQL_ROOT_PASSWORD
value: "zabbix"
- name: MYSQL_DATABASE
value: "zabbix"
- name: MYSQL_USER
value: "zabbix"
- name: MYSQL_PASSWORD
value: "zabbix"
ports:
- containerPort: 3306
name: mysql
---
apiVersion: v1
kind: Service
metadata:
name: mysql
spec:
type: NodePort
ports:
- port: 3306
nodePort: 30006
protocol: TCP
targetPort: 3306
selector:
app: mysql
2.部署zabbix-server
vim zabbix-server-deploy.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: zabbix-server
spec:
replicas: 1
selector:
matchLabels:
app: zabbix-server
template:
metadata:
labels:
app: zabbix-server
spec:
containers:
- name: zabbix-server
image: zabbix/zabbix-server-mysql
imagePullPolicy: IfNotPresent
ports:
- containerPort: 10051
name: server
protocol: TCP
readinessProbe:
tcpSocket:
port: server
initialDelaySeconds: 5
periodSeconds: 10
livenessProbe:
tcpSocket:
port: server
initialDelaySeconds: 15
periodSeconds: 20
env:
- name: DB_SERVER_HOST
value: "mysql"
- name: MYSQL_USER
value: "zabbix"
- name: MYSQL_PASSWORD
value: "zabbix"
- name: MYSQL_DATABASE
value: "zabbix"
- name: DB_SERVER_PORT
value: "3306"
---
apiVersion: v1
kind: Service
metadata:
name: zabbixserver
spec:
type: NodePort
ports:
- port: 10051
nodePort: 30051
protocol: TCP
targetPort: 10051
selector:
app: zabbix-server
3.部署zabbix-web
vim zabbix-web-deploy.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: zabbix-web
spec:
replicas: 2
selector:
matchLabels:
app: zabbix-web
template:
metadata:
labels:
app: zabbix-web
spec:
containers:
- image: zabbix/zabbix-web-nginx-mysql
name: zabbix-web
imagePullPolicy: IfNotPresent
ports:
- containerPort: 80
name: web
protocol: TCP
env:
- name: DB_SERVER_HOST
value: "mysql"
- name: ZBX_SERVER_HOST
value: "zabbixserver"
- name: MYSQL_USER
value: "zabbix"
- name: MYSQL_PASSWORD
value: "zabbix"
- name: TZ
value: "Asia/Shanghai"
---
apiVersion: v1
kind: Service
metadata:
name: zabbix-web
spec:
type: NodePort
ports:
- port: 80
protocol: TCP
nodePort: 30080
targetPort: 80
selector:
app: zabbix-web
[root@k8s zabbix]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
zabbix/zabbix-agent latest 954724565311 6 days ago 14.5MB
coredns/coredns 1.6.2 bf261d157914 8 months ago 44.1MB
zabbix/zabbix-web-nginx-mysql latest a9f298a246c6 15 months ago 163MB
zabbix/zabbix-server-mysql latest e7a125d25077 15 months ago 62.7MB
zabbix/zabbix-proxy-mysql latest e1a7866b9a83 15 months ago 60.8MB
busybox 1.28 8c811b4aec35 23 months ago 1.15MB
k8s.gcr.io/pause 3.1 da86e6ba6ca1 2 years ago 742kB
mysql 5.7 877345fbf968 3 years ago 406MB
[root@k8s zabbix]# kubectl create -f mysql-deploy.yaml
[root@k8s zabbix]# kubectl create -f zabbix-server-deploy.yaml
[root@k8s zabbix]# kubectl create -f zabbix-web-deploy.yaml
[root@k8s zabbix]# kubectl get pods
NAME READY STATUS RESTARTS AGE
busybox 1/1 Running 5 3d7h
mysql-f74967858-9nzqw 1/1 Running 0 26m
zabbix-server-c74989dc7-b24z6 1/1 Running 0 25m
zabbix-web-856989975-drvbw 1/1 Running 0 24m
zabbix-web-856989975-txnf9 1/1 Running 0 24m
[root@k8s zabbix]# kubectl get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 169.169.0.1 <none> 443/TCP 5d5h
mysql NodePort 169.169.198.178 <none> 3306:30006/TCP 3m21s
zabbix-web NodePort 169.169.183.23 <none> 80:30080/TCP 81s
zabbixserver NodePort 169.169.103.35 <none> 10051:30051/TCP 2m28s
[root@k8s zabbix]# kubectl get deploy
NAME READY UP-TO-DATE AVAILABLE AGE
mysql 1/1 1 1 27m
zabbix-server 1/1 1 1 26m
zabbix-web 2/2 2 2 25m
更多推荐
所有评论(0)