k8s 部署单节点rabbitmq
10.65.0.111 为nfs server
mkdir -p /export/nfs_share/volume-mytest/mq-prod
chmod 777 -R /export/nfs_share/volume-mytest/mq-prod
cat > mq-prod-pvc-pv.yaml << EOF
apiVersion: v1
kind: PersistentVolume
metadata:
name: mq-prod
namespace: mytest
labels:
name: mq-prod
spec:
nfs:
path: /export/nfs_share/volume-mytest/mq-prod
server: 10.65.0.111
accessModes: ["ReadWriteMany","ReadOnlyMany"]
capacity:
storage: 5Gi
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: mq-prod
namespace: mytest
spec:
accessModes: ["ReadWriteMany"]
resources:
requests:
storage: 5Gi
EOF
cat > mq-prod-deployment.yaml << EOF
apiVersion: apps/v1beta1
kind: Deployment
metadata:
namespace: mytest
name: mq-prod
labels:
name: mq-prod
annotations:
blackbox_path: /
blackbox_port: "80"
blackbox_scheme: http
spec:
replicas: 1
template:
metadata:
labels:
name: mq-prod
spec:
containers:
- env:
- name: RABBITMQ_DEFAULT_VHOST
value: mymq_vhost
- name: RABBITMQ_DEFAULT_USER
value: guest
- name: RABBITMQ_DEFAULT_PASS
value: guest
name: mq-prod
image: ${mirror_store}/base/${base_version}
imagePullPolicy: IfNotPresent # Always、Never、IfNotPresent
ports:
- containerPort: 80
volumeMounts:
- name: storage
mountPath: /var/lib/rabbitmq
resources:
limits:
cpu: "1000m"
memory: 4096Mi
requests:
cpu: "1000m"
memory: 4096Mi
securityContext:
capabilities:
add:
- SYS_PTRACE
securityContext:
fsGroup: 999
runAsUser: 999
volumes:
- name: storage
persistentVolumeClaim:
claimName: mq-prod
EOF
cat > mq-prod-svc.yaml << EOF
kind: Service
apiVersion: v1
metadata:
annotations:
prometheus.io/probe: "true"
name: mq-prod
namespace: mytest
labels:
name: mq-prod
spec:
ports:
- name: mq
nodePort: 31629
port: 5672
protocol: TCP
targetPort: 5672
- name: tmq
nodePort: 31630
port: 15672
protocol: TCP
targetPort: 15672
selector:
name: mq-prod
type: NodePort
EOF
_kubectl='/opt/kubernetes/client/bin/kubectl --kubeconfig=/opt/kubernetes/config_prod'
${_kubectl} apply -f mq-prod-pvc-pv.yaml
${_kubectl} apply -f mq-prod-deployment.yaml
${_kubectl} apply -f mq-prod-svc.yaml