How to mount a kubernetes.io/dockerconfigjson

5/29/2019

I have a secret of type kubernetes.io/dockerconfigjson:

$ kubectl describe secrets dockerjson

Name:         dockerjson
Namespace:    my-prd
Labels:       <none>
Annotations:  <none>

Type:  kubernetes.io/dockerconfigjson

Data
====
.dockerconfigjson:  1335 bytes

When I try to mount this secret into a container - I cannot find a config.json:

- name: dump
  image: kaniko-executor:debug
  imagePullPolicy: Always
  command: ["/busybox/find", "/", "-name", "config.json"]
  volumeMounts:
  - name: docker-config
    mountPath: /foobar
volumes:
- name: docker-config
  secret:
    secretName: dockerjson
      defaultMode: 256

which only prints:

/kaniko/.docker/config.json

Is this supported at all or am I doing something wrong?

Am using OpenShift 3.9 - which should be Kubernetes 1.9.

-- abergmeier
kubernetes

1 Answer

5/29/2019
apiVersion: v1
kind: Pod
metadata:
  name: kaniko
spec:
  containers:
  - name: kaniko
    image: gcr.io/kaniko-project/executor:debug-v0.9.0
    command:
    - /busybox/cat
    resources:
      limits:
        cpu: 2
        memory: 2Gi
      requests:
        cpu: 0.5
        memory: 500Mi
    tty: true
    volumeMounts:
      - name: docker-config
        mountPath: /kaniko/.docker/
  volumes:
    - name: docker-config
      secret:
        secretName: dockerjson
        items:
          - key: .dockerconfigjson
            path: config.json
-- hariK
Source: StackOverflow