安装配置文件时出现错误,任何人都可以提供帮助吗?
在volumeMounts上使用subPath时出现错误:
Error: stat /var/config/openhim-console.json: no such file or directory.
我可以读取此文件。
在volumeMounts上没有子路径,我得到此错误:
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
答案 0 :(得分:2)
在装入卷而不是文件时,hostPath
应该保留path
而不是文件路径:/var/config/openhim-console.json
。
如果是,则type
应指定为File
。
另请参阅docs#hostpath
答案 1 :(得分:0)
您应该使用:
volumes:
- name: host-file
hostPath:
path: /var/log/waagent.log
type: File
或
volumes:
- name: test-volume
hostPath:
path: /data
# Directory is the default, so this field is optional.
type: Directory
示例:
apiVersion: v1
kind: Pod
metadata:
name: test-pd
spec:
containers:
- image: k8s.gcr.io/test-webserver
name: test-container
volumeMounts:
- mountPath: /test-pd
name: test-volume
- mountPath: /var/log/lala/aaa.log
name: host-file
volumes:
- name: test-volume
hostPath:
path: /data
# this field is optional
type: Directory
- name: host-file
hostPath:
path: /var/log/waagent.log
type: File
subpath通常在您只需要在容器内安装一个路径而不是根目录时使用。
您可以在docs中找到更多详细信息。