3 min read

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.

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.

This article focuses on GitHub Alerts.

We continue investigating Notification Controllers by targetting a GitHub repo for alerts.

What does a GitHub Status Notification Flow Look Like?

  • 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

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
💡
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)

FluxCD has shared the outcomes of the reconciliation to GitHub, something that, so far, we have been checking for using FluxCD CLI.

Architecturally Speaking


Summary: What and Why?

GitHub Folder Structure So Far


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.