Support Online
Skip to main content

How to Setup Kubernetes Continuous Delivery with Flux (GitOps Guide)

Kubernetes alone does not offer CI/CD.
In this guide, you will make Kubernetes deployments automated and trackable with the GitOps approach.

Using Flux you will make the Git repository the single source of truth and automatically apply all changes to the cluster.

What Will You Learn in This Guide?

  • How the GitOps approach works in Kubernetes
  • Flux installation and integration with GitHub
  • Automatic deployment of applications
  • Receive instant delivery notifications via Slack
  • (Optional) Helm chart automation

Prerequisites

Before you start, you should have the following ready:

  • Kubernetes Cluster: Kubectl configured (ex: GenixNode Kubernetes)
  • GitHub Account: Personal Access Token created
  • Slack Workspace: Webhook creation authority
  • Local Environment: Git and kubectl installed

1. Flux Installation and Bootstrap Process

Flux is a GitOps-based Continuous Delivery tool.
It is first installed on your local machine, then connected to the cluster.

Flux Setup

curl https://fluxcd.io/install.sh -so flux-install.sh
chmod +x flux-install.sh
./flux-install.sh
  • This command installs the Flux CLI tool on the system.

Add autocomplete:


echo ". <(flux completion bash)" >> ~/.bashrc
source ~/.bashrc

  • Run preflights:

flux check --pre
  • This command checks Kubernetes version compatibility.

2. Installing Flux on Your Cluster with GitHub (Bootstrap)

  • Flux keeps its configuration in the Git repository.
  • This repository is also the sole source of distribution.

Define your GitHub information as a variable:


export GITHUB_USER=kullanici_adiniz
export GITHUB_TOKEN=github_tokeniniz

Start the Bootstrap process:


flux bootstrap github \
--owner=$GITHUB_USER \
--repository=flux-config \
--branch=main \
--path=./clusters/my-cluster \
--personal

  • This process:
  1. Creates a private repo on GitHub

  2. Installs Flux components into the cluster

  3. Synchronizes Kubernetes with Git


3. Automating Application Deployment

  1. Flux needs two things to monitor an application:
  • GitRepository: Where the source is located

  • Kustomization: What to deploy


Cloning the Flux Configuration Repository


git clone https://github.com/$GITHUB_USER/flux-config ~/flux-config
cd ~/flux-config

Source Repo Definition

flux create source git podinfo \
--url=https://github.com/$GITHUB_USER/podinfo \
--branch=master \
--interval=30s \
--export > ./clusters/my-cluster/podinfo-source.yaml
  • This file tells Flux which Git repo to monitor.

Creating Kustomization

flux create kustomization podinfo \
--source=podinfo \
--path="./kustomize" \
--prune=true \
--interval=5m \
--export > ./clusters/my-cluster/podinfo-kustomization.yaml

  • This structure:
  1. Automatically implements Kubernetes manifests

  2. Reverts manual changes

  3. Prevents non-Git interventions

  4. Send files:



git add . && git commit -m "podinfo eklendi"
git push

4. Set Up Slack Notifications

-Flux can send deployment events to Slack.

Creating a Slack Webhook Secret


kubectl -n flux-system create secret generic slack-url \
--from-literal=address=SLACK_WEBHOOK_URL
  • This command securely stores the Slack webhook address.

Alert Provider Definition


flux create alert-provider slack \
--type slack \
--channel general \
--secret-ref slack-url \
--export > ./clusters/my-cluster/slack-alert-provider.yaml

Creating an Alert Definition


flux create alert slack-alert \
--event-severity info \
--event-source Kustomization/* \
--provider-ref slack \
--export > ./clusters/my-cluster/slack-alert.yaml

Submit changes:


git add . && git commit -m "Slack bildirimleri eklendi"
git push
  • Now every deployment falls on Slack 🔔

5. (Optional) Helm Chart Automation

  1. Flux can also monitor Helm charts.

Helm Repo Definition


flux create source helm podinfo \
--url=https://stefanprodan.github.io/podinfo \
--interval=10m \
--export > ./clusters/my-cluster/podinfo-helm-repo.yaml

Creating HelmRelease


flux create hr podinfo \
--source=HelmRepository/podinfo \
--chart=podinfo \
--target-namespace=podinfo-helm \
--export > ./clusters/my-cluster/podinfo-helm-chart.yaml
Namespace oluşturun ve push edin:


kubectl create namespace podinfo-helm

git add . && git commit -m "Helm chart added" && git push


##Frequently Asked Questions (FAQ)

1. Why does Flux roll back manual changes? In GitOps logic, Git is the only source of truth.

2. Can I make immediate changes to the live? Yes, Kustomization can be done by suspending it.

3. Does Flux replace CI? No. Flux is the CD tool, CI requires Jenkins/GitHub Actions.

4. Can I use another tool instead of Slack? Yes. All systems that support Teams, Discord and webhook work.


Result

With Flux, you've made your Kubernetes deployments fully Git-based, traceable, and retrievable. Now every commit is automatically deployed and the entire process is recorded.

You can safely scale your projects by installing this GitOps architecture on GenixNode Kubernetes infrastructure 🚀