2022-02-24:k8s安装rabbitmq,yaml如何写?
答案2022-02-24:
yaml如下:
代码语言:yaml复制apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: rabbitmq
name: rabbitmq
namespace: moonfdd
spec:
replicas: 1
selector:
matchLabels:
app: rabbitmq
template:
metadata:
labels:
app: rabbitmq
spec:
containers:
- env:
- name: RABBITMQ_DEFAULT_USER
value: admin
- name: RABBITMQ_DEFAULT_PASS
value: moonfdd
image: 'rabbitmq:management'
imagePullPolicy: IfNotPresent
name: rabbitmq
volumeMounts:
- mountPath: /var/lib/rabbitmq/
name: data
volumes:
- name: data
hostPath:
path: /root/k8s/moonfdd/rabbitmq/var/lib/rabbitmq/
type: DirectoryOrCreate
---
apiVersion: v1
kind: Service
metadata:
labels:
app: rabbitmq
name: rabbitmq
namespace: moonfdd
spec:
ports:
- name: 5672-5672
port: 5672
protocol: TCP
targetPort: 5672
- name: 15672-15672
port: 15672
protocol: TCP
targetPort: 15672
selector:
app: rabbitmq
type: NodePort
结果如下: