<p>I'm trying to pull an image from my priavte harbor registry. In Kubernetes I created a secret first as explained in this documentation:</p>

<p><a href="https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/" rel="nofollow noreferrer">https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/</a></p>

<p>Then I tried to implement that into my deployment.yaml:</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: nginx-k8s-test9
  namespace: k8s-test9
spec:
  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
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: webcontent
  namespace: k8s-test9
  annotations:
    volume.alpha.kubernetes.io/storage-class: default
spec:
  accessModes: [ReadWriteOnce]
  resources:
    requests:
      storage: 5Gi
</code></pre>

<p>When I try to create the deployment I get the following error message:</p>

<pre><code>error: error validating "deployment.yaml": error validating data: [ValidationError(Deployment.spec.template.spec.imagePullSecrets[0]): unknown field "imagePullPolicy" in io.k8s.api.core.v1.LocalObjectReference, ValidationError(Deployment.spec.template.spec.imagePullSecrets[0]): unknown field "ports" in io.k8s.api.core.v1.LocalObjectReference, ValidationError(Deployment.spec.template.spec.imagePullSecrets[0]): unknown field "volumeMounts" in io.k8s.api.core.v1.LocalObjectReference]; if you choose to ignore these errors, turn validation off with --validate=false
</code></pre>

<p>I guess it's a yaml issue somehow but I don't know where it should be. </p>

<p>And here is the solution:</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: nginx-k8s-test9
  namespace: k8s-test9
spec:
  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: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: webcontent
  namespace: k8s-test9
  annotations:
    volume.alpha.kubernetes.io/storage-class: default
spec:
  accessModes: [ReadWriteOnce]
  resources:
    requests:
      storage: 5Gi

</code></pre>

<p>The imagePullSecrets section was not at the right place.</p>
