如何解决Azure Kubernetes Service中PVC的读写权限问题
当前,我尝试在Azure Kubernetes服务上设置Nextcloud作为练习。基本上,该应用程序似乎正在运行,但是在连接数据库之后,Nextcloud的结尾类似于...
请将存储空间的权限更改为0770,以防止其他人访问您的数据
我想是因为我使用了azurefile
共享作为持久卷。我的pvc部署如下所示:
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: nextcloud-shared-storage-claim
labels:
app: nextcloud
spec:
accessModes:
- ReadWriteOnce
storageClassName: azurefile
resources:
requests:
storage: 5Gi
我已经对该主题进行了研究,并找到了通过securityContext
实现对pod的权限使用的方法。因为我只是刚开始在Azure上使用Kubernetes,所以我在将我的nextcloud部署文件与Pod绑定在一起时遇到了一些麻烦。
要完成该帖子-这是我使用的Nextcloud的部署文件
apiVersion: apps/v1
kind: Deployment
metadata:
name: nextcloud-server
labels:
app: nextcloud
spec:
replicas: 1
selector:
matchLabels:
pod-label: nextcloud-server-pod
template:
metadata:
labels:
pod-label: nextcloud-server-pod
spec:
containers:
- name: nextcloud
image: nextcloud:20-apache
volumeMounts:
- name: server-storage
mountPath: /var/www/html
subPath: server-data
volumes:
- name: server-storage
persistentVolumeClaim:
claimName: nextcloud-shared-storage-claim
---
apiVersion: v1
kind: Service
metadata:
name: nextcloud-server
labels:
app: nextcloud
spec:
selector:
pod-label: nextcloud-server-pod
ports:
- protocol: TCP
port: 80
我猜/希望这很简单。
解决方法
将此答案发布为社区Wiki,因为它可能对社区有所帮助。随意扩展。
如@Nick Graham在评论中所述
要修改已安装卷的权限,您需要在容器启动后执行脚本。一些图像使您可以选择将脚本复制到特定文件夹中,然后在启动时执行该文件夹,请检查文档以查看您使用的图像是否提供该功能
examples很少。
另外根据此comment,您可以尝试在存储类中指定此权限。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。