Skip to main content
In this tutorial, you’ll learn how to use the Flux Source Controller to fetch container images from an OCI-compatible registry (GitHub Container Registry) and deploy them to your Kubernetes cluster. We’ll pull the bb-app image (7.7.0-0bb2691) from GHCR, configure authentication, and create a Kustomization to manage deployments.

Prerequisites

  • A Kubernetes cluster with Flux CD installed (Flux Installation Guide).
  • flux CLI and kubectl configured to target your cluster.
  • Docker (optional) to verify the image locally.

Overview of Flux Resources

1. Pull the OCI Image Locally (Optional)

Verify the bb-app image before integrating with Flux:
You need both the image path (ghcr.io/sidd-harth-2/bb-app) and the tag (7.7.0-0bb2691).
Public OCI registries (e.g., Docker Hub) typically don’t require authentication. Private registries like GHCR do.

2. Create an OCIRepository Source

Register the image in Flux by creating an OCIRepository. Update the tag to 7.7.0-0bb2691:
Contents of demo-source-oci-bb-app.yaml:

3. Create the OCI Authentication Secret

Flux requires credentials to pull from a private registry. Generate a GitHub Personal Access Token (PAT) with the read:packages scope, then create the secret:
Keep your GitHub PAT secure. Do not commit ghcr-auth.yaml to public repositories.
Apply both manifests:
Verify the secret in the flux-system namespace:

4. Create a Kustomization for Deployment

Define a Kustomization that references your OCIRepository, sets up health checks, and enforces dependency ordering:
demo-kustomize-bb-app.yaml:
Apply the Kustomization:

Health Checks

Flux polls the specified resource and waits until it’s ready before marking the Kustomization as healthy. Example for a Git-based Kustomization:

Dependencies

The dependsOn field enforces deployment order. In this demo, bb-app waits for infra-database-git-mysql (your SQL database) to succeed first.

5. Reconcile and Debug

Check the Kustomization status:
If reconciliation stalls or health checks time out, inspect the resource:
Correct any mismatches (e.g., deployment names), then trigger a manual reconcile:
Verify the deployment reaches Ready:

6. Verify the Deployment

List all resources in the bb-app namespace:
Then open your browser at http://127.0.0.1:3770. In version 7.7.0 you’ll notice a new “High Score” field—but a known bug prevents high scores from persisting:
The image shows a screenshot of a "Block Buster" game with a "Game Over" message. It includes game details like score, level, and lives, along with a colorful block layout.
That issue will be fixed in the next release. Thanks for following along!

References

Watch Video