+
+
+
gradle
+
hugging
+
+
zig
+
keras
+
intellij
+
clickhouse
bundler
tcl
+
cargo
+
+
+
suse
+
+
nuxt
+
astro
next
+
+
//
+
+
+
+
+
java
%
+
+
==
+
couchdb
+
+
+
android
kotlin
elementary
vue
+
http
+
vercel
emacs
groovy
+
+
android
npm
+
ubuntu
mvn
โˆ‰
redis
numpy
vb
+
stimulus
+
+
nvim
+
+
+
vault
play
+
>=
micronaut
s3
+
+
+
qwik
+
vercel
+
travis
Back to Blog
๐Ÿ”„ Flux GitOps on AlmaLinux 9: Complete Guide
almalinux flux gitops

๐Ÿ”„ Flux GitOps on AlmaLinux 9: Complete Guide

Published Sep 6, 2025

Master GitOps with Flux CD on AlmaLinux 9! Learn automated deployments, Git synchronization, multi-environment management, and continuous delivery with practical examples.

5 min read
0 views
Table of Contents

๐Ÿ”„ Flux GitOps on AlmaLinux 9: Complete Guide

Ready to make Git your single source of truth? ๐ŸŽฏ Today weโ€™ll deploy Flux CD on AlmaLinux 9, creating a powerful GitOps system that automatically syncs your Kubernetes cluster with Git! Letโ€™s automate everything! ๐Ÿš€โœจ

๐Ÿค” Why is Flux Important?

Imagine deployments that happen automatically when you push to Git! ๐ŸŒŸ Thatโ€™s Fluxโ€™s magic! Hereโ€™s why itโ€™s game-changing:

  • ๐Ÿ”„ Automatic Sync - Push to Git, watch it deploy automatically!
  • ๐Ÿ“ฆ Git as Truth - Everything lives in Git, versioned and auditable
  • ๐Ÿ›ก๏ธ Self-Healing - Drift detection and automatic correction
  • ๐ŸŒ Multi-Environment - Manage dev, staging, prod from one repo
  • ๐ŸŽฏ Pull-Based - Secure deployments without CI/CD access
  • ๐Ÿ“Š Declarative Everything - Infrastructure and apps as code
  • ๐Ÿ” Security First - No cluster credentials outside cluster
  • ๐Ÿ’ก CNCF Graduated - Production-ready and battle-tested

๐ŸŽฏ What You Need

Before we GitOps all the things, gather these:

  • โœ… AlmaLinux 9 server (4GB RAM minimum, 8GB recommended)
  • โœ… Kubernetes cluster 1.20+ (K3s, K8s, or any flavor)
  • โœ… kubectl configured and working
  • โœ… GitHub/GitLab account with personal access token
  • โœ… Git repository for your manifests
  • โœ… Basic Git knowledge
  • โœ… Root or sudo access
  • โœ… Ready for GitOps magic! ๐ŸŽ‰

๐Ÿ“ Step 1: Prepare AlmaLinux Environment

Letโ€™s prepare your system for Flux! ๐Ÿ› ๏ธ

Install Prerequisites

# Update system packages
sudo dnf update -y  # Keep everything current

# Install required tools
sudo dnf install -y git curl wget

# Verify Kubernetes cluster
kubectl get nodes  # All should be Ready
kubectl version --short  # Check version 1.20+

# Create flux-system namespace
kubectl create namespace flux-system

# Check cluster access
kubectl auth can-i create deployments --all-namespaces  # Should return "yes"

Install Flux CLI

# Install Flux CLI - Method 1: Direct download
curl -s https://fluxcd.io/install.sh | sudo bash

# Or Method 2: Manual installation
FLUX_VERSION="2.2.0"  # Check latest at github.com/fluxcd/flux2
curl -LO https://github.com/fluxcd/flux2/releases/download/v${FLUX_VERSION}/flux_${FLUX_VERSION}_linux_amd64.tar.gz
tar -xzf flux_${FLUX_VERSION}_linux_amd64.tar.gz
sudo mv flux /usr/local/bin/
sudo chmod +x /usr/local/bin/flux

# Verify installation
flux --version  # Shows Flux version

# Enable bash completion
flux completion bash | sudo tee /etc/bash_completion.d/flux > /dev/null
source /etc/bash_completion.d/flux

