- Lab
-
Libraries: If you want this lab, consider one of these libraries.
- Cloud

Deploying Applications with GitHub Actions Workflow and Flux
This hands-on lab challenges the student to implement Flux within a GitHub environment, taking into account the need to deploy applications into development, test, and production environments. This lab challenges the student to set up Kubernetes YAML to deploy workloads into a QA and Production Cluster.

Lab Info
Table of Contents
-
Challenge
Fork or Create a GitHub Repository
Please set up a repository for this lab. If you have one from a prior lab, it should work for you. If not, you may fork the ACloudGuru-Resources/content-gitops repository.
-
Challenge
Create the Hello YAML in a Folder Called qa
If the folder
qa
does not exist in the repository, create that folder and create thehello.yaml
file within it.The content of the yaml file is:
apiVersion: apps/v1 kind: Deployment metadata: name: hello namespace: lasample labels: app: hello spec: selector: matchLabels: app: hello template: metadata: labels: app: hello spec: containers: - name: hello image: acgtes/gitops:hellov1.1
-
Challenge
Create Another hello.yaml in a Folder Called production
Create a folder called
production
with the samehello.yaml
file in it.apiVersion: apps/v1 kind: Deployment metadata: name: hello namespace: lasample labels: app: hello spec: selector: matchLabels: app: hello template: metadata: labels: app: hello spec: containers: - name: hello image: acgtes/gitops:hellov1.1
-
Challenge
Deploy the Flux Daemon and Configure It To Scan the qa Folder
Deploy Flux as in other labs with the following commands:
Install the fluxctl software:
$ sudo snap install fluxctl --classic
Create the
flux
namespace:$ kubectl create namespace flux
Set the GHUSER Environment variable to your GitHub username:
$ export GHUSER=[Your username here]
Deploy Flux, but notice that we are scanning the
qa
folder not theworkloads
folder:$ fluxctl install --git-user=${GHUSER} --git-email=${GHUSER}@users.noreply.github.com [email protected]:${GHUSER}/content-gitops --git-path=namespaces,qa --namespace=flux | kubectl apply -f -
Set the environment variable for the
fluxctl
command:$ export FLUX_FORWARD_NAMESPACE=flux
Grab the RSA key created by Flux:
$ fluxctl identity
The alternative is to not set the FLUX_FORWARD_NAMESPACE variable and instead use this command:
$ fluxctl identity --k8s-fwd-ns flux
Copy and past that RSA key into the Deploy Keys within your GitHub Repo.
-
Challenge
Add the Deploy Key to Your Repo
Use the RSA key copied to the clipboard to add a "Deploy Key" in GitHub, or an SSH RSA Key in other Git servers, to grant read and write access to your QA Kubernetes Cluster.
-
Challenge
Use the list-workloads Command To Examine The Deployed Container Images
If you have not set the FLUX_FORWARD_NAMESPACE variable, you should do so now:
$ export FLUX_FORWARD_NAMESPACE=flux
Use
fluxctl
to examine the container images deployed:$ fluxctl list-workloads --all-namespaces
-
Challenge
Change the hello.yaml File in the QA Folder to Deploy Version 1.2
Change the
hello.yaml
file to deploy the version 1.2 of the container image.Then sync with:
$ fluxctl sync
Check the container running with:
$ fluxctl list-workloads --all-namespaces
-
Challenge
Delete the flux and lasample Namespaces and Repeat the Install for Production
Delete the running instance of Flux on your cluster:
$ kubectl delete namespace flux
Delete the deployed
hello
workload:$ kubectl delete namespace lasample
Then repeat the steps to install the
flux
daemon, but this time configure for scanning theproduction
folder:$ fluxctl install --git-user=${GHUSER} --git-email=${GHUSER}@users.noreply.github.com [email protected]:${GHUSER}/content-gitops --git-path=namespaces,production --namespace=flux | kubectl apply -f -
Then test by changing the
hello.yaml
file in the production folder to deploy other images.
About the author
Real skill practice before real-world application
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.
Learn by doing
Engage hands-on with the tools and technologies you’re learning. You pick the skill, we provide the credentials and environment.
Follow your guide
All labs have detailed instructions and objectives, guiding you through the learning process and ensuring you understand every step.
Turn time into mastery
On average, you retain 75% more of your learning if you take time to practice. Hands-on labs set you up for success to make those skills stick.