kubernetes init containers using a private repo

2/23/2017

has anyone tried having the image for an init container in a private repo when using the imagePullSecret to access the registry? Below is a sample for a private registry with image pull secrets.

apiVersion: v1
kind: Pod
metadata:
  name: private-reg
spec:
   containers:
     - name: private-reg-container
       image: privatereg:5000/private-image-name
  imagePullSecrets:
    - name: regsecret

When you define the init containers, the secrets cannot be included with the init-container since its not part of the container spec.

So will it still work using init containers? I see in the example https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-initialization/ that they have a volume created in the spec and its available in the init.

-- JamStar
kubernetes

1 Answer

2/23/2017

You can add it via annotations:

annotations:
  pod.beta.kubernetes.io/init-containers: '[
    {
      "name": "install",
       "image": "my-init-container",
       "imagePullSecrets": "something"
     }
    ]'
-- jaxxstorm
Source: StackOverflow