[英]no such file or directory Kubernetes
In one of my containers I am getting the error在我的一个容器中出现错误
Warning Failed 7m52s (x4 over 8m33s) kubelet Error: failed to start container "xxx-xxx": Error response from daemon: OCI runtime create failed: container_linux.go:380: starting container process caused: exec: "/src/application/entrypoint.sh": stat /src/application/entrypoint.sh: no such file or directory: unknown
I can't figure out why this is an issue, as running my docker-compose file outside of kube.netes hasn't presented any issues.我不明白为什么这是一个问题,因为在 kube.netes 之外运行我的 docker-compose 文件没有出现任何问题。
The yaml section for this looks like: yaml 部分如下所示:
spec:
replicas: 1
selector:
matchLabels:
io.kompose.service: xxx-xxx
strategy:
type: Recreate
template:
metadata:
creationTimestamp: null
labels:
io.kompose.service: xxx-xxx
spec:
containers:
- env:
- name: BEARER_TOKEN
valueFrom:
configMapKeyRef:
key: BEARER_TOKEN
name: xxx-xxx-env-dev
- name: PGADMIN_DEFAULT_EMAIL
valueFrom:
configMapKeyRef:
key: PGADMIN_DEFAULT_EMAIL
name: xxx-xxx-env-dev
- name: PGADMIN_DEFAULT_PASSWORD
valueFrom:
configMapKeyRef:
key: PGADMIN_DEFAULT_PASSWORD
name: xxx-xxx-env-dev
- name: PGADMIN_LISTEN_PORT
valueFrom:
configMapKeyRef:
key: PGADMIN_LISTEN_PORT
name: xxx-xxx-env-dev
- name: POSTGRES_DB
valueFrom:
configMapKeyRef:
key: POSTGRES_DB
name: xxx-xxx-env-dev
- name: POSTGRES_HOST_NAME
valueFrom:
configMapKeyRef:
key: POSTGRES_HOST_NAME
name: xxx-xxx-env-dev
- name: POSTGRES_PASSWORD
valueFrom:
configMapKeyRef:
key: POSTGRES_PASSWORD
name: xxx-xxx-env-dev
- name: POSTGRES_PORT
valueFrom:
configMapKeyRef:
key: POSTGRES_PORT
name: xxx-xxx-env-dev
- name: POSTGRES_USER
valueFrom:
configMapKeyRef:
key: POSTGRES_USER
name: xxx-xxx-env-dev
image: x/xx-xxx-xxx:prod
name: xxx-xxx
ports:
- containerPort: 5000
resources: {}
volumeMounts:
- mountPath: /src/application
name: xxx-xxx-claim0
restartPolicy: Always
volumes:
- name: xxx-xxx-claim0
persistentVolumeClaim:
claimName: xxx-xxx-claim0
It seems kube.netes can't locate the entrypoint file, what can I do to make it accessible?似乎 kube.netes 找不到入口点文件,我该怎么做才能使其可访问? Is this persisten volume related?这个持久卷是否相关? Sorry but I am a beginner at Kube.netes.抱歉,我是 Kube.netes 的初学者。
In docker-compose was the entrypoint.sh mounted from the host, eg $PWD/app?在 docker-compose 中是从主机挂载的 entrypoint.sh,例如 $PWD/app? If yes, this setup would be hard to replicate with kube.netes, kompose does have an option to use hostPath
but this would work only for a local dev setup like minikube or docker desktop.如果是,这个设置将很难用 kube.netes 复制,kompose 确实有一个使用hostPath
的选项,但这只适用于像 minikube 或 docker 桌面这样的本地开发设置。
For a dev workflow which works well with kube.netes tools like https://skaffold.dev/ or https://devspace.sh/ can be used, both have a file sync feature so that dev artifacts are synced inside the container, as it is said in some comments the entrypoint should not stay in a volume, it shuld be part of the image and the dev tools should allow the local copy to be deployed quickly during the dev+test cycles.对于与 kube.netes 配合良好的开发工作流程,可以使用https://skaffold.dev/或https://devspace.sh/等工具,它们都具有文件同步功能,以便在容器内同步开发工件,正如某些评论中所说,入口点不应保留在卷中,它应该是映像的一部分,并且开发工具应允许在开发+测试周期中快速部署本地副本。
Another option is to keep docker-compose for dev and use k8s/helm for production, although I am not a big fan of this approach since it will add a big overhead when troubleshooting prod.另一种选择是保留 docker-compose 用于开发并使用 k8s/helm 用于生产,尽管我不是这种方法的忠实拥护者,因为它会在对产品进行故障排除时增加很大的开销。
To workaround the error and be able to check the contents of the volume from inside the container add command: [ "/bin/bash", "-c", "sleep 1000000" ]
to your pod definition, then use kubectl exec
to get an interactive shell.要解决该错误并能够从容器内部检查卷的内容,请将command: [ "/bin/bash", "-c", "sleep 1000000" ]
添加到您的 pod 定义中,然后使用kubectl exec
获取交互式 shell。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.