Azure Kubernetes服务给出了建议--应该对容器强制执行可变(只读)根文件系统。
没有它,我的部署就像预期的那样工作,但是在添加readOnlyRootFilesystem: true之后,它就不能工作了,因为容器不能写。
我也使用PVC与天蓝色的存储文件,它显示成功的绑定,但它总是显示为空。
这是我的deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: redis-healthy-deployment
labels:
app: redis
spec:
replicas: 3
selector:
matchLabels:
app: redis
template:
metadata:
labels:
app: redis
annotations:
container.apparmor.security.beta.kubernetes.io/redis: runtime/default
spec:
containers:
- name: redis
image: <customer-registry>.azurecr.io/redis:latest
ports:
- containerPort: 80
resources:
limits:
cpu: 100m
memory: 250Mi
securityContext:
privileged: false
readOnlyRootFilesystem: true
allowPrivilegeEscalation: false
runAsNonRoot: true
runAsUser: 1000
volumeMounts:
- mountPath: "/mnt/azure"
name: volume
- mountPath: "mnt/secrets-store"
name: secrets-mount
readOnly: true
volumes:
- name: volume
persistentVolumeClaim:
claimName: helloworld-pvc
- name: secrets-mount
csi:
driver: secrets-store.csi.k8s.io
readOnly: true
volumeAttributes:
secretProviderClass: "azure-keyvault"下面是豆荚的错误:
rm: can't remove '/home/test/mi-4.0.0/tmp/README': Read-only file system
rm: can't remove '/home/test/mi-4.0.0/tmp/work': Read-only file system如果我使用PVC,那么吊舱/容器不应该写信给PVC吗??
如果有人能帮我解决这个问题,我会非常感激的。我很高兴提供更多的细节
发布于 2022-04-29 22:54:33
的确,如果可能的话,只读文件系统更好。但是,由于某种原因,某些应用程序需要将数据写入磁盘。
您的错误不是关于挂载的卷,而是关于/tmp目录的。
通过将空dir卷挂载到此路径,您可以使只读文件系统仅使该部分可写。
volumes:
- name: tmp
emptyDir: {}volumeMounts:
- name: tmp
mountPath: /home/test/mi-4.0.0/tmp请注意,卷将覆盖要安装到的位置。如果容器启动时需要此目录中的数据,则可以选择安装相同卷并将所需文件添加到其中的initContainer。
https://stackoverflow.com/questions/72064353
复制相似问题