1 k8s 配置文件yaml:
apiVersion: apps/v1
kind: Deployment
metadata:name: rabbitmq-deploynamespace: rz-dt
spec:replicas: 1selector:matchLabels:app: rabbitmqtemplate:metadata:labels:app: rabbitmqspec:containers:- name: rabbitmqimage: "rz-dt-image-server-registry-vpc.cn-shanghai.cr.aliyuncs.com/rz-dt-real/rabbitmq:3.6.15-management"imagePullPolicy: IfNotPresent #pull镜像时机,ports:- name: amqpcontainerPort: 5672- name: http-apicontainerPort: 15672imagePullSecrets:- name: rz-dt-miyue
---
apiVersion: v1
kind: Service
metadata:name: rabbitmq-servicenamespace: rz-dt
spec:ports:- name: amqpnodePort: 30671port: 5672protocol: TCPtargetPort: 5672- name: http-apinodePort: 30672port: 15672protocol: TCPtargetPort: 15672selector:app: rabbitmqsessionAffinity: Nonetype: NodePort
2 Dockerfile
(也可以手动拉取,上传镜像仓库,如下 )
docker pull rabbitmq:3.6.15-managementdocker tag rabbitmq:3.6.15-management rz-dt-image-server-registry-vpc.cn-shanghai.cr.aliyuncs.com/rz-dt-real/rabbitmq:3.6.15-managementdocker push rz-dt-image-server-registry-vpc.cn-shanghai.cr.aliyuncs.com/rz-dt-real/rabbitmq:3.6.15-management
FROM rabbitmq:3.6.15-management
3 k8s 执行命令:
kubectl --kubeconfig ~/.kube-rz-real/config apply -f rabbitmq-service.yaml
访问地址 http://ip:30672 ,账号guest/guest