- 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
qadoes not exist in the repository, create that folder and create thehello.yamlfile 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
productionwith the samehello.yamlfile 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 --classicCreate the
fluxnamespace:$ kubectl create namespace fluxSet the GHUSER Environment variable to your GitHub username:
$ export GHUSER=[Your username here]Deploy Flux, but notice that we are scanning the
qafolder not theworkloadsfolder:$ 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
fluxctlcommand:$ export FLUX_FORWARD_NAMESPACE=fluxGrab the RSA key created by Flux:
$ fluxctl identityThe alternative is to not set the FLUX_FORWARD_NAMESPACE variable and instead use this command:
$ fluxctl identity --k8s-fwd-ns fluxCopy 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=fluxUse
fluxctlto 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.yamlfile to deploy the version 1.2 of the container image.Then sync with:
$ fluxctl syncCheck 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 fluxDelete the deployed
helloworkload:$ kubectl delete namespace lasampleThen repeat the steps to install the
fluxdaemon, but this time configure for scanning theproductionfolder:$ 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.yamlfile 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.