This repo serves as an example for :
This operator creates a rabbitmq service, and puts the credentials in a secret. This secret will then be used in the deployment to allow our script to access the instances.
This example is split into 2 parts, sender and receiver, and works as follows:
- Get the user and secret from the environment
- Connect to rabbimq
- Ensure the queue exists
- Push or pop from the queue
This example takes strong inspiration from the official tutorial.
Skaffold allows us to easily develop an application that will run on kubernetes. As we will be running a sender and receiver, we will need to describe both.
For our example, 5 files are needed:
- skaffold.yaml
- k8s-deploy-{receiver,sender}.yaml
- docker/Dockerfile.{receiver,sender}
Skaffold configuration, describes the two images we will have to build, and the kubernetes maniifest to deploy them.
When run with
skaffold dev
skaffold will watch the files in the repo and redeploy when necessary. It is advised to run this in a separate terminal.
K8s deployment, will launch our image with the credentials stored in the secret generated by the rabbitmq-operator.
Dockerfile to run our script.
For development:
NAMESPACE="test-rabbitmq"
kubectl -n $NAMESPACE apply -f ./simple.yaml
skaffold -n $NAMESPACE dev
For deployment:
NAMESPACE="test-rabbitmq"
kubectl -n $NAMESPACE apply -f ./simple.yaml
skaffold -n $NAMESPACE run