创建一个pod, 新建一个 文件 buxybox.yaml
正常情况没人会建pod,都是建立deployment,在deployment中管理pod

apiVersion: v1
kind: Pod
metadata:
  name: mybusyboxpod
spec:
  volumes:
  - name: filedata
    emptyDir: {}
  - name: abc
    emptyDir: {}

  containers:
  - name: mybusybox-container
    image: busybox
    imagePullPolicy: IfNotPresent
    command: ['sh', '-c']
    args: ['echo "hello";sleep 120']
    volumeMounts:
    - name: filedata
      mountPath: /filetest
    - name: abc
      mountPath: /abcd
    env:
    - name: abc
      value: "123"
    lifecycle:
      postStart:
        httpGet:
          host: www.baidu.com
          path: /
          port: 80
          scheme: HTTP
      preStop:
        exec:
          command: ['sh','-c','echo "goodbye";sleep 10']

k8s pod

k8s pod

相关文章: