[root@k8scloude1 pod]# vim pod5.yaml #preStop处理函数指定在容器关闭之前执行"/bin/sh","-c","/usr/sbin/nginx -s quit"[root@k8scloude1 pod]# cat pod5.yamlapiVersion: v1kind: Podmetadata:creationTimestamp: nulllabels:run: pod5name: pod5spec:terminationGracePeriodSeconds: 600containers:- image: nginxcommand: ["sh","-c","date > /tmp/aa.txt ; sleep 10000"]imagePullPolicy: IfNotPresentname: n1resources: {}lifecycle:postStart:exec:command: ["/bin/sh","-c","date >> /tmp/bb.txt"]preStop:exec:command: ["/bin/sh","-c","/usr/sbin/nginx -s quit"]dnsPolicy: ClusterFirstrestartPolicy: Alwaysstatus: {}[root@k8scloude1 pod]# kubectl apply -f pod5.yamlpod/pod5 created[root@k8scloude1 pod]# kubectl get podNAMEREADYSTATUSRESTARTSAGEpod51/1Running05s[root@k8scloude1 pod]# kubectl delete pod pod5pod "pod5" deleted^C[root@k8scloude1 pod]# kubectl delete pod pod5 --forcewarning: Immediate deletion does not wait for confirmation that the running resource has been terminated. The resource may continue to run on the cluster indefinitely.pod "pod5" force deleted
【五 pod钩子 pod:pod hook和优雅的关闭nginx pod】
推荐阅读
- 弹壳特攻队第五关通关攻略
- 第五人格第23赛季什么结束
- 第五人格第24赛季什么时候上线
- LolliPods plus和pro有什么差别_LolliPods plus和pro怎么选择
- iptables和firewalld基础
- 五 Selenium4+Python3系列 - 多窗口处理之句柄切换
- 鸡皮疙瘩第五关拼车怎么过
- 原神在弹弹菇上连续弹跳五次怎么完成
- 商业银行贷款的五级分类 银行五级分类标准
- 第五人格古董商推演任务要怎样完成