我正在从docker-compose迁移到kuberenetes。 我们正在使用的服务之一是Rabbit-mq。 当我尝试部署Rabbit-mq 3.6.16-management时,收到错误消息:
/usr/local/bin/docker-entrypoint.sh:第382行:/etc/rabbitmq/rabbitmq.config:权限被拒绝。
虽然可以在docker-compose部署中使用。
Kuberentes :
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: rabbit-mq
name: rabbit-mq
spec:
replicas: 1
selector:
matchLabels:
app: rabbit-mq
strategy:
type: Recreate
template:
metadata:
labels:
app: rabbit-mq
spec:
containers:
- image: rabbitmq:3.6.16-management
name: rabbit-mq
ports:
- containerPort: 15671
- containerPort: 5671
volumeMounts:
- mountPath: /etc/rabbitmq
name: rabbit-mq-data
restartPolicy: Always
hostname: rabbit-mq
volumes:
- name: rabbit-mq-data
persistentVolumeClaim:
claimName: rabbit-mq-data
PVC:
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
labels:
app: rabbit-mq-data
name: rabbit-mq-data
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 16Gi
PV:
apiVersion: v1
kind: PersistentVolume
metadata:
name: rabbit-mq-data
labels:
type: local
spec:
accessModes:
- ReadWriteOnce
capacity:
storage: 16Gi
hostPath:
path: "/etc/rabbitmq"
Docker-Compose:
rabbit-mq:
image: rabbitmq:3.6.16-management
ports:
- "15671:15671"
- "5671:5671"
container_name: rabbit-mq
volumes:
- rabbit-mq-data:/etc/rabbitmq
restart: on-failure:5
答案 0 :(得分:1)
最终,我使用configmap和secrets而不是PV来挂载文件,并且按预期方式工作。
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: rabbit-mq
name: rabbit-mq
spec:
replicas: 1
selector:
matchLabels:
app: rabbit-mq
template:
metadata:
labels:
app: rabbit-mq
spec:
containers:
- image: rabbitmq:3.6.16-management
name: rabbit-mq
ports:
- containerPort: 15671
- containerPort: 5671
volumeMounts:
- name: rabbit-mq-data
mountPath: /etc/rabbitmq
readOnly: false
- name: mq-secret
mountPath: /etc/rabbitmq/certfiles
#readOnly: true
volumes:
- name: mq-secret
secret:
defaultMode: 420
secretName: rabbit-mq-secrets
- configMap:
defaultMode: 420
items:
- key: rabbitmq.config
path: rabbitmq.config
name: mq-config
name: rabbit-mq-data