如何解决如何更改持久卷声明更改默认目录?
kind: Job
metadata:
name: test
spec:
ttlSecondsAfterFinished: 3600
backoffLimit: 0
template:
metadata:
annotations:
version: "1.0"
labels:
component: test
name: test
spec:
securityContext:
runAsUser: 1000
runAsGroup: 1000
fsGroup: 5000
restartPolicy: Never
initContainers:
- name: test-init
image: sampleimage:latest
volumeMounts:
- name: testvol
mountPath: /u01/subpath
command: ['sh','-c',"whoami && cd /u01/subpath && echo 1 && mkdir -p -m 0777 folder1 && echo 2 && mkdir -p -m 0777 folder2 && echo 4 && echo done"]
containers:
- image: sampleimage:latest
imagePullPolicy: Always
name: testcontainer
resources:
requests:
cpu: 1
memory: 4G
limits:
cpu: 1
memory: 4G
volumeMounts:
- name: testvol
mountPath: /u01/subpath/folder1
subPath: folder1
- name: testvol
mountPath: /u01/subpath/folder2
subPath: folder2
command: ['sh','ls -lrt /u01 ']
volumes:
- name: testvol
persistentVolumeClaim:
claimName: testpvc```
我正在尝试创建具有上述规范的工作。文件夹 1 和文件夹 2 的默认用户以 root 身份出现。当持久卷声明安装到具有如图所示的子路径的文件夹时,如何更改文件夹的用户?我尝试将 init-containers 中的权限更改为 chmod 777 -R /u01/subpath 但它抛出一个错误,提示无法更改文件夹的所有者或权限。
解决方法
尝试 chown uid 示例:
name: testcontainer
command: ["sh","-c","chmod 777 /u01/ && chown 1000:1000 /u01/"]
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。