# Deploy EMQX on Google Kubernetes Engine

The EMQX Operator allows for the deployment of EMQX on Google Kubernetes Engine (GKE), which simplifies the process of deploying a managed Kubernetes cluster in GCP. With GKE, you can offload the operational overhead to GCP, enabling you to focus on your application deployment and management. By deploying EMQX on GKE, you can take advantage of the scalability and flexibility of Kubernetes, while benefiting from the simplicity and convenience of a managed service. With EMQX Operator and GKE, you can easily deploy and manage your MQTT broker on the cloud, allowing you to focus on your business goals and objectives.

# Before You Begin

Before you begin, you must have the following:

  • To create a GKE cluster on Google Cloud Platform, you will need to enable the GKE service in your GCP subscription. You can find more information on how to do this in the Google Kubernetes Engine documentation.

  • To connect to a GKE cluster using kubectl commands, you can install the kubectl tool on your local machine and obtain the cluster's KubeConfig to connect to the cluster. Alternatively, you can use Cloud Shell through the GCP Console to manage the cluster with kubectl.

    • To connect to a GKE cluster using kubectl, you will need to install and configure the kubectl tool on your local machine. Refer to the Connect to a GKE cluster (opens new window) documentation for detailed instructions on how to do this.

    • To connect to a GKE cluster using Cloud Shell, you can use the Cloud Shell directly from the GCP Console to connect to the GKE cluster and manage the cluster using kubectl. Refer to the Manage a GKE cluster with Cloud Shell (opens new window) documentation for detailed instructions on how to connect to Cloud Shell and use kubectl.

  • To install EMQX Operator, please refer to Install EMQX Operator

    WARING

    For installing cert-manager on Google Kubernetes Engine, see the official documentation:

    Remember to install CRDs when running helm with the --set installCRDs=true flag.

    More information can be found at cert-manager (opens new window).

# Quickly deploying an EMQX cluster

Here are the relevant configurations for EMQX Custom Resource. You can choose the corresponding APIVersion based on the version of EMQX you wish to deploy. For specific compatibility relationships, please refer to EMQX Operator Compatibility:

# Connecting to EMQX cluster to publish/subscribe messages using MQTT X CLI

MQTT X CLI (opens new window) is an open-source MQTT 5.0 command-line client tool designed to help developers develop and debug MQTT services and applications faster without the need for a GUI.

  • Retrieve External IP of the EMQX cluster
  • Subscribe to messages
$ mqttx sub -t 'hello' -h ${external_ip} -p 1883

[10:00:25] › …  Connecting...
[10:00:25] › ✔  Connected
[10:00:25] › …  Subscribing to hello...
[10:00:25] › ✔  Subscribed to hello
1
2
3
4
5
6
  • Create a new terminal window and send a message
$ mqttx pub -t 'hello' -h ${external_ip} -p 1883 -m 'hello world'

[10:00:58] › …  Connecting...
[10:00:58] › ✔  Connected
[10:00:58] › …  Message Publishing...
[10:00:58] › ✔  Message published
1
2
3
4
5
6
  • View messages received in the subscription terminal window
[10:00:58] › payload: hello world
1

# Use LoadBalancer for TLS offloading

Since Google LoadBalancer doesn't support TCP certificates, please check discussion (opens new window) to address TCP certificate offloading issues.