k8s 安裝 rabbitMQ 單機版


rabbitMQ docker鏡像使用rabbitmq:3.8-management

service.yaml文件

apiVersion: v1
kind: Service
metadata:
  name: rabbitmq-web 
spec:
  ports:
  - port: 15672
    nodePort: 31900
  selector:
    app: rabbitmq
  type: NodePort

---
apiVersion: v1
kind: Service
metadata:
  name: rabbitmq-app
spec:
  ports:
  - port: 5672
  selector:
    app: rabbitmq

storageclass.yaml文件, pvc.yaml, pv.yaml我就不在這寫了,因為大家的可能使用不同的存儲

略過
persistentvolumeclaim 名字 用了efs-rabbitmq-pvc

deployment.yaml文件

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: rabbitmq
  labels:
    app: rabbitmq
spec:
  replicas: 1
  selector:
    matchLabels:
      app: rabbitmq
  template:
    metadata:
      labels:
        app: rabbitmq
    spec:
      hostname: my-rabbit
      containers:
      - name: rabbitmq
        image: rabbitmq:3.8-management
        ports:
        - name: rabbitmq-web
          containerPort: 15672 
        - name: rabbitmq-app
          containerPort: 5672
        volumeMounts:
        - name: persisitent-storage-rabbitmq
          mountPath: /var/lib/rabbitmq 
        env:
        - name: RABBITMQ_DEFAULT_VHOST
          value: my_vhost
        - name: RABBITMQ_DEFAULT_USER
          value: admin
        - name: RABBITMQ_DEFAULT_PASS
          value: yourpassword
      volumes:
      - name: persisitent-storage-rabbitmq
        persistentVolumeClaim:
          claimName: efs-rabbitmq-pvc

kubectl apply一下就好了


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM