gpt4 book ai didi

kubernetes - Kubernetes配置文件从主机到容器?

转载 作者:行者123 更新时间:2023-12-02 12:04:47 29 4
gpt4 key购买 nike

安装配置文件时出现错误,任何人都可以提供帮助吗?

在volumeMounts上使用subPath时出现错误:

Error: stat /var/config/openhim-console.json: no such file or directory.

我可以读取此文件。

在volumeMounts上没有subPath时,出现此错误:
Warning  Failed   13s                kubelet, ip-10-0-65-230.eu-central-1.compute.internal  Error: failed to start container "openhim-console": Error response from daemon: oci runtime error: container_linux.go:262: starting container process caused "process_linux.go:339: container init caused \"rootfs_linux.go:57: mounting \\\"/var/config/openhim-console.json\\\" to rootfs \\\"/var/lib/docker/overlay2/7408e2aa7e93b3c42ca4c2320681f61ae4bd4b02208364eee8da5f51d587ed21/merged\\\" at \\\"/var/lib/docker/overlay2/7408e2aa7e93b3c42ca4c2320681f61ae4bd4b02208364eee8da5f51d587ed21/merged/usr/share/nginx/html/config/default.json\\\" caused \\\"not a directory\\\"\""
: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type
Warning BackOff 2s kubelet, ip-10-0-65-230.eu-central-1.compute.internal Back-off restarting failed container

这是deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: openhim-console-deployment
spec:
replicas: 1
selector:
matchLabels:
component: openhim-console
template:
metadata:
labels:
component: openhim-console
spec:
volumes:
- name: console-config
hostPath:
path: /var/config/openhim-console.json
containers:
- name: openhim-console
image: jembi/openhim-console:1.13.rc
ports:
- containerPort: 80
volumeMounts:
- name: console-config
mountPath: /usr/share/nginx/html/config/default.json
subPath: default.json
env:
- name: NODE_ENV
value: development

最佳答案

可能hostPath应该保留path而不是文件路径:/var/config/openhim-console.json,因为您要装载卷而不是文件。

如果是,应将type指定为File

另请参阅docs#hostpath

关于kubernetes - Kubernetes配置文件从主机到容器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55378171/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com