# Check prerequisites
flux check --pre  # All checks should pass

๐Ÿ”ง Step 2: Bootstrap Flux

Time to connect Flux with your Git repository! ๐ŸŽŠ

Create GitHub Token

# Create a personal access token at:
# https://github.com/settings/tokens/new
# Required scopes: repo (full control)

# Export token as environment variable
export GITHUB_TOKEN=<your-token>
export GITHUB_USER=<your-username>

# Verify token works
curl -H "Authorization: token $GITHUB_TOKEN" https://api.github.com/user

Bootstrap Flux with GitHub

# Bootstrap Flux to your cluster
flux bootstrap github \
  --owner=$GITHUB_USER \
  --repository=fleet-infra \
  --branch=main \
  --path=./clusters/production \
  --personal \
  --private=false

# This command will:
# 1. Create the repository if it doesn't exist
# 2. Generate Flux manifests
# 3. Deploy Flux controllers to your cluster
# 4. Configure Flux to manage itself from Git

# Watch Flux installation
flux get all  # Shows all Flux resources
kubectl get pods -n flux-system  # All should be Running

Alternative: Bootstrap with GitLab

# For GitLab users
export GITLAB_TOKEN=<your-token>

flux bootstrap gitlab \
  --owner=$GITLAB_USER \
  --repository=fleet-infra \
  --branch=main \
  --path=./clusters/production \
  --hostname=gitlab.com \
  --personal \
  --private=false

๐ŸŒŸ Step 3: Deploy Applications with Flux

Letโ€™s deploy applications the GitOps way! ๐Ÿš€

Create Application Source

# Clone your fleet-infra repository
git clone https://github.com/$GITHUB_USER/fleet-infra
cd fleet-infra

# Create app source
cat <<EOF > ./clusters/production/podinfo-source.yaml
apiVersion: source.toolkit.fluxcd.io/v1
kind: GitRepository
metadata:
  name: podinfo
  namespace: flux-system
spec:
  interval: 1m
  ref:
    branch: master
  url: https://github.com/stefanprodan/podinfo
EOF

# Create Kustomization for deployment
cat <<EOF > ./clusters/production/podinfo-kustomization.yaml
apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
metadata:
  name: podinfo
  namespace: flux-system
spec:
  interval: 10m
  path: "./kustomize"
  prune: true
  sourceRef:
    kind: GitRepository
    name: podinfo
  targetNamespace: default
  patches:
    - patch: |
        - op: replace
          path: /spec/replicas
          value: 3
      target:
        kind: Deployment
        name: podinfo
EOF

# Commit and push
git add .
git commit -m "Add podinfo application"
git push

# Watch Flux sync the application
flux get sources git
flux get kustomizations
kubectl get pods -n default  # podinfo pods appear!

Deploy Helm Charts

# Add Helm repository source
cat <<EOF > ./clusters/production/nginx-helm-repo.yaml
apiVersion: source.toolkit.fluxcd.io/v1beta2
kind: HelmRepository
metadata:
  name: bitnami
  namespace: flux-system
spec:
  interval: 1h
  url: https://charts.bitnami.com/bitnami
EOF

# Create HelmRelease
cat <<EOF > ./clusters/production/nginx-helm-release.yaml
apiVersion: helm.toolkit.fluxcd.io/v2beta2
kind: HelmRelease
metadata:
  name: nginx
  namespace: default
spec:
  interval: 5m
  chart:
    spec:
      chart: nginx
      version: '15.x'
      sourceRef:
        kind: HelmRepository
        name: bitnami
        namespace: flux-system
  values:
    replicaCount: 2
    service:
      type: LoadBalancer
    resources:
      limits:
        cpu: 100m
        memory: 128Mi
      requests:
        cpu: 50m
        memory: 64Mi
EOF

# Commit and push
git add .
git commit -m "Add NGINX Helm release"
git push

# Monitor deployment
flux get helmreleases
helm list -A  # Shows deployed charts

โœ… Step 4: Multi-Environment Setup

Letโ€™s manage multiple environments with Flux! ๐ŸŒ

Structure for Multiple Environments

# Create environment structure
mkdir -p ./clusters/{staging,production}/apps
mkdir -p ./infrastructure/{base,staging,production}

