Open tongpaopao opened 6 years ago
apiVersion: apps/v1beta2 # for versions before 1.8.0 use apps/v1beta1 kind: StatefulSet metadata: name: emq namespace: kube-system spec: selector: matchLabels: app: emq serviceName: emq replicas: 3 template: metadata: labels: app: emq spec: affinity: nodeAffinity: requiredDuringSchedulingIgnoredDuringExecution: nodeSelectorTerms:
metadata: name: emq-data annotations: volume.beta.kubernetes.io/storage-class: "emq" spec: accessModes: [ "ReadWriteOnce" ] resources: requests: storage: 5Gi
sorry.i don't konw where i make a mistake. i have 2 node 1 master evenyone ./bin/emqttd_ctl cluster status get [{running_nodes,['emq-0@emq-0.emq']}]
You can deploy emqx cluster on k8s by referring to the following example.
$ cat emqx.yml
apiVersion: v1
kind: Service
metadata:
name: emqx
spec:
ports:
- port: 32333
nodePort: 32333
targetPort: emqx-dashboard
protocol: TCP
selector:
app: emqx
type: NodePort
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: emqx
labels:
app: emqx
spec:
replicas: 2
template:
metadata:
labels:
app: emqx
spec:
containers:
- name: emqx
image: emqx/emqx:latest
ports:
- name: emqx-dashboard
containerPort: 18083
- name: emqx-http
containerPort: 8083
- name: emqx-mqtt
containerPort: 1883
env:
- name: EMQX_CLUSTER__DISCOVERY
value: k8s
- name: EMQX_NAME
value: emqx
- name: EMQX_CLUSTER__K8S__APISERVER
value: http://172.31.19.161:8080
- name: EMQX_CLUSTER__K8S__NAMESPACE
value: default
- name: EMQX_CLUSTER__K8S__SERVICE_NAME
value: emqx
- name: EMQX_CLUSTER__K8S__ADDRESS_TYPE
value: ip
- name: EMQX_CLUSTER__K8S__APP_NAME
value: emqx
tty: true
$ kubectl apply -f emqx.yml
Can you give an example。