Using Manifests and Flux with Kubernetes Clusters

45 minutes
  • 4 Learning Objectives

About this Hands-on Lab

This hands-on learning experience challenges you to install and configure Flux with your own code repository (e.g., GitHub or GitLab). Once configured, you will create a namespace to deploy an application into, create a Deployment of a sample “Hello” application, and update the Deployment to a new release of the same application. Some troubleshooting is required to achieve the goals of this lab.

>The YAML in this lab refers to a Docker image v.1.0 that does not exist on Docker Hub. This is intentional so you may observe what happens when a YAML file attempts to deploy a tagged image that does not exist.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

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

Use your own GitHub or GitLab account to set up a repository with the Kubernetes YAML, 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 
--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

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

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 YAML-created namespace 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, pasting in the namespace you deployed the hello pod into:

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

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

Link to this lab's GitHub repository

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

The Docker image tagged v1.0 does not exist. This is intentional to observe what Flux does when a YAML file attempts to deploy a tagged image that does not exist.

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.

Sign In
Welcome Back!

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

Get Started
Who’s going to be learning?