1 k8s 配置文件yaml:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: rabbitmq-deploy
  namespace: rz-dt
spec:
  replicas: 1
  selector:
    matchLabels:
      app: rabbitmq
  template:
    metadata:
      labels:
        app: rabbitmq
    spec:
      containers:
      - name: rabbitmq
        image: "rz-dt-image-server-registry-vpc.cn-shanghai.cr.aliyuncs.com/rz-dt-real/rabbitmq:3.6.15-management"
        imagePullPolicy: IfNotPresent #pull镜像时机,
        ports:
        - name: amqp
          containerPort: 5672
        - name: http-api
          containerPort: 15672
      imagePullSecrets:
        - name: rz-dt-miyue     
---
apiVersion: v1
kind: Service
metadata:
  name: rabbitmq-service
  namespace: rz-dt
spec:
  ports:
    - name: amqp
      nodePort: 30671
      port: 5672
      protocol: TCP
      targetPort: 5672
    - name: http-api
      nodePort: 30672
      port: 15672
      protocol: TCP
      targetPort: 15672
  selector:
    app: rabbitmq
  sessionAffinity: None
  type: NodePort

2 Dockerfile

(也可以手动拉取,上传镜像仓库,如下 )

docker pull  rabbitmq:3.6.15-management

docker tag rabbitmq:3.6.15-management rz-dt-image-server-registry-vpc.cn-shanghai.cr.aliyuncs.com/rz-dt-real/rabbitmq:3.6.15-management


docker 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

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