前置条件
配置域名(可选)
address=/app-rabbitmq1.basic.tanqidi.com/172.31.0.100
address=/rabbitmq.dev.tanqidi.com/172.31.0.100
1. docker 部署
docker run -d --name rabbitmq \
-p 5672:5672 \
-p 15672:15672 \
-e RABBITMQ_DEFAULT_USER=admin \
-e RABBITMQ_DEFAULT_PASS=123456 \
rabbitmq:4.0.3-management
2. kubernetes 部署
2.1 deployment
kind: Deployment
apiVersion: apps/v1
metadata:
name: rabbitmq
namespace: basic
labels:
app: rabbitmq
annotations:
deployment.kubernetes.io/revision: '1'
kubesphere.io/creator: admin
spec:
replicas: 1
selector:
matchLabels:
app: rabbitmq
template:
metadata:
creationTimestamp: null
labels:
app: rabbitmq
annotations:
kubesphere.io/creator: admin
kubesphere.io/imagepullsecrets: '{}'
spec:
volumes:
- name: host-time
hostPath:
path: /etc/localtime
type: ''
containers:
- name: rabbitmq
image: 'rabbitmq:4.0.3-management'
ports:
- name: http-5672
containerPort: 5672
protocol: TCP
- name: http-15672
containerPort: 15672
protocol: TCP
env:
- name: RABBITMQ_DEFAULT_USER
value: admin
- name: RABBITMQ_DEFAULT_PASS
value: '123456'
resources: {}
volumeMounts:
- name: host-time
readOnly: true
mountPath: /etc/localtime
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
imagePullPolicy: IfNotPresent
restartPolicy: Always
terminationGracePeriodSeconds: 30
dnsPolicy: ClusterFirst
serviceAccountName: default
serviceAccount: default
securityContext: {}
schedulerName: default-scheduler
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 25%
maxSurge: 25%
revisionHistoryLimit: 10
progressDeadlineSeconds: 600
2.2 service
使用NodePort来试验访问
kind: Service
apiVersion: v1
metadata:
name: rabbitmq
namespace: basic
labels:
app: rabbitmq
annotations:
kubesphere.io/creator: admin
spec:
ports:
- name: http-5672
protocol: TCP
port: 5672
targetPort: 5672
nodePort: 32063
- name: http-15672
protocol: TCP
port: 15672
targetPort: 15672
nodePort: 31858
selector:
app: rabbitmq
type: NodePort
sessionAffinity: None
externalTrafficPolicy: Cluster
ipFamilies:
- IPv4
ipFamilyPolicy: SingleStack
internalTrafficPolicy: Cluster
2.2 coredns
rewrite name app-rabbitmq1.basic.tanqidi.com rabbitmq.basic.svc.cluster.local
3. 操作总结
目前还是最简单的部署,仅限快速测试使用