Skip to main content
In this guide, you’ll learn how Flux’s Source Controller pulls manifests from a Git repository and how the Kustomize Controller applies them to a Kubernetes cluster, showcasing a GitOps-driven workflow.
Ensure you’ve bootstrapped Flux CD with SSH credentials so the secretRef in your GitRepository can authenticate to GitHub.
See Flux CD installation for details.

1. Define GitRepository and Kustomization

Create a GitRepository to tell Flux where to fetch your manifests, then reference it in a Kustomization:
Key fields explained:
  • interval: reconciliation frequency
  • url/ref: Git source and branch
  • secretRef: SSH key for cloning
  • path: directory in the repo to apply
  • prune: deletes resources removed from Git

Flux Controllers Overview

2. Verify Flux Sources and Kustomizations

Confirm that Flux has registered your sources and kustomizations:

3. Import and Clone the Demo Application

We’ll use a repository named bb-app-source containing both app code and Kubernetes manifests.
  1. Import into your GitHub account
The image shows a GitHub page for importing a project, with fields for the old repository's clone URL and new repository details, including options for public or private visibility. A "Begin import" button is highlighted.
  1. Clone locally and switch to the demo branch
The image shows a GitHub page indicating that a new repository import is complete, with a user menu open on the right side.

4. Examine Application Source and Manifests

  • src/: PHP app reporting its Pod and namespace.
  • manifests/1-demo/: Contains three YAML definitions:
    • deployment.yml
    • namespace.yml
    • service.yml
The image shows a GitHub repository page with a directory listing for "1-demo" containing three YAML files: deployment.yml, namespace.yml, and service.yml.
Here’s the Deployment snippet (manifests/1-demo/deployment.yml):

5. Add Manifests to Your Flux Cluster Repo

Copy the demo manifests into your Flux cluster repository under flux-clusters/dev-cluster/1-demo:
Flux will detect these new files and begin applying them automatically.

6. Verify the GitOps Deployment

  1. Check Kubernetes namespaces
  2. Confirm Flux has the latest revision

7. Inspect the Source Controller Cache

Dive into the Source Controller pod to view the cached repository archive:

8. Access the Deployed Application

  1. List resources in the demo namespace
  2. Open the game in your browser
    http://localhost:30001
The image shows a web-based game interface called "Block Buster" with a notification indicating "Level 1 Completed." It includes game details like pod name, IP, namespace, and app version, with a simple game layout featuring a paddle and ball.
This PHP-based game displays live pod metadata, demonstrating a full GitOps flow with Flux CD.

Watch Video

Practice Lab