# Base infrastructure components
cat <<EOF > ./infrastructure/base/namespace.yaml
apiVersion: v1
kind: Namespace
metadata:
  name: apps
EOF

# Staging overrides
cat <<EOF > ./infrastructure/staging/kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
  - ../base
patches:
  - patch: |
      - op: add
        path: /metadata/labels
        value:
          environment: staging
    target:
      kind: Namespace
      name: apps
EOF

# Production overrides
cat <<EOF > ./infrastructure/production/kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
  - ../base
patches:
  - patch: |
      - op: add
        path: /metadata/labels
        value:
          environment: production
    target:
      kind: Namespace
      name: apps
EOF

# Flux Kustomization for each environment
cat <<EOF > ./clusters/staging/infrastructure.yaml
apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
metadata:
  name: infrastructure
  namespace: flux-system
spec:
  interval: 10m
  path: ./infrastructure/staging
  prune: true
  sourceRef:
    kind: GitRepository
    name: flux-system
EOF

git add .
git commit -m "Add multi-environment setup"
git push

๐ŸŽฎ Quick Examples

Letโ€™s explore Fluxโ€™s powerful features! ๐ŸŽฌ

Example 1: Image Automation

# Enable image automation
flux install \
  --components-extra=image-reflector-controller,image-automation-controller

# Configure image scanning
cat <<EOF | kubectl apply -f -
apiVersion: image.toolkit.fluxcd.io/v1beta2
kind: ImageRepository
metadata:
  name: podinfo
  namespace: flux-system
spec:
  image: ghcr.io/stefanprodan/podinfo
  interval: 1m
---
apiVersion: image.toolkit.fluxcd.io/v1beta2
kind: ImagePolicy
metadata:
  name: podinfo
  namespace: flux-system
spec:
  imageRepositoryRef:
    name: podinfo
  policy:
    semver:
      range: '>=5.0.0'
---
apiVersion: image.toolkit.fluxcd.io/v1beta1
kind: ImageUpdateAutomation
metadata:
  name: podinfo
  namespace: flux-system
spec:
  interval: 10m
  sourceRef:
    kind: GitRepository
    name: flux-system
  git:
    checkout:
      ref:
        branch: main
    commit:
      author:
        email: [email protected]
        name: fluxcdbot
      messageTemplate: 'Update image to {{range .Images}}{{println .}}{{end}}'
    push:
      branch: main
  update:
    path: "./clusters/production"
    strategy: Setters
EOF

# Flux will now auto-update images! ๐ŸŽ‰

Example 2: Notifications

# Set up Slack notifications
cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: Secret
metadata:
  name: slack-url
  namespace: flux-system
stringData:
  address: https://hooks.slack.com/services/YOUR/SLACK/WEBHOOK
---
apiVersion: notification.toolkit.fluxcd.io/v1beta2
kind: Provider
metadata:
  name: slack
  namespace: flux-system
spec:
  type: slack
  secretRef:
    name: slack-url
---
apiVersion: notification.toolkit.fluxcd.io/v1beta2
kind: Alert
metadata:
  name: on-call-webapp
  namespace: flux-system
spec:
  providerRef:
    name: slack
  eventSeverity: info
  eventSources:
    - kind: GitRepository
      name: '*'
    - kind: Kustomization
      name: '*'
    - kind: HelmRelease
      name: '*'
  summary: 'Flux notification for production cluster'
EOF

# Now you get Slack alerts! ๐Ÿ“ฑ

Example 3: Monitoring with Grafana

# Deploy Flux Grafana dashboards
flux create source git monitoring \
  --url=https://github.com/fluxcd/flux2-monitoring-example \
  --branch=main

flux create kustomization monitoring \
  --source=GitRepository/monitoring \
  --path="./monitoring/configs" \
  --prune=true \
  --interval=1h

# Access Grafana
kubectl port-forward -n monitoring svc/grafana 3000:3000 &
echo "๐Ÿ“Š Grafana at http://localhost:3000 (admin/admin)"

๐Ÿšจ Fix Common Problems

Donโ€™t panic! Here are solutions! ๐Ÿ’ช

Problem 1: Flux Not Syncing

# Check Flux status
flux get all --all-namespaces

# Check source status
flux get sources git -A

