安装方式
kubectl apply -f rabbitmq.yaml -n yunda-dev-cache
rabbitmq.yaml
##创建PV
# 注意更换存储方式
---
apiVersion: v1
kind: PersistentVolume
metadata:
name: rabbitmq-project-pv
labels:
pv: rabbitmq-project-pv
spec:
capacity:
storage: 10Gi
accessModes:
- ReadWriteMany
persistentVolumeReclaimPolicy: Retain
nfs:
path: /data/k8s
server: 192.168.8.158
##创建pvc
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: rabbitmq-project-pvc
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 10Gi
selector:
matchLabels:
pv: rabbitmq-project-pv
## 部署rabbitmq
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: rabbitmq-project
labels:
name: rabbitmq-project
spec:
replicas: 1
selector:
matchLabels:
name: rabbitmq-project
template:
metadata:
labels:
name: rabbitmq-project
spec:
containers:
- name: rabbitmq-project
image: rabbitmq:3.7.8-management
volumeMounts:
- mountPath: /var/lib/rabbitmq
name: rabbitmq-project
ports:
- containerPort: 4369
- containerPort: 5671
- containerPort: 5672
- containerPort: 15672
- containerPort: 25672
env:
- name: RABBITMQ_DEFAULT_USER
value: atlas
- name: RABBITMQ_DEFAULT_PASS
value: rabbitmq-atlas
volumes:
- name: rabbitmq-project
persistentVolumeClaim:
claimName: rabbitmq-project-pvc
##创建Service
---
apiVersion: v1
kind: Service
metadata:
name: rabbitmq-project
labels:
name: rabbitmq-project
spec:
type: NodePort
ports:
- port: 5672
protocol: TCP
targetPort: 5672
name: rabbitmq-project-5672
nodePort: 30010
- port: 15672
protocol: TCP
targetPort: 15672
name: rabbitmq-project-15672
nodePort: 30009
selector:
name: rabbitmq-project