部署 k8s 的 RabbitMq 集群
前置:
k8s
准备就绪,PVC
准备就绪
创建命名空间
kubectl create namespace <you-namespace>
添加 helm 的依赖库
helm repo add bitnami https://charts.bitnami.com/bitnami
# 拉取
helm pull bitnami/rabbitmq
# 解压
tar -xvf {你拉下来的压缩包}
# 创建一份 values 的备份,我们需要改动一些
cp values.yaml values-test.yaml
修改 values.yaml
调整 storageClass
global:
imageRegistry: ""
## E.g.
## imagePullSecrets:
## - myRegistryKeySecretName
##
imagePullSecrets: []
storageClass: "<you-storageClass>"
登录账号名密码
auth:
## @param auth.username RabbitMQ application username
## ref: https://github.com/bitnami/containers/tree/main/bitnami/rabbitmq#environment-variables
##
username: <you-username>
## @param auth.password RabbitMQ application password
## ref: https://github.com/bitnami/containers/tree/main/bitnami/rabbitmq#environment-variables
##
password: "<you-password>"
(可选)如果要对外提供服务
service:
## @param service.type Kubernetes Service type
##
# 将这里的 ClusterIP 改为 NodePort
type: NodePort
nodePorts:
# 将这里的端口改为你想要对外暴露的端口,一般来说 NodePort 默认范围为 30000-32767 挑一个喜欢的
amqp: "<you-port>"
amqpTls: ""
dist: ""
manager: ""
epmd: ""
metrics: ""
执行
helm -n <you-namespace> install rabbitmq-cluster bitnami/rabbitmq -f values-test.yaml
对外暴露控制面板
路径模式
创建一个 yaml 文件
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: rabbitmq
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /$1
nginx.ingress.kubernetes.io/ssl-redirect: "false"
spec:
rules:
- host: <you-ingress-host>
http:
paths:
- backend:
service:
name: rabbitmq-cluster
port:
number: 15672
path: /rabbitmq/?(.*)
pathType: Prefix
# 执行这个文件
kubectl apply -f <you-ingress-config>.yaml -n <you-namespace>
访问 https://<you-ingress-host>/rabbitmq
即可
域名模式
原来的 values-test.yaml
ingress:
## @param ingress.enabled Enable ingress resource for Management console
##
enabled: true
## @param ingress.path Path for the default host. You may need to set this to '/*' in order to use this with ALB ingress controllers.
##
path: /
## @param ingress.pathType Ingress path type
##
pathType: ImplementationSpecific
## @param ingress.hostname Default host for the ingress resource
##
hostname: <you-rabbitmq-host>
访问 https://<you-rabbitmq-host>
即可