docker.recipes

Flux GitOps Stack

advanced

Flux CD for GitOps with Weave GitOps UI.

Overview

Flux is a Cloud Native Computing Foundation (CNCF) graduated project that implements GitOps principles for Kubernetes, treating Git repositories as the single source of truth for cluster configuration and application deployment. Originally developed by Weaveworks, Flux automates the deployment process by continuously monitoring Git repositories and synchronizing changes to Kubernetes clusters, eliminating manual kubectl commands and ensuring declarative infrastructure management. Flux CD operates on a pull-based model where controllers running inside the cluster detect configuration drift and automatically reconcile the desired state defined in Git. This GitOps stack combines Flux CD with Kind (Kubernetes in Docker) for local cluster simulation and Weave GitOps UI for visual management and monitoring. Kind provides a lightweight Kubernetes environment that runs entirely in Docker containers, making it perfect for GitOps development and testing without requiring cloud resources. The integrated container registry enables storing and managing custom images locally, while Weave GitOps delivers a web-based dashboard for visualizing GitOps workflows, monitoring deployments, and troubleshooting synchronization issues across multiple clusters. This configuration targets DevOps engineers and platform teams implementing GitOps practices in development environments, CI/CD pipelines, or proof-of-concept deployments. The stack eliminates the complexity of setting up separate Kubernetes clusters, Git repositories, and monitoring tools by providing a unified development environment where teams can experiment with GitOps workflows, test Flux configurations, and validate deployment strategies before promoting to production clusters.

Key Features

  • Pull-based GitOps reconciliation with Flux controllers monitoring Git repository changes
  • Multi-tenancy support with Flux namespace isolation and RBAC integration
  • Helm and Kustomize native support for complex application deployment patterns
  • Kind cluster with containerd runtime optimized for local Kubernetes development
  • Weave GitOps dashboard for visualizing application deployments and Git synchronization status
  • Built-in container registry for storing custom images without external dependencies
  • Flux image automation for updating container tags based on registry scanning
  • Git webhook support for immediate synchronization triggers beyond polling intervals

Common Use Cases

  • 1Local GitOps development environment for testing Flux configurations before production deployment
  • 2CI/CD pipeline integration for validating GitOps workflows in ephemeral test clusters
  • 3Multi-environment application promotion workflows using Git branching strategies
  • 4Kubernetes manifest validation and drift detection in containerized development setups
  • 5Training and education platform for teams learning GitOps principles and Flux operations
  • 6Proof-of-concept deployments demonstrating GitOps benefits to stakeholders and management
  • 7Custom controller development and testing in isolated Kubernetes environments

Prerequisites

  • Docker Engine 20.10+ with privileged container support for Kind cluster operation
  • Git repository with Kubernetes manifests and Flux configuration files
  • Minimum 4GB RAM and 2 CPU cores for stable Kind cluster with Flux controllers
  • Network access to GitHub/GitLab for Flux source controller Git repository synchronization
  • Basic Kubernetes knowledge including pods, services, and namespace concepts
  • Understanding of YAML syntax and Kubernetes manifest structure for GitOps workflows

For development & testing. Review security settings, change default credentials, and test thoroughly before production use. See Terms

docker-compose.yml

docker-compose.yml
1services:
2 kind:
3 image: kindest/node:v1.28.0
4 container_name: flux-cluster
5 privileged: true
6 ports:
7 - "${API_PORT:-6443}:6443"
8 volumes:
9 - kind_data:/var/lib/containerd
10
11 registry:
12 image: registry:2
13 container_name: flux-registry
14 restart: unless-stopped
15 ports:
16 - "${REGISTRY_PORT:-5000}:5000"
17 volumes:
18 - registry_data:/var/lib/registry
19
20 weave-gitops:
21 image: ghcr.io/weaveworks/wego-app:latest
22 container_name: weave-gitops
23 restart: unless-stopped
24 ports:
25 - "${GITOPS_PORT:-9001}:9001"
26
27volumes:
28 kind_data:
29 registry_data:

.env Template

.env
1# Flux GitOps
2API_PORT=6443
3REGISTRY_PORT=5000
4GITOPS_PORT=9001
5GITHUB_TOKEN=your_github_token

Usage Notes

  1. 1Weave GitOps UI at http://localhost:9001
  2. 2Bootstrap Flux with flux CLI
  3. 3Point Flux to your Git repo

Individual Services(3 services)

Copy individual services to mix and match with your existing compose files.

kind
kind:
  image: kindest/node:v1.28.0
  container_name: flux-cluster
  privileged: true
  ports:
    - ${API_PORT:-6443}:6443
  volumes:
    - kind_data:/var/lib/containerd
registry
registry:
  image: registry:2
  container_name: flux-registry
  restart: unless-stopped
  ports:
    - ${REGISTRY_PORT:-5000}:5000
  volumes:
    - registry_data:/var/lib/registry
weave-gitops
weave-gitops:
  image: ghcr.io/weaveworks/wego-app:latest
  container_name: weave-gitops
  restart: unless-stopped
  ports:
    - ${GITOPS_PORT:-9001}:9001

Quick Start

terminal
1# 1. Create the compose file
2cat > docker-compose.yml << 'EOF'
3services:
4 kind:
5 image: kindest/node:v1.28.0
6 container_name: flux-cluster
7 privileged: true
8 ports:
9 - "${API_PORT:-6443}:6443"
10 volumes:
11 - kind_data:/var/lib/containerd
12
13 registry:
14 image: registry:2
15 container_name: flux-registry
16 restart: unless-stopped
17 ports:
18 - "${REGISTRY_PORT:-5000}:5000"
19 volumes:
20 - registry_data:/var/lib/registry
21
22 weave-gitops:
23 image: ghcr.io/weaveworks/wego-app:latest
24 container_name: weave-gitops
25 restart: unless-stopped
26 ports:
27 - "${GITOPS_PORT:-9001}:9001"
28
29volumes:
30 kind_data:
31 registry_data:
32EOF
33
34# 2. Create the .env file
35cat > .env << 'EOF'
36# Flux GitOps
37API_PORT=6443
38REGISTRY_PORT=5000
39GITOPS_PORT=9001
40GITHUB_TOKEN=your_github_token
41EOF
42
43# 3. Start the services
44docker compose up -d
45
46# 4. View logs
47docker compose logs -f

One-Liner

Run this command to download and set up the recipe in one step:

terminal
1curl -fsSL https://docker.recipes/api/recipes/flux-gitops-stack/run | bash

Troubleshooting

  • Flux source controller fails to clone repository: Verify Git credentials and repository URL in Flux GitRepository resource, check network connectivity to Git provider
  • Kind cluster fails to start with 'failed to create cluster': Ensure Docker daemon is running with privileged container support and sufficient disk space available
  • Weave GitOps UI shows empty clusters: Run 'flux bootstrap' command to install Flux controllers and configure Git repository connection properly
  • Kustomization reconciliation suspended with authentication errors: Generate and configure deploy keys or personal access tokens with appropriate repository permissions
  • Container registry push failures: Verify registry service is running on port 5000 and Docker daemon trusts localhost:5000 as insecure registry
  • Flux controllers consuming high CPU: Reduce Git polling frequency in source controller configuration and optimize Kustomization resource specifications

Community Notes

Loading...
Loading notes...

Download Recipe Kit

Get all files in a ready-to-deploy package

Includes docker-compose.yml, .env template, README, and license

Ad Space