Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing Reloader with Mosquitto #5

Open
dystewart opened this issue Jan 12, 2022 · 0 comments
Open

Testing Reloader with Mosquitto #5

dystewart opened this issue Jan 12, 2022 · 0 comments
Labels
documentation Improvements or additions to documentation

Comments

@dystewart
Copy link
Owner

The final thing we need to do is update our Mosquitto deployment with annotations that Reloader uses to redeploy pods when a specified configmap or secret changes.
Check out the Reloader docs for more info on how it works: Reloader

To track the configmap and secret resources of our Mosquitto pod we need to add the following annotations in the metadata section of the Mosquitto deployment.yaml:

deployment.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
    secret.reloader.stakater.com/reload: "mosquitto-secret-file"
    configmap.reloader.stakater.com/reload: "mosquitto-config-file"
  name: mosquitto
  labels:
    app: mosquitto
spec:
  replicas: 1
  selector:
    matchLabels:
      app: mosquitto
  template:
    metadata:
      labels:
        app: mosquitto
    spec:
      containers:
        - name: mosquitto
          image: quay.io/dystewar/mosquitto
          ports:
            - containerPort: 1883
          volumeMounts:
            - name: mosquitto-conf
              mountPath: /mosquitto/config
            - name: mosquitto-secret
              mountPath: /mosquitto/secret  
      volumes:
        - name: mosquitto-conf
          configMap:
            name: mosquitto-config-file
        - name: mosquitto-secret
          secret:
            secretName: mosquitto-secret-file

Once you update the deployment.yaml manifest click save and finally we can check if our Reloader pod is working. At the web UI take a look at the secrets tab while in your Mosquitto project and select the mosquitto-secret-file resource. Take a look at the yaml of the secret resource and change the username or password to something else. As always click save to apply the changes. Now take a look back at your Reloader pod logs and you should see something like this:
reloaderworks

The change was picked up by Reloader! if you look at the Mosquitto pod you'll see that it was just recreated to reflect the changes. This redeployment was triggered by Reloader!

You can also test that changes to the Mosquitto configmap by making a change to the configmap yaml like below:
false

Now looking back at the Reloader logs:
cm

Reloader detected our configmap changes too! And there you have it. We have successfully configured and deployed 2 applications in our OpenShift cluster! Most basic application deployments will be spun up in a similar way, and you can take what you've seen here to help with debugging your next deployment.

@dystewart dystewart added the documentation Improvements or additions to documentation label Jan 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

1 participant