deployments do not support (honor) container restartPolicy #24725

 

[root@node1 test]# cat asda.yaml 
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  annotations:
    deployment.kubernetes.io/revision: "1"
  creationTimestamp: "2020-07-30T07:19:31Z"
  generation: 1
  name: asda
  namespace: default
  resourceVersion: "4098967"
  selfLink: /apis/extensions/v1beta1/namespaces/default/deployments/asda
  uid: c5e6490a-bab2-47ad-a265-09ca6c9d9b4a
spec:
  progressDeadlineSeconds: 600
  replicas: 1
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      app: qqqcpu
  strategy:
    rollingUpdate:
      maxSurge: 25%
      maxUnavailable: 25%
    type: RollingUpdate
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: qqqcpu
    spec:
      containers:
      - args:
        - "1000000"
        command:
        - sleep
        image: 192.168.56.103/test_chart/busybox:latest
        imagePullPolicy: OnFailure
        name: qqqcpu
        resources: {}
        terminationMessagePath: /dev/termination-log
        terminationMessagePolicy: File
      dnsPolicy: ClusterFirst
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext: {}
      terminationGracePeriodSeconds: 30
status:
  availableReplicas: 1
  conditions:
  - lastTransitionTime: "2020-07-30T07:19:31Z"
    lastUpdateTime: "2020-07-30T07:19:37Z"
    message: ReplicaSet "asda-dc4567ccd" has successfully progressed.
    reason: NewReplicaSetAvailable
    status: "True"
    type: Progressing
  - lastTransitionTime: "2020-08-17T01:12:45Z"
    lastUpdateTime: "2020-08-17T01:12:45Z"
    message: Deployment has minimum availability.
    reason: MinimumReplicasAvailable
    status: "True"
    type: Available
  observedGeneration: 1
  readyReplicas: 1
  replicas: 1
  updatedReplicas: 1

 

 And it deploys fine without the restartPolicy. However, I do not want the process to be run again once finished, hence I added the 'restartPolicy: Never'. Unfortunately I get the following error when I attempt to deploy:

[root@node1 test]# kubectl apply -f asda.yaml 
Warning: kubectl apply should be used on resource created by either kubectl create --save-config or kubectl apply
The Deployment "asda" is invalid: spec.template.spec.containers[0].imagePullPolicy: Unsupported value: "OnFailure": supported values: "Always", "IfNotPresent", "Never"

 

Please see https://github.com/kubernetes/kubernetes/issues/24725

It appears that only "Always" is supported.

posted @ 2020-08-18 19:16  loorean  阅读(448)  评论(0)    收藏  举报