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

/data/k8s-yaml/base_resource/deployment/nginx-v1.12.yaml:

  1. apiVersion: apps/v1
  2. kind: Deployment
  3. metadata:
  4. name: nginx-deploy
  5. namespace: app
  6. spec:
  7. replicas: 5
  8. selector:
  9. matchLabels:
  10. app: nginx
  11. release: stable
  12. tier: slb
  13. partition: website
  14. strategy:
  15. rollingUpdate:
  16. maxSurge: 1
  17. maxUnavailable: 0
  18. template:
  19. metadata:
  20. labels:
  21. app: nginx
  22. release: stable
  23. tier: slb
  24. partition: website
  25. version: v1.12
  26. spec:
  27. containers:
  28. - name: nginx-pod
  29. image: harbor.od.com/public/nginx:v1.12
  30. lifecycle:
  31. postStart:
  32. exec:
  33. command:
  34. - /bin/bash
  35. - -c
  36. - "echo 'health check ok!' > /usr/share/nginx/html/health.html"
  37. readinessProbe:
  38. initialDelaySeconds: 5
  39. httpGet:
  40. port: 80
  41. path: /health.html
  42. livenessProbe:
  43. initialDelaySeconds: 10
  44. periodSeconds: 5
  45. httpGet:
  46. port: 80
  47. path: /health.html
  1. [root@hdss7-21 ~]# kubectl apply -f http://k8s-yaml.od.com/base_resource/deployment/nginx-v1.12.yaml --record
  2. [root@hdss7-21 ~]# kubectl get pods -n app -l partition=website # 查看
  3. NAME READY STATUS RESTARTS AGE
  4. nginx-deploy-5597c8b45-425ms 1/1 Running 0 5m12s
  5. nginx-deploy-5597c8b45-5p2rz 1/1 Running 0 9m34s
  6. nginx-deploy-5597c8b45-dw7hd 1/1 Running 0 9m34s
  7. nginx-deploy-5597c8b45-fg82k 1/1 Running 0 5m12s
  8. nginx-deploy-5597c8b45-sfxmg 1/1 Running 0 9m34s
  9. [root@hdss7-21 ~]# kubectl get rs -n app -l partition=website -o wide
  10. NAME DESIRED CURRENT READY AGE CONTAINERS IMAGES SELECTOR
  11. nginx-deploy-5597c8b45 8 8 8 10m nginx-pod harbor.od.com/public/nginx:v1.12 app=nginx,partition=website,pod-template-hash=5597c8b45,release=stable,tier=slb
  12. [root@hdss7-21 ~]# kubectl get deployment -n app -o wide
  13. NAME READY UP-TO-DATE AVAILABLE AGE CONTAINERS IMAGES SELECTOR
  14. nginx-deploy 8/8 8 8 11m nginx-pod harbor.od.com/public/nginx:v1.12 app=nginx,partition=website,release=stable,tier=slb

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