# Force reconciliation
flux reconcile source git flux-system

# Check logs
flux logs --all-namespaces --follow

# Suspend and resume
flux suspend kustomization podinfo
flux resume kustomization podinfo

Problem 2: Authentication Issues

# Regenerate deploy keys
flux create secret git flux-system \
  --url=ssh://[email protected]/$GITHUB_USER/fleet-infra

# Update image pull secrets
kubectl create secret docker-registry regcred \
  --docker-server=ghcr.io \
  --docker-username=$GITHUB_USER \
  --docker-password=$GITHUB_TOKEN \
  -n flux-system

Problem 3: Drift Detection

# Check for drift
flux diff kustomization podinfo

# Fix drift manually
kubectl delete deployment podinfo -n default
flux reconcile kustomization podinfo --with-source

# Enable strict mode
flux create kustomization my-app \
  --source=flux-system \
  --path="./apps" \
  --prune=true \
  --validation=strict

๐Ÿ“‹ Simple Commands Summary

Your Flux command toolkit! ๐Ÿ“š

CommandWhat It DoesWhen to Use
flux bootstrap githubInstall FluxInitial setup
flux get allShow all resourcesCheck status
flux reconcileForce syncManual sync
flux logsView controller logsDebug issues
flux diffShow differencesCheck drift
flux suspendPause reconciliationMaintenance
flux resumeResume reconciliationAfter maintenance
flux create source gitAdd Git sourceNew repository
flux create helmreleaseDeploy Helm chartAdd application
flux uninstallRemove FluxCleanup

๐Ÿ’ก Tips for Success

Master GitOps with these pro tips! ๐Ÿ†

Repository Structure

  • ๐Ÿ“ Organize by environment and application
  • ๐ŸŽฏ Use Kustomize for configuration management
  • ๐Ÿ“ Keep secrets encrypted with Sealed Secrets
  • ๐Ÿ”„ Implement proper branching strategy
  • ๐Ÿ“Š Version everything with semantic versioning

Best Practices

  • ๐Ÿ›ก๏ธ Never commit secrets in plain text
  • ๐Ÿ” Monitor drift continuously
  • ๐Ÿ“ˆ Set up comprehensive alerting
  • ๐ŸŽฏ Use image automation carefully
  • ๐Ÿ’พ Backup Git repositories regularly
  • ๐Ÿ” Implement RBAC properly
  • โšก Keep reconciliation intervals reasonable

Performance Tips

  • ๐Ÿš€ Use webhooks for instant updates
  • ๐Ÿ’ก Optimize Git repository size
  • ๐Ÿ“Š Monitor controller resource usage
  • ๐ŸŽฏ Tune garbage collection
  • ๐Ÿ”„ Use dependency management

๐Ÿ† What You Learned

Outstanding! Youโ€™re now a GitOps master! ๐ŸŽ‰ You can:

  • โœ… Install and bootstrap Flux on AlmaLinux 9
  • โœ… Connect Flux with Git repositories
  • โœ… Deploy applications declaratively
  • โœ… Manage Helm charts with Flux
  • โœ… Set up multi-environment GitOps
  • โœ… Configure image automation
  • โœ… Implement notifications and monitoring
  • โœ… Troubleshoot common issues

๐ŸŽฏ Why This Matters

Youโ€™ve achieved true GitOps excellence! ๐Ÿš€ With Flux:

  • Git as Single Truth - Everything is versioned and auditable
  • Automatic Everything - Push to Git, done!
  • Self-Healing - No more configuration drift
  • Secure by Design - No cluster credentials in CI/CD
  • Multi-Environment - Manage all environments from one place
  • Developer Friendly - Developers just push code
  • Enterprise Ready - CNCF graduated project

Your deployments are now fully automated, secure, and auditable! No more manual kubectl commands, no more forgotten deployments. Everything flows from Git automatically.

Keep exploring advanced features like progressive delivery, A/B testing, and multi-cluster management. Youโ€™re doing GitOps like the pros! ๐ŸŒŸ

Remember: The future is GitOps - Flux makes it reality! Happy automating! ๐ŸŽŠ๐Ÿ”„


P.S. - Join the Flux community, contribute to the ecosystem, and share your GitOps journey! Together weโ€™re revolutionizing deployments! โญ๐Ÿ™Œ