Kubernetes RocketMQ NameService

单例部署

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
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: nameservice-deployment
labels:
app: nameservice
spec:
replicas: 1
selector:
matchLabels:
app: nameservice
template:
metadata:
labels:
app: nameservice
spec:
containers:
- image:
name: nameservice
ports:
- containerPort: 9876
volumeMounts:
- name: nameservice-logs-ps
mountPath: /opt/logs
- name: nameservice-store-ps
mountPath: /opt/store
volumes:
- name: nameservice-logs-ps
persistentVolumeClaim:
claimName: nameservice-logs-pv-claim
- name: nameservice-store-ps
persistentVolumeClaim:
claimName: nameservice-store-pv-claim

集群部署

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
apiVersion: apps/v1beta1
kind: StatefulSet
metadata:
name: rocketmq-nameservice
spec:
serviceName: "rocketmq-nameservice"
replicas: 2
template:
metadata:
labels:
app: rocketmq-nameservice
spec:
containers:
- image:
name: nameservice
ports:
- containerPort: 9876
volumeMounts:
- name: nameservice-logs-ps
mountPath: /opt/logs
- name: nameservice-store-ps
mountPath: /opt/store
volumeClaimTemplates:
- metadata:
name: nameservice-logs-ps
spec:
accessModes: [ "ReadWriteOnce" ]
storageClassName: "pd-standard"
resources:
requests:
storage: 5Gi
- metadata:
name: nameservice-store-ps
spec:
accessModes: [ "ReadWriteOnce" ]
storageClassName: "pd-standard"
resources:
requests:
storage: 15Gi
1
2
3
4
5
6
7
8
kind: StorageClass
apiVersion: storage.k8s.io/v1beta1
metadata:
name: pd-standard
provisioner: kubernetes.io/gce-pd
reclaimPolicy: Retain
parameters:
type: pd-standard

查看pv和pvc

1
kubectl get pv / pvc
1
2
3
4
5
NAME                                          STATUS    VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS         AGE
nameservice-logs-ps-rocketmq-nameservice-0 Bound pvc-584801f4-4208-11e8-90f0-42010a940054 5Gi RWO pd-standard 5m
nameservice-logs-ps-rocketmq-nameservice-1 Bound pvc-6827321f-4208-11e8-90f0-42010a940054 5Gi RWO pd-standard 5m
nameservice-store-ps-rocketmq-nameservice-0 Bound pvc-584866f2-4208-11e8-90f0-42010a940054 15Gi RWO pd-standard 5m
nameservice-store-ps-rocketmq-nameservice-1 Bound pvc-68279d36-4208-11e8-90f0-42010a940054 15Gi RWO pd-standard 5m

因为这里使用StorageClass方式,则动态创建PV并绑定PVC