【发布时间】:2020-12-10 12:51:38
【问题描述】:
我正在尝试创建一个运行 zookeper 的 statefulset,但我希望它以非 root 身份运行(即在 zookeper 用户下)。
这是用于此目的的图像:
https://github.com/kubernetes-retired/contrib/blob/master/statefulsets/zookeeper/Dockerfile
这就是我尝试挂载卷的方式(显然我需要一个根据this 的初始化容器):
initContainers:
# Changes username for volumes
- name: changes-username
image: busybox
command:
- /bin/sh
- -c
- |
chown -R 1000:1000 /var/lib/zookeeper /etc/zookeeper-conf # <<<<--- this returns
# cannot change ownership, permission denied
# read-only filesystem.
containers:
- name: zookeeper
imagePullPolicy: IfNotPresent
image: my-repo/k8szk:3.4.14
command:
- sh
- -c
- |
zkGenConfig.sh # The script right here requires /var/lib/zookeper to be owned by zookeper user.
# Initially zookeeper user does own it as per the dockerfile above,
# but when mounting the volume, the directory becomes owned by root
# hence the script fails.
volumeMounts:
- name: zk-data
mountPath: /var/lib/zookeeper
- name: zk-log4j-config
mountPath: /etc/zookeeper-conf
我还尝试添加securityContext:fsGroup: 1000,没有任何变化。
【问题讨论】:
标签: docker kubernetes apache-zookeeper