Bird
Raised Fist0
Kubernetesdevops~20 mins

FluxCD for continuous delivery in Kubernetes - Practice Problems & Coding Challenges

Choose your learning style10 modes available

Start learning this pattern below

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
Challenge - 5 Problems
🎖️
FluxCD Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
FluxCD GitRepository Resource Status Check
You run the command kubectl get gitrepositories.source.toolkit.fluxcd.io after applying a GitRepository manifest. What output indicates the repository is successfully cloned and ready?
Kubernetes
kubectl get gitrepositories.source.toolkit.fluxcd.io
A
NAME          READY   STATUS              REVISION          SUSPENDED
my-repo       True    Fetched revision    main@abcdef1234   False
B
NAME          READY   STATUS              REVISION          SUSPENDED
my-repo       False   Cloning failed      main@abcdef1234   False
C
NAME          READY   STATUS              REVISION          SUSPENDED
my-repo       True    Cloning in progress main@abcdef1234   False
D
NAME          READY   STATUS              REVISION          SUSPENDED
my-repo       False   Repository not found main@abcdef1234  False
Attempts:
2 left
💡 Hint
Look for READY status being True and a positive STATUS message.
🔀 Workflow
intermediate
2:00remaining
FluxCD Automated Deployment Workflow
Which step correctly describes the order of actions FluxCD performs to deploy an application from a Git repository?
A1,2,3,4
B2,1,3,4
C3,1,2,4
D1,3,2,4
Attempts:
2 left
💡 Hint
Think about fetching code before applying it.
Troubleshoot
advanced
2:00remaining
Diagnosing FluxCD Kustomization Sync Failure
You see the Kustomization resource stuck with Ready: False and status message Reconciliation failed: unable to apply manifests. Which command helps you find detailed error logs for this Kustomization?
Akubectl logs -n flux-system deployment/flux-controller
Bkubectl describe kustomization -n flux-system my-kustomization
Ckubectl logs -n flux-system kustomization/my-kustomization
Dkubectl get events -n flux-system --field-selector involvedObject.name=my-kustomization
Attempts:
2 left
💡 Hint
Look for detailed status and error messages in resource description.
🧠 Conceptual
advanced
2:00remaining
Understanding FluxCD Reconciliation Interval
What is the effect of setting a very short reconciliation interval (e.g., 5 seconds) on a FluxCD Kustomization resource?
AFluxCD will ignore changes and only reconcile once at startup.
BFluxCD will batch changes and apply them once every hour regardless of interval.
CFluxCD will frequently check and apply changes, increasing cluster load and API server requests.
DFluxCD disables reconciliation and requires manual sync commands.
Attempts:
2 left
💡 Hint
Think about how often FluxCD polls the Git repository and applies manifests.
Best Practice
expert
2:00remaining
Secure Git Access in FluxCD
Which method is the most secure and recommended way to provide FluxCD access to a private Git repository?
AAllow anonymous read access to the Git repository to avoid credentials.
BStore Git username and password in plain text in the Kustomization manifest.
CEmbed personal access tokens directly in the Git URL in the manifest.
DUse SSH deploy keys stored as Kubernetes secrets referenced by FluxCD GitRepository resource.
Attempts:
2 left
💡 Hint
Consider security best practices for credentials in Kubernetes.

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

  1. Step 1: Understand FluxCD's purpose

    FluxCD is designed to automate continuous delivery by syncing Kubernetes with Git repositories.
  2. Step 2: Identify the correct role

    Among the options, only automatic syncing and deploying from Git matches FluxCD's role.
  3. Final Answer:

    Automatically sync and deploy application changes from Git to Kubernetes -> Option A
  4. 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?
easy
A. apiVersion: apps/v1 kind: Deployment metadata: name: my-repo spec: replicas: 1
B. apiVersion: source.toolkit.fluxcd.io/v1beta2 kind: HelmRelease metadata: name: my-repo spec: chart: repository: https://charts.example.com
C. apiVersion: source.toolkit.fluxcd.io/v1beta2 kind: GitRepository metadata: name: my-repo spec: url: https://github.com/example/repo.git
D. apiVersion: v1 kind: Pod metadata: name: my-repo spec: containers: - name: app

