• 微信公众号:美女很有趣。 工作之余,放松一下,关注即送10G+美女照片!

k8s 部署单点 rabbitmq

开发技术 开发技术 4小时前 2次浏览

创建pvc

vim rabbitmq-pvc.yaml

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: rabbitmq-data
  namespace: dev
spec:
  storageClassName: k8s-nfs-class
  accessModes:
  - ReadWriteMany
  resources:
    requests:
      storage: 1Gi

创建deployment

vim rabbitmq-deploy.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: rabbitmq-dev
  namespace: dev
spec:
  selector:
    matchLabels:
      app: rabbitmq-dev
  template:
    metadata:
      labels:
        app: rabbitmq-dev
    spec:
      containers:
      - name: rabbitmq-dev
        image: rabbitmq:3.6.15-management
        ports:
        - containerPort: 5672
        volumeMounts:
        - name: rabbitmq-persistent-storage
          mountPath: /var/lib/rabbitmq
      volumes:
      - name: rabbitmq-persistent-storage
        persistentVolumeClaim:
          claimName: rabbitmq-data

创建svc

vim rabbitmq-svc.yaml

apiVersion: v1
kind: Service
metadata:
  annotations:
    prometheus.io/probe: "true"
  name: rabbitmq-dev
  namespace: dev
  labels:
    name: rabbitmq-dev
spec:
  selector:
    app: rabbitmq-dev
  type: NodePort
  ports:
  - name: mq
    nodePort: 30672
    port: 5672
    protocol: TCP
    targetPort: 5672
  - name: tmq
    nodePort: 35672
    port: 15672
    protocol: TCP
    targetPort: 15672

然后依次执行

kubectl apply -f rabbitmq-pvc.yaml

查看
kubectl get pvc -n dev | grep rabbitmq

kubectl apply -f rabbitmq-deploy.yaml

kubectl get deployment -n dev | grep rabbitmq
kubectl get pod -n dev | grep rabbitmq

kubectl apply -f rabbitmq-svc.yaml

kubectl get svc -n dev | grep rabbitmq

 


程序员灯塔
转载请注明原文链接:k8s 部署单点 rabbitmq
喜欢 (0)