Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
FluxCD for continuous delivery
📖 Scenario: You are working as a DevOps engineer for a small company. Your team wants to automate the deployment of applications to Kubernetes clusters using GitOps principles. You will use FluxCD, a tool that watches your Git repository and applies changes automatically to your cluster.
🎯 Goal: Set up a basic FluxCD configuration to deploy a simple Kubernetes application from a Git repository. You will create the initial Kubernetes manifest, configure FluxCD to watch the repository, apply the main deployment logic, and finally verify the deployment.
📋 What You'll Learn
Create a Kubernetes manifest file for a simple Nginx deployment
Add a FluxCD GitRepository resource to point to the Git repo
Create a FluxCD Kustomization resource to apply the deployment
Verify the deployment by checking the FluxCD sync status
💡 Why This Matters
🌍 Real World
FluxCD is widely used in real companies to automate Kubernetes deployments by syncing cluster state with Git repositories. This reduces manual errors and speeds up delivery.
💼 Career
Understanding FluxCD and GitOps is valuable for DevOps roles, Kubernetes administrators, and cloud engineers who manage continuous delivery pipelines.
Progress0 / 4 steps
1
Create the initial Kubernetes manifest
Create a file named nginx-deployment.yaml with a Kubernetes Deployment manifest for Nginx. Use apiVersion: apps/v1, kind: Deployment, and set metadata.name to nginx-deployment. The deployment should have 1 replica and use the image nginx:latest. Include a container port 80.
Kubernetes
Hint
Remember to set metadata.name exactly to nginx-deployment and use nginx:latest as the container image.
2
Add FluxCD GitRepository resource
Create a file named flux-gitrepository.yaml with a FluxCD GitRepository resource. Set apiVersion to source.toolkit.fluxcd.io/v1beta2 and kind to GitRepository. Name the resource nginx-repo. Set the spec.url to https://github.com/example/nginx-config.git and spec.interval to 1m.
Kubernetes
Hint
Make sure the GitRepository resource has the exact name nginx-repo and the URL matches exactly.
3
Create FluxCD Kustomization resource
Create a file named flux-kustomization.yaml with a FluxCD Kustomization resource. Use apiVersion: kustomize.toolkit.fluxcd.io/v1beta2 and kind: Kustomization. Name it nginx-kustomization. Set spec.interval to 1m, spec.path to ./, and spec.sourceRef.name to nginx-repo with kindGitRepository. This will apply the manifests from the Git repository.
Kubernetes
Hint
Ensure the Kustomization resource references the nginx-repo GitRepository by name and kind.
4
Verify FluxCD deployment sync status
Run the command flux get kustomizations in your terminal to check the sync status of the nginx-kustomization. This command shows if FluxCD has applied the manifests successfully.
Kubernetes
Hint
Use the exact command flux get kustomizations to see the status. Look for nginx-kustomization in the output.
Practice
(1/5)
1. What is the primary role of FluxCD in a Kubernetes environment?
easy
A. Automatically sync and deploy application changes from Git to Kubernetes
B. Monitor Kubernetes cluster health and send alerts
C. Manage container image builds and push to registries
D. Provide a user interface for Kubernetes cluster management
Solution
Step 1: Understand FluxCD's purpose
FluxCD is designed to automate continuous delivery by syncing Kubernetes with Git repositories.
Step 2: Identify the correct role
Among the options, only automatic syncing and deploying from Git matches FluxCD's role.
Final Answer:
Automatically sync and deploy application changes from Git to Kubernetes -> Option A
Quick Check:
FluxCD = Git sync and deploy [OK]
Hint: FluxCD syncs Git changes to Kubernetes automatically [OK]
Common Mistakes:
Confusing FluxCD with monitoring tools
Thinking FluxCD builds container images
Assuming FluxCD provides UI for cluster management
2. Which of the following is the correct minimal YAML snippet to define a GitRepository resource for FluxCD?
4. You applied a Kustomization resource but FluxCD never deploys your changes. Which of these is the most likely cause?
medium
A. The FluxCD controller pod is running with high CPU usage
B. The Kubernetes cluster is out of disk space
C. The container image tag is not updated in the deployment manifest
D. The GitRepository resource referenced by sourceRef is missing or has wrong name
Solution
Step 1: Check Kustomization sourceRef
If the GitRepository resource named in sourceRef does not exist or is misnamed, FluxCD cannot fetch manifests to deploy.
Step 2: Evaluate other options
Disk space or CPU issues may cause problems but won't prevent FluxCD from attempting deploy; image tag issues affect app behavior but not deployment trigger.
Final Answer:
The GitRepository resource referenced by sourceRef is missing or has wrong name -> Option D
Quick Check:
Missing GitRepository = no deploy [OK]
Hint: Check sourceRef GitRepository exists and matches name exactly [OK]
Common Mistakes:
Ignoring sourceRef misconfiguration
Blaming cluster resources without checking FluxCD logs
Assuming image tag changes trigger deploy automatically
5. You want FluxCD to deploy only when a specific branch 'release' is updated in your Git repository. Which field should you add or modify in the GitRepository resource to achieve this?
hard
A. Add 'ref: branch: release' under spec in GitRepository
B. Set 'interval: 1h' in Kustomization spec
C. Add 'prune: false' in Kustomization spec
D. Set 'validation: none' in Kustomization spec
Solution
Step 1: Understand GitRepository branch filtering
To track a specific branch, the GitRepository spec must include a ref field specifying the branch name.
Step 2: Identify correct syntax
The correct syntax is spec.ref.branch: release, which tells FluxCD to sync only that branch.