pod hook 钩子函数 生命周期 lifecycle/postStart/preStop

hook 钩子函数 生命周期 lifecycle/postStart/preStop


hook-demo1.yaml    lifecycle/postStart
---
apiVersion: v1
kind: Pod
metadata:
    name: hook-demo1
    labels:
        app: hook
spec:
    containers:
    - name: hook-demo1
      image: nginx
      ports:
      - name: webport
          containerPort: 80
      lifecycle:
          postStart:
              exec:
                  command: ["/bin/sh","-c","echo Hello from the postStart Handler > /usr/share/message"]



hook-demo2.yaml    lifecycle/preStop
---
apiVersion: v1
kind: Pod
metadata:
  name: hook-demo2
  labels:
    app: hook
spec:
  containers:
  - name: hook-demo2
    image: nginx
    ports:
    - name: webport
      containerPort: 80
    volumeMounts:
    - name: message
      mountPath: /usr/share/
    lifecycle:
      preStop:
        exec:
          command: ['/bin/sh','-c','echo Hello from the preStop Handler > /usr/share/message']
  volumes:
  - name: message
    hostPath:
      path: /tmp

posted @ 2019-10-28 19:07  walkersss  阅读(1515)  评论(0编辑  收藏  举报