kubernetes.yaml註釋
下載自:github.com/zabbix/zabbix-docker/blob/5.2/kubernetes.yaml
apiVersion: v1
#版本號,版本號可以用 kubectl api-versions 查詢到
kind: Namespace
#表明資源物件,例如Pod、RC、Service、Namespace、Endpoints(把外部的連結到k8s系統中)及Node等
metadata:
#meta資訊,比如名稱、namespace、標籤等資訊
name: zabbix
labels:
name: zabbix
---
apiVersion: v1
kind: Service
metadata:
name: zabbix-web #service名稱
labels:
app: zabbix
namespace: zabbix
spec: #資源物件的詳細定義,持久化到etcd中儲存
type: NodePort
#Service型別,ClusterIP供kubernates叢集內部pod訪問
ports: #暴露的埠列表
- port: 80
#Service監聽的埠,對應ClusterIP,即ClusterIP+ServicePort供叢集內部pod訪問的
targetPort: 8080 #對應pod中容器的埠
#nodePort: 8080 #port和nodePort都是service的埠,前者暴露給k8s叢集內部服務訪問,後者暴露給
#k8s叢集外部流量訪問。從上兩個埠過來的資料都需要經過反向代理kube-proxy,流
#入後端pod的targetPort上,最後到達pod內的容器。
#補充:NodePort型別的service可供外部叢集訪問是因為service監聽了宿主機上的埠,即監聽了(所有節點)nodePort,該埠的請求會傳送給service,service再經由負載均衡轉發給Endpoints的節點。
name: web-http #埠名稱
- port: 443
targetPort: 8443
name: web-https
selector: #label選擇器,管理label對應的pod
name: zabbix-web #pod的label
# externalIPs:
#對於指定了externalIPs的 Service,ipvs 會安裝匹配KUBE-EXTERNAL-IP ipset 集的 iptables 規則
# - <Specify external IP here>
---
apiVersion: v1
kind: Service
metadata:
name: mysql-server
labels:
app: zabbix
tier: db
namespace: zabbix
spec:
ports:
- port: 3306
targetPort: 3306
name: mysql-server
selector:
name: mysql-server
---
apiVersion: v1
kind: Service
metadata:
name: zabbix-server
labels:
app: zabbix
namespace: zabbix
spec:
ports:
- port: 10051
targetPort: 10051
name: zabbix-trapper
- port: 162
targetPort: 1162
protocol: UDP
name: snmp-trap
selector:
name: zabbix-server
# externalIPs:
# - <Specify external IP here>
---
apiVersion: v1
kind: Service
metadata:
name: zabbix-proxy-sqlite3
labels:
app: zabbix
namespace: zabbix
spec:
ports:
- port: 10051
targetPort: 10051
name: zabbix-trapper
- port: 162
targetPort: 1162
protocol: UDP
name: snmp-trap
selector:
name: zabbix-proxy-sqlite3
---
apiVersion: v1
kind: Service
metadata:
name: zabbix-proxy-mysql
labels:
app: zabbix
namespace: zabbix
spec:
ports:
- port: 10051
targetPort: 10051
name: zabbix-trapper
- port: 162
targetPort: 1162
protocol: UDP
name: snmp-trap
selector:
name: zabbix-proxy-mysql
---
apiVersion: v1
kind: Service
metadata:
name: zabbix-java-gateway
labels:
app: zabbix
namespace: zabbix
spec:
ports:
- port: 10052
targetPort: 10052
name: zabbix-jmx
selector:
name: zabbix-java-gateway
---
apiVersion: v1
kind: Service
metadata:
name: zabbix-agent
labels:
app: zabbix
namespace: zabbix
spec:
ports:
- port: 10050
targetPort: 10050
name: zabbix-agent
selector:
name: zabbix-agent
---
apiVersion: v1
kind: ReplicationController
#根據標籤選擇器管理符合其標籤的所有pod,並維持在replicas設定的數量上
metadata:
name: zabbix-web
labels:
app: zabbix
tier: zabbix-web
namespace: zabbix
spec:
replicas: 2
template:
metadata:
labels:
name: zabbix-web
app: zabbix
spec:
containers:
- name: zabbix-web
image: zabbix/zabbix-web-nginx-mysql:alpine-5.2-latest
imagePullPolicy: Always
ports:
- containerPort: 8080
name: web-http
- containerPort: 8443
name: web-https
resources:
limits:
cpu: 200m
memory: 400Mi
requests:
cpu: 200m
memory: 400Mi
livenessProbe:
httpGet:
path: /
port: web-http
scheme: HTTP
initialDelaySeconds: 15
timeoutSeconds: 2
periodSeconds: 10
successThreshold: 1
failureThreshold: 5
readinessProbe:
httpGet:
path: /
port: web-http
scheme: HTTP
initialDelaySeconds: 15
timeoutSeconds: 2
periodSeconds: 10
successThreshold: 1
failureThreshold: 5
env:
- name: ZBX_SERVER_NAME
value: "Zabbix kubernetes"
- name: PHP_TZ
value: "Europe/Riga"
- name: MYSQL_USER
valueFrom:
secretKeyRef:
name: db-secret
key: db-zbx-user
- name: MYSQL_PASSWORD
valueFrom:
secretKeyRef:
name: db-secret
key: db-zbx-pass
- name: MYSQL_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: db-secret
key: db-root-pass
- name: MYSQL_DATABASE
value: "zabbix"
# volumeMounts:
# - name: zabbix-web-ssl
# mountPath: /etc/ssl/nginx
# readOnly: true
# volumes:
# - hostPath:
# path: /home/dotneft/zbx/zbx_env/etc/ssl/nginx/
# name: zabbix-web-ssl
---
apiVersion: v1
kind: ReplicationController
metadata:
name: mysql-server
labels:
app: zabbix
tier: mysql-server
namespace: zabbix
spec:
replicas: 1
template:
metadata:
labels:
name: mysql-server
app: zabbix
tier: mysql-server
spec:
# volumes:
# - name: zabbix-mysql-data
# persistentVolumeClaim:
# claimName: zabbix-mysql-data-claim
containers:
- name: zabbix-db
image: mysql:5.7
ports:
- containerPort: 3306
name: mysql
env:
- name: MYSQL_USER
valueFrom:
secretKeyRef:
name: db-secret
key: db-zbx-user
- name: MYSQL_PASSWORD
valueFrom:
secretKeyRef:
name: db-secret
key: db-zbx-pass
- name: MYSQL_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: db-secret
key: db-root-pass
- name: MYSQL_DATABASE
value: "zabbix"
# volumeMounts:
# - mountPath: "/var/lib/mysql/" #容器中目錄
# name: zabbix-mysql-data #定義的名稱zabbix-mysql-data與下面配置中的volumes對應。
# readOnly: false
---
apiVersion: v1
kind: ReplicationController
metadata:
name: zabbix-server
labels:
app: zabbix
tier: server
environment: dev
namespace: zabbix
spec:
replicas: 1
template:
metadata:
labels:
name: zabbix-server
app: zabbix
spec:
containers:
- name: zabbix-server
image: zabbix/zabbix-server-mysql:alpine-5.2-latest
imagePullPolicy: Always
ports:
- containerPort: 10051
protocol: TCP
name: zabbix-trapper
readinessProbe:
tcpSocket:
port: zabbix-trapper
initialDelaySeconds: 5
periodSeconds: 10
livenessProbe:
tcpSocket:
port: zabbix-trapper
initialDelaySeconds: 15
periodSeconds: 20
env:
- name: MYSQL_USER
valueFrom:
secretKeyRef:
name: db-secret
key: db-zbx-user
- name: MYSQL_PASSWORD
valueFrom:
secretKeyRef:
name: db-secret
key: db-zbx-pass
- name: MYSQL_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: db-secret
key: db-root-pass
- name: MYSQL_DATABASE
value: "zabbix"
- name: ZBX_JAVAGATEWAY_ENABLE
value: "true"
- name: ZBX_STARTJAVAPOLLERS
value: "5"
- name: ZBX_ENABLE_SNMP_TRAPS
value: "true"
- name: ZBX_STARTPROXYPOLLERS
value: "5"
- name: ZBX_PROXYCONFIGFREQUENCY
value: "60"
volumeMounts:
- name: zabbix-db-storage
mountPath: /var/lib/zabbix/snmptraps/
readOnly: true
- name: zabbix-snmptraps
image: zabbix/zabbix-snmptraps:alpine-5.2-latest
imagePullPolicy: Always
ports:
- containerPort: 1162
protocol: UDP
name: snmp-trap
volumeMounts:
- name: zabbix-db-storage
mountPath: /var/lib/zabbix/snmptraps/
readOnly: false
volumes:
- hostPath:
path: /zabbix/
name: zabbix-db-storage
---
apiVersion: v1
kind: ReplicationController
metadata:
name: zabbix-proxy-sqlite3
labels:
app: zabbix
tier: proxy
namespace: zabbix
spec:
replicas: 1
template:
metadata:
labels:
name: zabbix-proxy-sqlite3
app: zabbix
spec:
containers:
- name: zabbix-proxy-sqlite3
image: zabbix/zabbix-proxy-sqlite3:alpine-5.2-latest
imagePullPolicy: Always
ports:
- containerPort: 10051
protocol: TCP
name: zabbix-trapper
env:
- name: ZBX_HOSTNAME
value: "zabbix-proxy-passive"
- name: ZBX_CONFIGFREQUENCY
value: "60"
- name: ZBX_PROXYMODE
value: "1"
---
apiVersion: v1
kind: ReplicationController
metadata:
name: zabbix-proxy-mysql
labels:
app: zabbix
tier: proxy
namespace: zabbix
spec:
replicas: 1
template:
metadata:
labels:
name: zabbix-proxy-mysql
app: zabbix
spec:
containers:
- name: zabbix-proxy-mysql
image: zabbix/zabbix-proxy-mysql:alpine-5.2-latest
imagePullPolicy: Always
ports:
- containerPort: 10051
protocol: TCP
name: zabbix-trapper
env:
- name: MYSQL_USER
valueFrom:
secretKeyRef:
name: db-secret
key: db-zbx-user
- name: MYSQL_PASSWORD
valueFrom:
secretKeyRef:
name: db-secret
key: db-zbx-pass
- name: MYSQL_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: db-secret
key: db-root-pass
- name: MYSQL_DATABASE
value: "zabbix_proxy"
---
apiVersion: v1
kind: ReplicationController
metadata:
name: zabbix-java-gateway
labels:
app: zabbix
tier: java
namespace: zabbix
spec:
replicas: 1
template:
metadata:
labels:
name: zabbix-java-gateway
app: zabbix
spec:
containers:
- name: zabbix-java-gateway
image: zabbix/zabbix-java-gateway:alpine-5.2-latest
imagePullPolicy: Always
ports:
- containerPort: 10052
protocol: TCP
name: zabbix-jmx
env:
- name: ZBX_TIMEOUT
value: "5"
---
apiVersion: apps/v1
kind: DaemonSet
#DaemonSet好比Kubernetes叢集Node的守護程式,可以保證在每個Node上(或者一部分Node上)都執行同一個Pod且只執行一個。適用的場景主要是一些agent,如日誌收集的agent、監控的agent等
metadata:
name: zabbix-agent
labels:
app: zabbix
tier: agent
namespace: zabbix
spec:
selector:
matchLabels:
name: zabbix-agent
updateStrategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 1
template:
metadata:
labels:
name: zabbix-agent
app: zabbix
spec:
containers:
- name: zabbix-agent
image: zabbix/zabbix-agent:alpine-5.2-latest
imagePullPolicy: Always
resources:
limits:
cpu: 100m
memory: 54Mi
requests:
cpu: 100m
memory: 54Mi
ports:
- containerPort: 10050
name: zabbix-agent
env:
- name: ZBX_SERVER_HOST
value: "zabbix-server"
- name: ZBX_PASSIVE_ALLOW
value: "true"
- name: ZBX_STARTAGENTS
value: "3"
- name: ZBX_TIMEOUT
value: "10"
securityContext:
privileged: true
---
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
#使Pod水平自動縮放,提高叢集的整體資源利用率,讓service中的Pod個數自動調整
metadata:
name: zabbix-web
namespace: zabbix
spec:
scaleTargetRef:
apiVersion: v1
kind: ReplicationController
name: zabbix-web
minReplicas: 1
maxReplicas: 5
metrics:
- type: Resource
resource:
name: cpu
targetAverageUtilization: 70
---
kind: PersistentVolume
#用於pod和volume之間解耦
apiVersion: v1
metadata:
name: zabbix-mysql-data
labels:
type: local
namespace: zabbix
spec:
capacity:
storage: 1Gi
accessModes:
- ReadWriteOnce #可以被一個node讀寫,縮寫為RWO
hostPath:
path: "/data"
---
kind: PersistentVolumeClaim
#PVC是使用PV資源的宣告
apiVersion: v1
metadata:
name: zabbix-mysql-data-claim
namespace: zabbix
spec:
accessModes:
- ReadWriteOnce
resources: #約定宣告PV的大小等引數
requests:
storage: 1Gi
volumeName: zabbix-mysql-data
---
apiVersion: v1
kind: List
metadata:
namespace: zabbix
items:
- apiVersion: v1
kind: Secret
# Secret解決了密碼、token、秘鑰等敏感資料的配置問題
type: Opaque #base64編碼格式的Secret,用來儲存密碼、秘鑰等
metadata:
name: db-secret
namespace: zabbix
data:
db-root-pass: "c29tZV90ZXN0X3Bhc3M="
db-zbx-user: "emFiYml4" # echo -n 'zabbix' | base64
db-zbx-pass: "emFiYml4" # mysql -uzabbix -pzabbix
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/7970627/viewspace-2762777/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Python註釋之TODO註釋Python
- JavaScript註釋:單行註釋和多行註釋詳解JavaScript
- 註釋
- Python如何新增註釋?註釋有幾種?Python
- HTML 註釋HTML
- Python註釋Python
- Java註釋Java
- React註釋React
- SCSS 註釋CSS
- JavaScript 註釋JavaScript
- 註解和註釋區別
- IDEA自定義類註釋和方法註釋(自定義groovyScript方法實現多行引數註釋)Idea
- python程式註釋Python
- 3 JS註釋JS
- /* */註釋的代替
- C# 註釋C#
- 10046 tracefile註釋
- IDEA新增註釋Idea
- iOS 註釋方法大全 程式碼塊加快捷鍵註釋iOS
- Python註釋方式有哪些?註釋時需要注意什麼?Python
- vscode註釋快捷鍵是啥 vscode註釋快捷鍵設定VSCode
- VsCode 新增檔案頭部註釋和函式註釋[koroFileHeader]VSCode函式Header
- idea java 類開發中註釋@Author @Description 註釋報警告IdeaJava
- 一段註釋
- IDEA自定義註釋Idea
- python中的註釋Python
- python如何新增註釋Python
- python如何註釋多行Python
- GoLang使用註釋 GoannoGolang
- Rust 註釋介紹Rust
- Oracle comment新增註釋Oracle
- PHP 註釋標記,PHP
- golang 註釋規範Golang
- CSS 註釋規範CSS
- 變數 和 註釋變數
- JavaScript 註釋規範JavaScript
- java命名與註釋Java
- git修改commit註釋GitMIT