Menu

Configuring Defaults for RabbitMQ Cluster Operator

Overview

This guide covers how to modify the default configuration of the RabbitMQ Cluster Kubernetes Operator in a Kubernetes cluster.

Environment variables used by the operator can be overridden in order to influence how the operator configures created RabbitmqClusters. This can be useful when configuring the operator to automatically use RabbitMQ container images stored in a private registry.

Configurable Parameters

The following configuration options are available to be set:

Env. variable Description Effect when unset
OPERATOR_SCOPE_NAMESPACE Namespace which the operator will reconcile and watch RabbitmqClusters (independent of installation namespace) All namespaces are watched and reconciled
DEFAULT_RABBITMQ_IMAGE RabbitMQ container image used for new RabbitmqCluster Pods where not explicitly set in RabbitmqCluster.Spec.Image Operator uses the latest RabbitMQ container image available at time of release for new Pods
DEFAULT_USER_UPDATER_IMAGE Vault sidecar container image used for new RabbitmqCluster Pods where not explicitly set in RabbitmqCluster.Spec.SecretBackend.Vault.DefaultUserUpdaterImage Operator uses the latest sidecar container image available at time of release for new Pods
DEFAULT_IMAGE_PULL_SECRETS Comma-separated list of imagePullSecrets to set by default on all RabbitmqCluster Pods where not explicitly set in RabbitmqCluster.Spec.ImagePullSecrets New RabbitmqCluster Pods have no imagePullSecrets by default

Configuration

In order to set these configuration parameters, you will need to edit the Deployment manifest of the operator. This is the YAML manifest artefact released with every new version of the RabbitMQ Cluster Operator on GitHub.

If you already have the operator deployed, you can edit the manifest of the operator directly:

kubectl -n rabbitmq-system edit deployment rabbitmq-cluster-operator

In the manifest, add the environment variables you wish to change. For example, to set the namespace scope of the operator:

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app.kubernetes.io/component: rabbitmq-operator
    app.kubernetes.io/name: rabbitmq-cluster-operator
    app.kubernetes.io/part-of: rabbitmq
  name: rabbitmq-cluster-operator
  namespace: rabbitmq-system
spec:
  template:
    spec:
      containers:
      - command:
        - /manager
        env:
        - name: OPERATOR_NAMESPACE
          valueFrom:
            fieldRef:
              fieldPath: metadata.namespace
        - name: OPERATOR_SCOPE_NAMESPACE
          value: custom-namespace
...

Upon saving, the operator Pod will be updated to use this configuration. Note that future GitHub release artefacts will not have these changes that you make, and so you must remember to add these changes every time you update the cluster operator.

You may consider using templating to add these variables in automatically; for example you can use a ytt overlay such as:

values.yaml

#@ load("@ytt:overlay", "overlay")
#@ deployment = overlay.subset({"kind": "Deployment"})
#@ cluster_operator = overlay.subset({"metadata": {"name": "rabbitmq-cluster-operator"}})
#@overlay/match by=overlay.and_op(deployment, cluster_operator),expects="1+"
---
spec:
  template:
    spec:
      containers:
      #@overlay/match by=overlay.subset({"name": "operator"}),expects="1+"
      -
        #@overlay/match missing_ok=True
        env:
        - name: OPERATOR_SCOPE_NAMESPACE
          value: custom-namespace

Use this overlay when upgrading the operator to ensure your custom configuration is applied for the new version:

ytt -f https://github.com/rabbitmq/cluster-operator/releases/latest/download/cluster-operator.yml -f values.yaml | kubectl apply -f -

Getting Help and Providing Feedback

If you have questions about the contents of this guide or any other topic related to RabbitMQ, don't hesitate to ask them on the RabbitMQ mailing list.

Help Us Improve the Docs <3

If you'd like to contribute an improvement to the site, its source is available on GitHub. Simply fork the repository and submit a pull request. Thank you!