- Lab
- A Cloud Guru
Installing and Configuring Flux with GitLab
This lab is provided for students that do not utilize GitHub and prefer to use GitLab or some other VCS repository manager with Flux. This lab covers the installation of Flux when a student is using a repository on GitLab.
Path Info
Table of Contents
-
Challenge
Set Up A Repository (Project) In GitLab
The student must have a GitLab account, and set up a repository within that account. The repository should contain two files that are Kubernetes YAML. The first, within the
namespaces
folder, will create a namespace for the application. The YAML is as follows:apiVersion: v1 kind: Namespace metadata: labels: name: laflux name: laflux
The second file is for creating the actual deployment of an NGINX server. The YAML should be in the
workloads
folder. That YAML is as follows:apiVersion: apps/v1 kind: Deployment metadata: name: nginx-deployment namespace: laflux labels: app: nginx spec: replicas: 2 selector: matchLabels: app: nginx template: metadata: labels: app: nginx spec: containers: - name: nginx image: nginx:1.7.9 ports: - containerPort: 80
-
Challenge
Establish a Terminal Session on the Kubernetes Master and Install Flux
Use SSH to establish a session on the Kubernetes host server:
ssh cloud_user@[IP Address Here]
Use the password supplied in the lab interface.
To verify that fluxctl was installed automatically, type:
$ fluxctl version
If it was not installed automatically, you may enter:
$ sudo snap install fluxctl --classic
Once on the server, create the namespace to run Flux:
$ kubectl create namespace flux
Then set the GLUSER environment variable:
$ export GLUSER=[your GitLab username]
Then input the command to run flux:
$ fluxctl install --git-user=${GLUSER} --git-email=${GLUSER}@gmail.com --git-branch=main [email protected]:${GLUSER}/flux-sample --git-path=namespaces,workloads --namespace=flux | kubectl apply -f -
You may check the deployment with the following command:
$ kubectl -n flux rollout status deployment/flux
-
Challenge
Obtain the RSA Key Created by fluxctl, and Grant GitLab Write Permission to the Cluster
Obtain the RSA key created by the Flux install procedure with the following command:
$ fluxctl identity --k8s-fwd-ns flux
Then copy the RSA key to the clipboard and use the Settings->SSH Keys feature in GitLab to add the SSH Key.
-
Challenge
Use the fluxctl sync Command to Synchronize the Cluster
After the GitLab account has been granted write access to the Cluster, use the
sync
command to apply the YAML from the repository:$ fluxctl sync --k8s-fwd-ns flux
Once the
sync
command has run, you may check that the namespace has been created and that the NGINX deployment has been applied and deployed:$ kubectl get pods --all-namespaces
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.