gpt4 book ai didi

docker - 使用 kubernetes 部署 rabbit-mq

转载 作者:行者123 更新时间:2023-12-02 11:30:07 26 4
gpt4 key购买 nike

我正在从 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

光伏:
apiVersion: v1
kind: PersistentVolume
metadata:
name: rabbit-mq-data
labels:
type: local
spec:
accessModes:
- ReadWriteOnce
capacity:
storage: 16Gi
hostPath:
path: "/etc/rabbitmq"

Docker-撰写:
  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

最佳答案

最终我使用 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

关于docker - 使用 kubernetes 部署 rabbit-mq,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52081373/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com