首页 > 解决方案 > 如何挂载 kubernetes.io/dockerconfigjson

问题描述

我有一个类型的秘密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

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

我正在使用 OpenShift 3.9 - 应该是 Kubernetes 1.9。

标签: kubernetes

解决方案


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

推荐阅读