0

我正在尝试将文件添加到 kubernetes 中 AWX 任务/Web 容器的 /etc/ 目录中。我对掌舵相当陌生,我不确定自己做错了什么。

我添加到 helm chart 的唯一内容是 configmap 中的 krb5 键,以及任务和 Web 容器的附加卷和卷挂载。krb5.conf 文件位于charts/mychart/files/

配置图:

apiVersion: v1
kind: ConfigMap
metadata:
  name: {{ include "awx.fullname" . }}-application-config
  labels:
    app.kubernetes.io/name: {{ include "awx.name" . }}
    helm.sh/chart: {{ include "awx.chart" . }}
    app.kubernetes.io/instance: {{ .Release.Name }}
    app.kubernetes.io/managed-by: {{ .Release.Service }}
data:
  krb5: |-
  {{ .Files.Get "krb5.conf"}}
  secret_key: {{ .Values.awx_secret_key }}
  awx_settings: |
    *some stuff*

部署:

卷添加到 deployment.yaml 的底部

volumes:
  - name: {{ include "awx.fullname" . }}-application-config
    configMap:
      name: {{ include "awx.fullname" . }}-application-config
      items:
        - key: awx_settings
          path: settings.py
        - key: secret_key
          path: SECRET_KEY
  - name: {{ include "awx.fullname" . }}-application-config-krb5
    configMap:
      name: {{ include "awx.fullname" . }}-application-config
      items:
        - key: krb5
          path: krb5.conf

卷挂载添加到任务/Web 容器

 volumeMounts:
   - mountPath: /etc/tower
     name: {{ include "awx.fullname" . }}-application-config
   - mountPath: /etc
     name: {{ include "awx.fullname" . }}-application-config-krb5

我正在尝试将文件挂载到 kubernetes pod 中的容器中,但出现以下错误:

  Warning  Failed     40s                kubelet, aks-prdnode-18232119-1  Error: failed to start container "web": Error response from daemon: OCI runtime create failed: container_linux.go:344: starting container process caused "process_linux.go:424: container init caused \"rootfs_linux.go:58: mounting \\\"/var/lib/docker/containers/d66044fe204abbf9a4d3772370d0f8d4184e339e59ad9a018f046eade03b8418/resolv.conf\\\" to rootfs \\\"/var/lib/docker/overlay2/d9fa9705d70bbb864ed526a96f6a2873b2720c41a9f9ef5b4a428902e4cf3c82/merged\\\" at \\\"/var/lib/docker/overlay2/d9fa9705d70bbb864ed526a96f6a2873b2720c41a9f9ef5b4a428902e4cf3c82/merged/etc/resolv.conf\\\" caused \\\"open /var/lib/docker/overlay2/d9fa9705d70bbb864ed526a96f6a2873b2720c41a9f9ef5b4a428902e4cf3c82/merged/etc/resolv.conf: read-only file system\\\"\"": unknown
4

1 回答 1

2

您将希望使用subPath:“进入”该选项-application-config-krb5并仅安装一个文件:

- mountPath: /etc/krb5.conf
  name: {{ include "awx.fullname" . }}-application-config-krb5
  subPath: krb5.conf

因为,正如错误正确指出的那样,您肯定不想破坏/etc几乎所有容器环境的目录(它会破坏/etc/passwd、、、/etc/hostsresolv.conf无数其他重要文件)

于 2019-06-07T06:31:54.437 回答