FluxCD is a continuous delivery tool that automates the deployment and lifecycle management of applications on Kubernetes. It uses GitOps principles to synchronize application code stored in Git repositories with Kubernetes clusters, ensuring consistency and reliability in the deployment process.
curl -s https://fluxcd.io/install.sh | sudo bash
export GITHUB_TOKEN=<gh-token>
flux bootstrap github \
--token-auth \
--owner=ex-offenders \
--repository=paas-config \
--branch=main \
--path=clusters/production \
--personal
With this, paas-config GH repository in ex-offenders organization will be initialized.
After this is done, you would be able to see the following files in the new repository
clusters
-- production
----flux-system
------gotk-components.yaml
------gotk-sync.yaml
------kustomization.yaml
Now we can start deploying resources into the Kubernetes cluster by pushing the changes to this github repository. Also please see the docs to learn how flux contributes to our automated release process.
It is helpful to receive notifications on the status of our GitOps pipelines. For this we make use of Flux Notification Controller to send notifications to our slack.
Directory Structure
clusters
--production
----flux-system
------slack-secret-enc.yaml
Content
apiVersion: v1
data:
token: <token>
kind: Secret
metadata:
name: slack-secret
namespace: flux-system
type: Opaque
Make sure to encrypt the secret using sealed-secrets
clusters
--production
----flux-system
------slack-secret-enc.yaml
------notification-provider-slack.yaml
Content
---
apiVersion: notification.toolkit.fluxcd.io/v1beta3
kind: Provider
metadata:
name: notification-provider-slack
namespace: flux-system
spec:
address: https://slack.com/api/chat.postMessage
channel: flux-notifications
secretRef:
name: slack-secret
type: slack
username: FluxCD
Directory structure
clusters
--production
----flux-system
------slack-secret-enc.yaml
------notification-provider-slack.yaml
------notification-alert-slack.yaml
Content
---
apiVersion: notification.toolkit.fluxcd.io/v1beta3
kind: Alert
metadata:
name: notification-alert-slack
namespace: flux-system
spec:
eventSeverity: info
eventSources:
- kind: Kustomization
name: '*'
- kind: GitRepository
name: '*'
- kind: HelmChart
name: '*'
- kind: HelmRepository
name: '*'
- kind: HelmRelease
name: '*'
- kind: ImageRepository
name: '*'
- kind: ImagePolicy
name: '*'
- kind: ImageUpdateAutomation
name: '*'
providerRef:
name: notification-provider-slack
That would be it. Now we should be able to see Flux notifications in #flux-notifications slack channel