我尝试过在K8s中部署Kafka,所以需要用HostPath持久化它的卷,但是当卷配置添加到部署文件中时,Kafka Pod中会显示这个错误,Pod状态变为CrashloopBackoff:
mkdir: cannot create directory ‘/bitnami/config’: Permission denied
我想我必须更改权限,这样Pod才能创建此文件。
Deployment.yml:
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: kafka-broker
name: kafka-broker
namespace: kafka
spec:
replicas: 1
selector:
matchLabels:
app: kafka-broker
template:
metadata:
labels:
app: kafka-broker
spec:
containers:
- env:
- name: ALLOW_PLAINTEXT_LISTENER
value: "yes"
- name: KAFKA_BROKER_ID
value: "1"
- name: KAFKA_ZOOKEEPER_CONNECT
value: zookeeper-service:2181
- name: KAFKA_LISTENERS
value: PLAINTEXT://:9092
- name: KAFKA_ADVERTISED_LISTENERS
value: PLAINTEXT://:9092
image: bitnami/kafka
imagePullPolicy: IfNotPresent
name: kafka-broker
ports:
- containerPort: 9092
volumeMounts:
- name: kafka-data
readOnly: false
mountPath: "/bitnami/kafka"
volumes:
- name: kafka-data
hostPath:
path: /data/kafka-data
2条答案
按热度按时间polhcujo1#
你有没有试过设置
在您的部署配置中?
Bitnami映像是非根用户,已装载卷(=>fsGroup)所需的用户1001也是如此,请参阅https://github.com/bitnami/bitnami-docker-kafka#persisting-your-data
jhkqcmku2#
我已经解决了这个问题,方法是使用以下命令更改Worker服务器上的路径(装载Pod数据的位置)所有权:
但我认为这个解决方案不是最好的做法。