Getting errors when using "imagePullSecrets" in my kubernetes deployment

12/9/2021

I have a kind:deployment file, and they are forcing the image to be defined down here in the "initContainers", but I can't get my image in my own registry to load. If I try to put

  imagePullSecrets:
  - name: regcred

in line with the "image" down below, I get error converting YAML to JSON: yaml: found character that cannot start any token. And I get the same thing if I move it around to different spots. Any ideas how I can use imagePullCreds here?

spec:
  template:
    metadata:
    spec:
      initContainers:
      - env:
        - name: "BOOTSTRAP_DIRECTORY"
          value: "/bootstrap-data"
        image: "my-custom-registry.com/my-image:1.6.24-SNAPSHOT"
        imagePullPolicy: "Always"
        name: "bootstrap"
-- Mike K.
docker
docker-registry
kubectl
kubernetes
kustomize

1 Answer

12/9/2021

Check if you are using tabs for indentation; YAML doesn't allow tabs; it requires spaces.

Also, You should use imagePullSecrets under spec instead of under containers.

spec:
  template:
    metadata:
    spec:
      imagePullSecrets:
      - name: regcred
      initContainers:
-- Hamid Ostadvali
Source: StackOverflow