当前位置:  首页>> 技术小册>> Kubernets合辑5-Pod控制器

  1. ```

[root@hdss7-200 base_resource]# cat /data/k8s-yaml/base_resource/daemonset/proxy-v1.12.yaml
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: proxy-daemonset
namespace: app
labels:
app: nginx
release: stable
partition: CRM
spec:
selector:
matchLabels:
app: nginx
release: stable
tier: proxy
partition: CRM
updateStrategy:
rollingUpdate:
maxUnavailable: 1
template:
metadata:
labels:
app: nginx
release: stable
tier: proxy
partition: CRM
version: v1.12
spec:
containers:

  1. - name: nginx-proxy
  2. image: harbor.od.com/public/nginx:v1.12
  3. ports:
  4. - name: http
  5. containerPort: 80
  6. hostPort: 10080
  7. lifecycle:
  8. postStart:
  9. exec:
  10. command:
  11. - /bin/bash
  12. - -c
  13. - "echo 'health check ok!' > /usr/share/nginx/html/health.html"
  14. readinessProbe:
  15. initialDelaySeconds: 5
  16. httpGet:
  17. port: 80
  18. path: /health.html
  19. livenessProbe:
  20. initialDelaySeconds: 10
  21. periodSeconds: 5
  22. httpGet:
  23. port: 80
  24. path: /health.html

[root@hdss7-21 ~]# kubectl apply -f http://k8s-yaml.od.com/base_resource/daemonset/proxy-v1.12.yaml —record
[root@hdss7-21 ~]# kubectl get daemonset -n app
NAME DESIRED CURRENT READY UP-TO-DATE AVAILABLE NODE SELECTOR AGE
proxy-daemonset 2 2 2 2 2 56s

[root@hdss7-21 ~]# kubectl get pod -n app -l tier=proxy -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
proxy-daemonset-7stgs 1/1 Running 0 8m31s 172.7.22.9 hdss7-22.host.com
proxy-daemonset-dxgdp 1/1 Running 0 8m31s 172.7.21.10 hdss7-21.host.com
[root@hdss7-21 ~]# curl -s 10.4.7.22:10080/info # 通过宿主机的端口访问
2020-01-22T13:15:58+00:00|172.7.22.9|nginx:v1.12
[root@hdss7-21 ~]# curl -s 10.4.7.21:10080/info
2020-01-22T13:16:05+00:00|172.7.21.10|nginx:v1.12
```


该分类下的相关小册推荐: