如何挂载kubernetes.io/dockerconfigjson

时间:2019-05-29 13:31:44

标签: kubernetes

我有一个kubernetes.io/dockerconfigjson类型的秘密:

$ kubectl describe secrets dockerjson

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

Type:  kubernetes.io/dockerconfigjson

Data
====
.dockerconfigjson:  1335 bytes

当我尝试将此秘密安装到容器中时-我找不到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

仅打印:

/kaniko/.docker/config.json

这是完全支持还是我做错了什么?

Am使用OpenShift 3.9-应该是Kubernetes 1.9。

1 个答案:

答案 0 :(得分:0)

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