Change EMQX Configurations
Task Target
Change EMQX configuration by bootstrapConfig in EMQX Custom Resource.
Configure EMQX Cluster
The main configuration file of EMQX is /etc/emqx.conf. Starting from version 5.0, EMQX adopts HOCON as the configuration file format.
apps.emqx.io/v2alpha1 EMQX supports configuring EMQX cluster through .spec.bootstrapConfig field. For bootstrapConfig configuration, please refer to the document: bootstrapConfig.
TIP
This is only applicable before EMQX is started. If you need to modify the cluster configuration after creating EMQX, please modify it through EMQX Dashboard.
Save the following content as a YAML file and deploy it with the
kubectl applycommandyamlapiVersion: apps.emqx.io/v2alpha1 kind: EMQX metadata: name: emqx spec: image: emqx:5.0 imagePullPolicy: IfNotPresent bootstrapConfig: | listeners.tcp.test { bind = "0.0.0.0:1884" max_connections = 1024000 } listenersServiceTemplate: spec: type: LoadBalancer dashboardServiceTemplate: spec: type: LoadBalancerIn the
.spec.bootstrapConfigfield, we have configured a TCP listener for the EMQX cluster. The name of this listener is: test, and the listening port is: 1884.Wait for the EMQX cluster to be ready, you can check the status of EMQX cluster through
kubectl getcommand, please make sureSTATUSisRunning, this may take some timebash$ kubectl get emqx emqx NAME IMAGE STATUS AGE emqx emqx:5.0 Running 10mObtain the Dashboard External IP of EMQX cluster and access EMQX console
EMQX Operator will create two EMQX Service resources, one is emqx-dashboard and the other is emqx-listeners, corresponding to EMQX console and EMQX listening port respectively.
bash$ kubectl get svc emqx-dashboard -o json | jq '.status.loadBalancer.ingress[0].ip' 192.168.1.200Access
http://192.168.1.200:18083through a browser, and use the default username and passwordadmin/publicto login EMQX console.
Verify Configuration
View EMQX cluster listener information
bash$ kubectl exec -it emqx-core-0 -c emqx -- emqx_ctl listenersYou can get a print similar to the following, which means that the listener named
testconfigured by us has taken effect.bashtcp:default listen_on: 0.0.0.0:1883 acceptors: 16 proxy_protocol : false running: true current_conn: 0 max_conns : 1024000 tcp:test listen_on: 0.0.0.0:1884 acceptors: 16 proxy_protocol : false running: true current_conn: 0 max_conns : 1024000