How to Deploy RabbitMQ on EKS using a Helmfile

RabbitMQ is an open-source message-queuing or messaging broker software. Applications connect to a RabbitMQ queue to transfer messages. Helmfile allows you to declare the definition of all Kubernetes clusters and Helm releases (Helm charts) in a single YAML file. It maintains a directory of chart value files and version control. It also allows you to specify an environment-based application release (develop, test, production).

Deploy RabbitMQ on AWS EKS using Helmfile

The Helm chart for RabbitMQ is available on Github. We modify the Helmchart for RabbitMQ and convert it to a Helmfile. Helmfile uses Go templates for templating helmfile.yaml. There are several built-in functions we can use in helmfile, and for this we are using requiredEnv and exec functions.

requiredEnv: This function allows you to declare an environment variable as required which can be used for template rendering. If the environment variable is unset or empty, the template rendering will fail with an error message. We use environment variables DOMAIN and ENVIRONMENT to use a generic file and deploy this helmfile to multiple environments.

exec: This template function is useful for importing values from any source. We import values from the SSM parameter store. For e.g.,

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
username:
username:
username: 

Note: On the Production environment please add a replica count as per your requirement for the autoscaling purpose. Add the below parameter in helmfile replicaCount: 2

Create the helmfile named rabbitmq.yaml

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# DOMAIN=rabbitmq.devops.app.com ENVIRONMENT=devops helmfile -f rabbitmq.yaml diff
repositories:
- name: bitnami
url: https: //charts.bitnami.com/bitnami
releases:
- name: rabbitmq
namespace:
chart: bitnami/rabbitmq
version: 8.25 . 0
values:
- auth:
username:
password:
erlangCookie:
plugins: "rabbitmq_management rabbitmq_peer_discovery_k8s"
extraPlugins: "rabbitmq_auth_backend_ldap"
persistence:
enabled: true
metrics:
enabled: true
prometheusRule:
enabled: true
service:
type: NodePort
ingress:
enabled: true
path: /*
hostname:
annotations:
kubernetes. io /ingress. class : alb
external-dns. alpha . kubernetes . io /hostname:
external-dns. alpha . kubernetes . io /ingress-hostname-source: annotation-only
alb. ingress . kubernetes . io /actions. response - 404 : |
{ "Type" : "fixed-response" , "FixedResponseConfig" : { "ContentType" : "text/plain" , "StatusCode" : "404" , "MessageBody" : " - 404 Page not found" }}
alb. ingress . kubernetes . io /ssl-redirect: '443'
alb. ingress . kubernetes . io /certificate-arn:
alb. ingress . kubernetes . io /listen-ports: '[{"HTTPS":443}]'
alb. ingress . kubernetes . io /load-balancer-attributes:
alb. ingress . kubernetes . io /scheme: internet-facing
alb. ingress . kubernetes . io /security-groups:
alb. ingress . kubernetes . io /subnets:
alb. ingress . kubernetes . io /group. name :
wait: true
timeout: 120
# DOMAIN=rabbitmq.devops.app.com ENVIRONMENT=devops helmfile -f rabbitmq.yaml diff repositories: - name: bitnami url: https://charts.bitnami.com/bitnami releases: - name: rabbitmq namespace: chart: bitnami/rabbitmq version: 8.25.0 values: - auth: username: password: erlangCookie: plugins: "rabbitmq_management rabbitmq_peer_discovery_k8s" extraPlugins: "rabbitmq_auth_backend_ldap" persistence: enabled: true metrics: enabled: true prometheusRule: enabled: true service: type: NodePort ingress: enabled: true path: /* hostname: annotations: kubernetes.io/ingress.class: alb external-dns.alpha.kubernetes.io/hostname: external-dns.alpha.kubernetes.io/ingress-hostname-source: annotation-only alb.ingress.kubernetes.io/actions.response-404: | {"Type":"fixed-response","FixedResponseConfig":{"ContentType":"text/plain","StatusCode":"404","MessageBody":" - 404 Page not found"}} alb.ingress.kubernetes.io/ssl-redirect: '443' alb.ingress.kubernetes.io/certificate-arn: alb.ingress.kubernetes.io/listen-ports: '[{"HTTPS":443}]' alb.ingress.kubernetes.io/load-balancer-attributes: alb.ingress.kubernetes.io/scheme: internet-facing alb.ingress.kubernetes.io/security-groups: alb.ingress.kubernetes.io/subnets: alb.ingress.kubernetes.io/group.name: wait: true timeout: 120
# DOMAIN=rabbitmq.devops.app.com ENVIRONMENT=devops helmfile -f rabbitmq.yaml diff

repositories:
- name: bitnami
  url: https://charts.bitnami.com/bitnami

releases:
- name: rabbitmq
  namespace: 
  chart: bitnami/rabbitmq
  version: 8.25.0
  values:
  - auth:
      username: 
      password: 
      erlangCookie: 
    plugins: "rabbitmq_management rabbitmq_peer_discovery_k8s"
    extraPlugins: "rabbitmq_auth_backend_ldap"
    persistence:
      enabled: true
    metrics:
      enabled: true
    prometheusRule:
      enabled: true
    service:
      type: NodePort
    ingress:
      enabled: true
      path: /*
      hostname: 
      annotations:
        kubernetes.io/ingress.class: alb
        external-dns.alpha.kubernetes.io/hostname: 
        external-dns.alpha.kubernetes.io/ingress-hostname-source: annotation-only
        alb.ingress.kubernetes.io/actions.response-404: |
          {"Type":"fixed-response","FixedResponseConfig":{"ContentType":"text/plain","StatusCode":"404","MessageBody":" - 404 Page not found"}}
        alb.ingress.kubernetes.io/ssl-redirect: '443'
        alb.ingress.kubernetes.io/certificate-arn: 
        alb.ingress.kubernetes.io/listen-ports: '[{"HTTPS":443}]'
        alb.ingress.kubernetes.io/load-balancer-attributes: 
        alb.ingress.kubernetes.io/scheme: internet-facing
        alb.ingress.kubernetes.io/security-groups: 
        alb.ingress.kubernetes.io/subnets: 
        alb.ingress.kubernetes.io/group.name: 
  wait: true
  timeout: 120

You can fetch username, password or any credentials from AWS Parameter store or AWS Secrets manager in the Helmfile.

We use SSM Parameter Store and a shell script to retrieve the credentials and insert them in our helmfile. Create a System Manager parameter store using AWS Console or AWS CLI

Create a file named ssm.sh

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
#!/usr/bin/env sh
set -ex
SSM_PARAMETER= "/"
aws ssm get-parameters \
--names "${SSM_PARAMETER}" \
--with-decryption \
--output text \
--query 'Parameters[0].Value' \
--region "us-west-2"
#!/usr/bin/env sh set -ex SSM_PARAMETER="/" aws ssm get-parameters \ --names "${SSM_PARAMETER}" \ --with-decryption \ --output text \ --query 'Parameters[0].Value' \ --region "us-west-2"
#!/usr/bin/env sh
set -ex

SSM_PARAMETER="/"

aws ssm get-parameters \
    --names "${SSM_PARAMETER}" \
    --with-decryption \
    --output text \
    --query 'Parameters[0].Value' \
    --region "us-west-2"

Give Executable permission to file

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
chmod +x ssm. sh
chmod +x ssm.sh
chmod +x ssm.sh

In the above mentioned helmfile we are using the AWS ALB ingress controller for the forwarding traffic from HTTP to HTTPS and distributing the load. We also use external-dns annotation for updating the DNS records.

Check the syntax using the diff command:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
helmfile -f rabbitmq. yaml diff
helmfile -f rabbitmq.yaml diff
helmfile -f rabbitmq.yaml diff

If we are satisfied with the diff, we run a sync or apply

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
helmfile -f rabbitmq. yaml apply
helmfile -f rabbitmq.yaml apply
helmfile -f rabbitmq.yaml apply

Once it is deployed check whether the pod is running or not

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
kubectl get pods -A
kubectl get pods -A
kubectl get pods -A

Once deployed successfully, external-DNS will update the DNS records and check using the DNS name if rabbitmq shows the dashboard page as shown below,

References

  1. “GitHub – Roboll/Helmfile: Deploy Kubernetes Helm Charts.” GitHub, June 5, 2022. https://github.com/roboll/helmfile.
  2. kubernetes-sigs. “GitHub – Kubernetes-Sigs/External-Dns: Configure External DNS Servers (AWS Route53, Google CloudDNS and Others) for Kubernetes Ingresses and Services.” GitHub – External DNS, October 26, 2022. https://github.com/kubernetes-sigs/external-dns.
  3. “Charts/Stable/Rabbitmq at Master · Helm/Charts.” GitHub – RabbitMQ. Accessed October 28, 2022. https://github.com/helm/charts/tree/master/stable/rabbitmq.

About the author

Suraj Kamble is a DevOps engineer at Excellarate. He has expertise in tools and technologies such as Docker, Kubernetes, terraform, Jenkins, CloudFormation, Gitlab and Bitbucket CICD, Sumologic, Datadog, Grafana and Prometheus. Suraj holds a bachelor’s degree in computer engineering from the Savitribai Phule Pune University.

Learn More about Encora

We are the software development company fiercely committed and uniquely equipped to enable companies to do what they can’t do now.

Learn More

Global Delivery

READ MORE

Careers

READ MORE

Industries

READ MORE

Related Insights

Enabling Transformation in Hospitality through Technology-Led Innovation

As the exclusive sponsor of the 2024 Hotel Visionary Awards, we support organizations leading ...

Read More

Key Insights from HLTH 2024: The Future of Patient-Centered Healthcare

Discover key insights from HLTH 2024 on digital health, AI in diagnostics, data interoperability, ...

Read More

Data-Driven Engineering: Transforming Operations and Products from Insight to Impact

Discover how data-driven engineering transforms operations and product development, enhancing team ...

Read More
Previous Previous
Next

Accelerate Your Path
to Market Leadership 

Encora logo

Santa Clara, CA

+1 669-236-2674

letstalk@encora.com

Innovation Acceleration

Speak With an Expert

Encora logo

Santa Clara, CA

+1 (480) 991 3635

letstalk@encora.com

Innovation Acceleration