Kubernetes Rocket-MQ Broker Master

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
apiVersion: apps/v1beta1
kind: StatefulSet
metadata:
name: mq-broker-master-deployment
spec:
selector:
matchLabels:
app: mq-broker-master
serviceName: mq-broker-master-service
replicas: 1
template:
metadata:
labels:
app: mq-broker-master
spec:
initContainers:
- name: init-broker-master
image: ubuntu:16.04
command:
- bash
- "-c"
- |
set -ex
cp /mnt/config-map/main.properties /mnt/conf/main.properties
volumeMounts:
- name: config-map
mountPath: /mnt/config-map
- name: conf
mountPath: /mnt/conf
############## Broker Container ###############
containers:
- name: mq-broker-master
image: gcr.io/fintend-cloud/mq-broker:4.2.15
ports:
- containerPort: 10911
- containerPort: 10909
volumeMounts:
- name: broker-pvc
mountPath: /opt/mq
- name: conf # relative to init container -> conf volumeMounts
mountPath: /root/rocketmq/fintend/
############# Volumes #############
volumes:
- name: config-map
configMap:
name: mq-broker-config
- name: conf
emptyDir: {}
nodeSelector:
node: broker
tolerations:
- key: "pod"
operator: "Equal"
value: "broker"
effect: "NoExecute"
volumeClaimTemplates:
- metadata:
name: broker-pvc
spec:
accessModes: [ "ReadWriteOnce" ]
storageClassName: "pd-standard"
resources:
requests:
storage: 200Gi

关键点,init containers如何把初始化好的配置文件传递给boot container

  1. 在volumes,声明一个空的临时目录conf

  2. init container 生成的配置文件存在conf目录里面

  3. boot container 映射conf作为配置文件的路径