Skip to content

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.
  • Labs icon Lab
  • A Cloud Guru
Google Cloud Platform icon
Labs

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.

Google Cloud Platform icon
Labs

Path Info

Level
Clock icon Beginner
Duration
Clock icon 45m
Published
Clock icon Feb 13, 2020

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.

Table of Contents

  1. 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.

  2. 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 the hello.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
    
  3. Challenge

    Create Another hello.yaml in a Folder Called production

    Create a folder called production with the same hello.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
    
  4. 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 the workloads 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.

  5. 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.

  6. 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
    
  7. 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
    
  8. 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 the production 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.

The Cloud Content team comprises subject matter experts hyper focused on services offered by the leading cloud vendors (AWS, GCP, and Azure), as well as cloud-related technologies such as Linux and DevOps. The team is thrilled to share their knowledge to help you build modern tech solutions from the ground up, secure and optimize your environments, and so much more!

What's a lab?

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.

Provided environment for hands-on practice

We will provide the credentials and environment necessary for you to practice right within your browser.

Guided walkthrough

Follow along with the author’s guided walkthrough and build something new in your provided environment!

Did you know?

On average, you retain 75% more of your learning if you get time for practice.

Start learning by doing today

View Plans