Rancher Server 设置
- Rancher 版本:2.7.5
- 安装选项 (Docker install/Helm Chart): Helm Chart)
- 如果是 Helm Chart 安装,需要提供 Local 集群的类型(RKE1, RKE2, k3s, EKS, 等)和版本:
- 在线或离线部署:RKE2
下游集群信息
- Kubernetes 版本: v1.26.5+rke2r1
- Cluster Type (Local/Downstream): Local
用户信息
主机操作系统:
Centos 7.9
问题描述:
在Rancher UI上管理下游RKE2集群创建Deployment工作负载时,因应用系统限制无法通过configMap环境变量导入方式实现,想要直接映射本地的配置文件application.yml至pod容器内的目录下,如docker中实现方式:docker run -v /data/application.yml:/data/run/application.yml。
请教是否有实现的方法?
使用configMap直接挂载yml配置文件步骤:
1、系统配置文件configMap创建:
2、pod挂载存储
3、容器挂载存储
4、pod编排后报错
/install/time/application.yml (via /proc/self/fd/6), flags: 0x5001: not a directory: unknown)
CrashLoopBackOff (back-off 5m0s restarting failed container=container-0 pod=time-dev-6db99994fb-4bn5r_dev-information(73ad95a8-8834-41c1-88d3-94b025829d2d)) | Last state: Terminated with 128: StartError (failed to create containerd task: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container init: error mounting "/var/lib/kubelet/pods/73ad95a8-8834-41c1-88d3-94b025829d2d/volumes/kubernetes.io~configmap/dev-time-config" to rootfs at "/install/time/application.yml": mount /var/lib/kubelet/pods/73ad95a8-8834-41c1-88d3-94b025829d2d/volumes/kubernetes.io~configmap/dev-time-config:/install/time/application.yml (via /proc/self/fd/6), flags: 0x5001: not a directory: unknown), started: Thu, Jan 1 1970 8:00:00 am, finished: Tue, Aug 22 2023 11:13:57 am
已通过mountPath和subPath的写法方式解决,如下图:
yaml文件
spec:
containers:
- image: my-time-images
imagePullPolicy: Always
name: container-0
securityContext:
allowPrivilegeEscalation: false
privileged: false
readOnlyRootFilesystem: false
runAsNonRoot: false
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /install/time/application.yml
name: dev-time-config-application
subPath: application.yml
1 个赞