Gitops w/ FluxCD: Automation of Status Notification to GitHub.
FluxCD can connect to GitHub and send status updates to it. Setting up this integration is a great way to be alerted about the state of a release activity.
🍏
This article is part of the GitOps & FluxCD: Automate Kubernetes Infrastructure Management Series.
In a previous article, FluxCD's Notification Controller was introduced and integrated into Slack.
The image below shows the different types of channels that are fair game for receiving messages from FluxCD.
![](https://hestia.ghost.io/content/images/2024/02/image-478.png)
We continue investigating Notification Controllers by targetting a GitHub repo for alerts.
What does a GitHub Status Notification Flow Look Like?
![](https://hestia.ghost.io/content/images/2024/03/image.png)
- Source Controllers will periodically look for changes in a source
- If changes are found, entries are made into the K8s Events log
- Kustomization Controllers will periodically check the logs and in case changes have been made (and logged in K8s Events), they will generate new deployment manifests and update a cluster's infrastructure
- Notification Controllers will also pick up logs from K8s Events and pass them onto whichever channel's been configured to receive messages from FluxCD
Demo: Configure FluxCD to Send Reconciliation Status to GitHub Repo.
Step 1: Save a Git Personal Access Token (PAT) as a K8s Secret
kubectl create secret -n flux-system generic github-token
--from-literal=token=<Git PAT>
Step 2: Generate an Alert Provider and an Alert
💡
Recall we had to make an Alert-Provider and an Alert for Slack notifications.
Alert Provider
# Assumption: Active folder is root of flux-infra/clusters/staging
flux create alert-provider github-instavote \
--type=github \
--address=https://github.com/usmanlakhani/instavote \
--secret-ref=github-token
![](https://hestia.ghost.io/content/images/2024/03/image-1.png)
Alert
# Assumption: Active folder is root of flux-infra/clusters/staging
flux create alert vote-staging \
--provider-ref=github-instavote \
--event-severity info \
--event-source Kustomization/vote-staging
![](https://hestia.ghost.io/content/images/2024/03/image-2.png)
💡
Alerts are created for a specific Kustomization and if you have multiple applications (in multiple GitHub repos/folders), an Alert will have to be made for each one.
Step 3: Check in the newly added files to GitHub
Assumption: You are root of flux-infra/clusters/staging
git add *
git commit -m "comment"
git push origin main
Step 4: After a period of waiting go to the commits section in the GitHub Repo (instavote)
![](https://hestia.ghost.io/content/images/2024/03/image-3.png)
Architecturally Speaking
![](https://hestia.ghost.io/content/images/2024/03/image-4.png)
Summary: What and Why?
![](https://hestia.ghost.io/content/images/2024/03/image-5.png)
GitHub Folder Structure So Far
![](https://hestia.ghost.io/content/images/2024/03/image-6.png)
I write to remember, and if, in the process, I can help someone learn about Containers, Orchestration (Docker Compose, Kubernetes), GitOps, DevSecOps, VR/AR, Architecture, and Data Management, that is just icing on the cake.