Using Manifests and Flux with Kubernetes Clusters

45 minutes
  • 4 Learning Objectives

About this Hands-on Lab

This hands-on learning experience challenges the student to install and configure Flux with a repository of their own.

Note To The Student:
The YAML in this lab refers to a docker image that does not exist on docker hub. This is intentional so the student may observe what happends when a YAML attempts to deploy a tagged image that does not exist. It is covered in the solution video.

Once configured, the student will:

1. Create a namespace to deploy an application into
2. Create a Deployment of a sample “Hello” application
3. Update that Deployment to a new release of the same application

Some troubleshooting of YAML is required to achieve the goals of this lab.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Set up a GitHub or Other GitVCS Repository with the Required YAML

The student must use their own GitHub or GitLab account to set up a repository with the Kubernetes YAML to create a namespace, and deploy the Hello application into that namespace.

The YAML files required are in the course repository, and include the following two files:

In the namespaces folder:

apiVersion: v1
kind: Namespace
    name: lasample
  name: lasample

In the workloads folder:

apiVersion: apps/v1
kind: Deployment
  name: hello
  namespace: lasample
    app: hello
      app: hello
        app: hello
      - name: hello
        image: linuxacademycontent/gitops:hellov1.0
Install and Configure Flux

Create the Flux namespace:

$ kubectl create namespace flux

Set the environment variable to the Flux namepace:


Set the GHUSER environment variable to your GitHub or GitLab handle:

$ export GHUSER="Your Handle"

Install Flux:

$ fluxctl install 
--git-email=${GHUSER}${GHUSER}/[Your Repo Name] 
--namespace=flux | kubectl apply -f -

Check the rollout status:

$ kubectl -n flux rollout status deployment/flux

Obtain the RSA key that was created:

$ fluxctl identity --k8s-fwd-ns flux

Note: Copy the RSA key and set it up in GitHub as a ‘Deploy Key’ or in GitLab as an SSH Key. Be sure to grant write access to the key when you add it.

Sync the Cluster with the Repository and Check the Results

The tagged image v1.0 in the original YAML does not exist. This is intentional so the student may see how Flux responds in that event. This is covered in the solution video.

Sync the cluster:

$ fluxctl sync

Check that the namespace exists:

$ kubectl get namespaces

Check that the deployment exists:

$ kubectl get pods --all-namespaces

Look at the Flux workloads:

$ fluxctl -n [Your Namespace] list-workloads

Look at the container image deployed:

$ fluxctl -n [Your Namespace] list-images

Note: Be sure the namespace in the namespace create YAML matches the namespace specified in the deployment. Troubleshoot the image deployed by using the Release command in the next step.

Verify the Image Tag Names Provided in Docker Hub and Use the Automate and Release Commands to Deploy Specific Containers

Note: The Docker hub location is linuxacademycontent/gitops.

Use the automate command to add automation to the deployment:

$ fluxctl automate --workload=[namespace]:deployment/hello

Use the release command to specify a different container:

$ fluxctl release --workload=[namespace]:deployment/hello --update-image=linuxacademycontent/gitops:hellov1.2

NOTE: The namespace to place in this command is the namespace you deployed the hello pod into.
Not the flux namespace where flux is running.

You may try the release command on other images as well. Check the changes pushed to the Repo YAML, and also use the list-workloads and list-images commands to see the results.

Additional Resources

To complete this lab the student must have their own GitHub or GitLab account and be able to set up a repository with the required YAML files. The student should also be familiar with the installation and configuration of Flux, which is covered in a prior lab as part of the GitOps course.

Note: The docker image tagged v1.0 does not exist. This is intentional so the student may observe what Flux does in this case.

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Get Started
Who’s going to be learning?

How many seats do you need?

  • $499 USD per seat per year
  • Billed Annually
  • Renews in 12 months

Ready to accelerate learning?

For over 25 licenses, a member of our sales team will walk you through a custom tailored solution for your business.


Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!