rabbitmq / cluster-operator

RabbitMQ Cluster Kubernetes Operator
https://www.rabbitmq.com/kubernetes/operator/operator-overview.html
Mozilla Public License 2.0
864 stars 269 forks source link

Issue with Adding Sidecar Container to RabbitMQ Cluster Pods #1666

Closed evgmoskalenko closed 3 months ago

evgmoskalenko commented 3 months ago

Describe the bug

Hello,

The sidecar container specified in the RabbitMQCluster manifest does not get attached to the RabbitMQ cluster pods. I followed the example provided in the official RabbitMQ Cluster Operator repository.

To Reproduce

Steps to reproduce the behavior:

  1. Apply the RabbitMQCluster manifest with the sidecar container configuration:
    apiVersion: rabbitmq.com/v1beta1
    kind: RabbitmqCluster
    metadata:
    name: qwerty-rabbitmq-cluster
    spec:
    replicas: 3
    override:
    statefulSet:
      spec:
        template:
          spec:
            containers:
              - name: rabbitmq
                securityContext:
                  runAsUser: 1001
                  runAsNonRoot: true
                  readOnlyRootFilesystem: false
                  allowPrivilegeEscalation: false
                  capabilities:
                    drop: [ "ALL" ]
                  seccompProfile:
                    type: "RuntimeDefault"
                env:
                  - name: RABBITMQ_USE_LONGNAME
                    value: "true"
                  - name: BITNAMI_DEBUG
                    value: "true"
                  - name: RABBITMQ_NODENAME
                    value: "rabbit@$(MY_POD_NAME).qwerty-rabbitmq-cluster-nodes.$(MY_POD_NAMESPACE)"
                  - name: K8S_SERVICE_NAME
                    value: "qwerty-rabbitmq-cluster-nodes"
                volumeMounts:
                  - mountPath: /etc/rabbitmq/certs
                    name: qwerty-rabbitmq-cluster-nodes-tls-secret
                  - mountPath: /etc/rabbitmq/inter-node-tls.config
                    name: inter-node-config
                    subPath: inter_node_tls.config
              - name: additional-container
                image: my-image-heare
                imagePullPolicy: IfNotPresent
                securityContext:
                  runAsUser: 1001
                  runAsNonRoot: true
                  readOnlyRootFilesystem: false
                  allowPrivilegeEscalation: false
                  capabilities:
                    drop: [ "ALL" ]
                  seccompProfile:
                    type: "RuntimeDefault"
                env:
                  - name: LOG_LEVEL
                    value: "info"
                  - name: LOG_FORMAT
                    value: "json"
                volumeMounts:
                  - mountPath: /etc/rabbitmq/certs
                    name: qwerty-rabbitmq-cluster-nodes-tls-secret
                  - mountPath: /etc/rabbitmq/inter-node-tls.config
                    name: inter-node-config
                    subPath: inter_node_tls.config
            initContainers:
              - name: setup-container
                securityContext:
                  runAsUser: 1001
                  runAsNonRoot: true
                  readOnlyRootFilesystem: false
                  allowPrivilegeEscalation: false
                  capabilities:
                    drop: [ "ALL" ]
                  seccompProfile:
                    type: "RuntimeDefault"
            volumes:
              - configMap:
                  defaultMode: 420
                  name: qwerty-rabbitmq-cluster-tls-config
                name: inter-node-config
              - name: qwerty-rabbitmq-cluster-nodes-tls-secret
                secret:
                  secretName: qwerty-rabbitmq-cluster-nodes-tls-secret
                  items:
                    - key: ca.crt
                      mode: 416
                      path: ca_certificate.pem
                    - key: tls.crt
                      mode: 416
                      path: server_certificate.pem
                    - key: tls.key
                      mode: 416
                      path: server_key.pem
  2. Observe the pods created by the RabbitMQCluster.

Include any YAML or manifest necessary to reproduce the problem.

Expected behavior

The sidecar container (additional-container) should be attached to the RabbitMQ cluster pods and start successfully.

Version and environment information

evgmoskalenko commented 3 months ago

I found an issue with my gatekeeper policies; everything works as expected. Thanks :-)