Solution

  1. Step 1: Identify the correct apiVersion and kind for GitRepository

    The GitRepository resource uses apiVersion source.toolkit.fluxcd.io/v1beta2 and kind GitRepository.
  2. Step 2: Check the YAML structure

    apiVersion: source.toolkit.fluxcd.io/v1beta2 kind: GitRepository metadata: name: my-repo spec: url: https://github.com/example/repo.git correctly defines metadata and spec with the repository URL, matching FluxCD's GitRepository spec.
  3. Final Answer:

    YAML with apiVersion source.toolkit.fluxcd.io/v1beta2 and kind GitRepository -> Option C
  4. Quick Check:

    GitRepository YAML = apiVersion: source.toolkit.fluxcd.io/v1beta2 kind: GitRepository metadata: name: my-repo spec: url: https://github.com/example/repo.git [OK]
Hint: GitRepository uses source.toolkit.fluxcd.io/v1beta2 and kind GitRepository [OK]
Common Mistakes:
  • Using wrong apiVersion or kind
  • Confusing GitRepository with Deployment or Pod
  • Missing required spec.url field
3. Given this Kustomization YAML snippet, what will FluxCD do when it applies this resource?
apiVersion: kustomize.toolkit.fluxcd.io/v1beta2
kind: Kustomization
metadata:
  name: example-app
spec:
  interval: 5m
  path: ./deploy
  prune: true
  sourceRef:
    kind: GitRepository
    name: example-repo
  validation: client
medium
A. FluxCD will build a container image every 5 minutes from './deploy' path
B. FluxCD will sync manifests from the Git repo path './deploy' every 5 minutes and prune removed resources
C. FluxCD will only validate manifests but not apply them
D. FluxCD will deploy manifests once and then stop

Solution

  1. Step 1: Analyze the Kustomization spec fields

    The interval field sets sync every 5 minutes; path points to manifests; prune true means remove deleted resources; sourceRef points to GitRepository.
  2. Step 2: Understand FluxCD behavior

    FluxCD will fetch manifests from Git, apply them, and prune removed resources every 5 minutes.
  3. Final Answer:

    FluxCD will sync manifests from the Git repo path './deploy' every 5 minutes and prune removed resources -> Option B
  4. Quick Check:

    Kustomization sync + prune = FluxCD will sync manifests from the Git repo path './deploy' every 5 minutes and prune removed resources [OK]
Hint: Kustomization interval controls sync frequency; prune removes deleted resources [OK]
Common Mistakes:
  • Thinking FluxCD builds container images
  • Assuming validation means no apply
  • Believing sync happens only once
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

  1. Step 1: Check Kustomization sourceRef

    If the GitRepository resource named in sourceRef does not exist or is misnamed, FluxCD cannot fetch manifests to deploy.
  2. 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.
  3. Final Answer:

    The GitRepository resource referenced by sourceRef is missing or has wrong name -> Option D
  4. 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

  1. Step 1: Understand GitRepository branch filtering

    To track a specific branch, the GitRepository spec must include a ref field specifying the branch name.
  2. Step 2: Identify correct syntax

    The correct syntax is spec.ref.branch: release, which tells FluxCD to sync only that branch.
  3. Step 3: Evaluate other options

    Interval controls sync frequency, prune controls resource removal, validation controls manifest checking; none filter branches.
  4. Final Answer:

    Add 'ref: branch: release' under spec in GitRepository -> Option A
  5. Quick Check:

    Branch filter = spec.ref.branch [OK]
Hint: Use spec.ref.branch to specify Git branch in GitRepository [OK]
Common Mistakes:
  • Changing Kustomization interval instead of GitRepository branch
  • Disabling prune or validation to filter branches
  • Assuming branch filtering is done in Kustomization