【发布时间】:2021-11-19 00:18:05
【问题描述】:
我是 Kubernetes 新手,通过实验学习。我已经创建了 RabbitMQ statefulset 并且它正在工作。但是,我面临的问题是我使用它的管理门户的方式。 默认情况下,RabbitMQ 提供来宾/来宾凭据,但仅适用于 localhsot。它让我想到我应该有另一个管理员用户以及我在 API 端的连接字符串来访问 RabbitMQ。 (目前在 API 方面,我也使用 guest:guest@.... 作为不好的做法)
我喜欢改变,但我不知道如何改变。我可以手动登录到 RabbitMQ 管理门户(在部署并使用 guest:guest 凭据之后)可以创建新用户。但我想将其自动化作为 Kubernetes Statefulset 部署的一部分。
我尝试添加 Kubernetes 的生命周期后挂钩,但效果不佳。我有以下物品:
rabbitmq-configmap:
rabbitmq.conf: |
## Clustering
#cluster_formation.peer_discovery_backend = k8s
cluster_formation.peer_discovery_backend = rabbit_peer_discovery_k8s
cluster_formation.k8s.host = kubernetes.default.svc.cluster.local
cluster_formation.k8s.address_type = hostname
cluster_partition_handling = autoheal
#cluster_formation.k8s.hostname_suffix = rabbitmq.${NAMESPACE}.svc.cluster.local
#cluster_formation.node_cleanup.interval = 10
#cluster_formation.node_cleanup.only_log_warning = true
rabbitmq-serviceaccount:
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: rabbitmq
rules:
- apiGroups: [""]
resources: ["endpoints"]
verbs:
- get
- list
- watch
rabbitmq-statefulset:
initContainers:
- name: "rabbitmq-config"
image: busybox
volumeMounts:
- name: rabbitmq-config
mountPath: /tmp/rabbitmq
- name: rabbitmq-config-rw
mountPath: /etc/rabbitmq
command:
- sh
- -c
# the newline is needed since the Docker image entrypoint scripts appends to the config file
- cp /tmp/rabbitmq/rabbitmq.conf /etc/rabbitmq/rabbitmq.conf && echo '' >> /etc/rabbitmq/rabbitmq.conf;
cp /tmp/rabbitmq/enabled_plugins /etc/rabbitmq/enabled_plugins;
containers:
- name: rabbitmq
image: rabbitmq
ports:
- containerPort: 15672
有什么帮助吗?
【问题讨论】:
标签: rabbitmq kubernetes-statefulset