Custom Resource Concept
Kubernetes is an open-source platform for automating the deployment, scaling, and management of containerized applications.
Operators are custom controllers that extend the capabilities of Kubernetes and implement custom functionality to manage applications and their components.
The HiveMQ Platform Operator for Kubernetes manages the HiveMQ platform on Kubernetes. A single HiveMQ Platform Operator can manage one or more HiveMQ platforms.
The HiveMQ Platform Custom Resource Definition (CRD) provides all the necessary definitions and configurations to deploy your HiveMQ platform to a Kubernetes system version 1.22 or higher.
Custom Resource Definition for the HiveMQ Platform
When you install the HiveMQ Platform Operator with the HiveMQ Platform Operator Helm chart, the custom resource definition (CRD) for the new HiveMQ Platform object is installed as well. The CRD is the central definition that enables Kubernetes to recognize your HiveMQ Platform as an object.
List the available CRDs on your Kubernetes cluster:
kubectl get customresourcedefinitions.apiextensions.k8s.io
kubectl get crds (using the abbreviation)
View the HiveMQ Platform CRD:
kubectl describe crd hivemq-platforms.hivemq.com
Once the HiveMQ Platform custom resource definition is deployed on your Kubernetes cluster, you can define and deploy as many HiveMQ Platform custom resources as your individual use case requires.
A custom resource is the concrete manifestation of the custom resource definition.
Your HiveMQ Platform custom resource defines what type of HiveMQ Platform cluster is deployed. The custom resource determines which HiveMQ container image is used, the number of nodes in your cluster, and what configurations are used.
The operator watches for the deployment of new custom resources and installs your HiveMQ platform cluster according to your custom resource specification. If you change an existing custom resource, the operator automatically reconciles your HiveMQ platform cluster with the changes.
To install your custom resource, you can use our preconfigured HiveMQ Platform Helm charts or deploy your own custom resource manually:
kubectl apply -f your-custom-resource.yaml
List the deployed HiveMQ Platform custom resources:
kubectl get hivemq-platforms.hivemq.com
kubectl get hmqp (using the abbreviation)
View your HiveMQ Platform custom resource:
kubectl get hmqp <your-hivemq-platform-name> -o yaml
Deploying the HiveMQ Platform custom resource gives you the ability to design your custom StatefulSet specification and your custom Service specification. This expert mode provides the highest level of flexibility for deploying your custom HiveMQ platform. Don’t forget to deploy any configMaps or secrets that your deployment needs in addition.
apiVersion: hivemq.com/v1
kind: HiveMQPlatform
metadata:
name: my-hivemq-platform
namespace: default
labels:
key: value
annotations:
key: value
spec:
configMapName: my-configmap-name
healthApiPort: 8889
logLevel: INFO
metricsPath: /
metricsPort: 9399
operatorRestApiPort: 7979
extensions:
id: hivemq-kafka-extension
enabled: true
extensionUri: preinstalled
supportsHotReload: yes
configMapName: my-kafka-configmap-name
statefulSet:
metadata: {}
spec:
replicas: 2
template:
spec:
containers:
- env:
- name: JAVA_OPTS
value: -XX:+UnlockExperimentalVMOptions -XX:InitialRAMPercentage=50 -XX:MaxRAMPercentage=50
name: hivemq
image: docker.io/hivemq/hivemq4:4.19.0
imagePullPolicy: IfNotPresent
ports:
- containerPort: 1883
name: mqtt-1883
- containerPort: 8080
name: cc-8080
- containerPort: 9399
name: metrics-9399
resources:
limits:
cpu: 4
memory: 4096M
requests:
cpu: 4
memory: 4096M
services:
- metadata:
name: hivemq-hmq-pl-mqtt-1883
spec:
ports:
- name: mqtt-1883
port: 1883
targetPort: mqtt-1883
- metadata:
name: hivemq-hmq-pl-cc-8080
spec:
ports:
- name: cc-8080
port: 8080
targetPort: cc-8080
- metadata:
name: hivemq-hmq-pl-metrics-9399
spec:
ports:
- name: metrics-9399
port: 9399
targetPort: metrics-9399
The HiveMQ Platform custom resource definition spec
contains several configuration sections :
Field | Description |
---|---|
|
Configures the name of the configMap that contains your HiveMQ platform configuration ( |
|
Defines the HealthAPI port for the HiveMQ platform nodes as an Int.
The operator accesses this port to query for the health of the nodes. |
|
Sets the log level for the HiveMQ platform. |
|
Defines the path where metrics can be scraped on each HiveMQ platform node.
The path is used for monitoring tools such as Prometheus. |
|
Defines the port where metrics can be reached on each HiveMQ platform node as an Int.
The port is used for monitoring tools such as Prometheus. |
|
Defines the port where the API and the metrics of the operator can be reached as an Int. |
|
The list of extensions with configuration settings for each extension.
|
|
Defines a list of service objects that are exposed for the HiveMQ Platform. Refer to the Kubernetes service configuration for valid options.
|
|
Defines the statefulSet object that is used to deploy the HiveMQ Platform. Refer to the Kubernetes statefulSet configuration for valid options.
|
Lifecycle Management
In addition to the configuration options, the custom resource of a deployed HiveMQ Platform also contains status information. The HiveMQ Platform Operator manages your custom resource and sets different statuses during operations. You can view the current and previous status of your HiveMQ Platform custom resource with this command.
View the status at the end of your HiveMQ Platform custom resource:
kubectl describe hmqp <name of your hivemq platform>
Status:
Message: HiveMQ Platform is ready
Observed Generation: 2
Recovery Information:
Message: HiveMQ Platform is starting
State: STARTING
State Phase: READY
Restart Extensions:
State: RUNNING
State Phase: READY