/data/k8s-yaml/base_resource/deployment/nginx-v1.12.yaml:
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deploy
namespace: app
spec:
replicas: 5
selector:
matchLabels:
app: nginx
release: stable
tier: slb
partition: website
strategy:
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
template:
metadata:
labels:
app: nginx
release: stable
tier: slb
partition: website
version: v1.12
spec:
containers:
- name: nginx-pod
image: harbor.od.com/public/nginx:v1.12
lifecycle:
postStart:
exec:
command:
- /bin/bash
- -c
- "echo 'health check ok!' > /usr/share/nginx/html/health.html"
readinessProbe:
initialDelaySeconds: 5
httpGet:
port: 80
path: /health.html
livenessProbe:
initialDelaySeconds: 10
periodSeconds: 5
httpGet:
port: 80
path: /health.html
[root@hdss7-21 ~]# kubectl apply -f http://k8s-yaml.od.com/base_resource/deployment/nginx-v1.12.yaml --record
[root@hdss7-21 ~]# kubectl get pods -n app -l partition=website # 查看
NAME READY STATUS RESTARTS AGE
nginx-deploy-5597c8b45-425ms 1/1 Running 0 5m12s
nginx-deploy-5597c8b45-5p2rz 1/1 Running 0 9m34s
nginx-deploy-5597c8b45-dw7hd 1/1 Running 0 9m34s
nginx-deploy-5597c8b45-fg82k 1/1 Running 0 5m12s
nginx-deploy-5597c8b45-sfxmg 1/1 Running 0 9m34s
[root@hdss7-21 ~]# kubectl get rs -n app -l partition=website -o wide
NAME DESIRED CURRENT READY AGE CONTAINERS IMAGES SELECTOR
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
[root@hdss7-21 ~]# kubectl get deployment -n app -o wide
NAME READY UP-TO-DATE AVAILABLE AGE CONTAINERS IMAGES SELECTOR
nginx-deploy 8/8 8 8 11m nginx-pod harbor.od.com/public/nginx:v1.12 app=nginx,partition=website,release=stable,tier=slb