Kubernetes pull images from private registry fails --> unknown field "imagePullPolicy"
And here is the solution:
apiVersion: extensions/v1beta1kind: Deploymentmetadata: name: nginx-k8s-test9 namespace: k8s-test9spec: replicas: 1 template: metadata: labels: app: nginx-k8s-test9 spec: containers: - name: nginx-k8s-test9 image: my-registry.com/nginx-test/nginx:1.14.2 volumeMounts: - name: webcontent mountPath: usr/share/nginx/html ports: - containerPort: 80 volumes: - name: webcontent configMap: name: webcontent imagePullSecrets: - name: harborcred-test---kind: PersistentVolumeClaimapiVersion: v1metadata: name: webcontent namespace: k8s-test9 annotations: volume.alpha.kubernetes.io/storage-class: defaultspec: accessModes: [ReadWriteOnce] resources: requests: storage: 5Gi
The imagePullSecrets section was not at the right place.
can you chnage your config like this any give a try
kind: PersistentVolumeClaimapiVersion: v1metadata: name: webcontent namespace: k8s-test9 annotations: volume.alpha.kubernetes.io/storage-class: defaultspec: accessModes: [ReadWriteOnce] resources: requests: storage: 5Gi---apiVersion: extensions/v1beta1kind: Deploymentmetadata: name: nginx-k8s-test9 namespace: k8s-test9spec: replicas: 1 template: metadata: labels: app: nginx-k8s-test9 spec: containers: - name: nginx-k8s-test9 image: my-registry.com/nginx-test/nginx:1.14.2 imagePullSecrets: - name: harborcred imagePullPolicy: Always volumeMounts: - name: webcontent mountPath: usr/share/nginx/html ports: - containerPort: 80 volumes: - name: webcontent configMap: name: webcontent
with kubectl apply -f deployment.yaml
if it's not work try
kubectl apply -f deployment.yaml --validate=false
I resolved this via creating & providing secret in pipeline and not editing the .yaml file
we had requirement was not to save secret in .yaml file as it was fetched from repo
step 1: create pipeline add a task
Deploy to Kubernetes >> choose Action: Create Secret - can find step how to create secrets
step 2: Then in any Task where you are pulling the .yaml file can use the secret by providing the secret name in ImagePullSecrets of Deploy to Kubernetes