
In this lab, we will implement a true GitOps workflow. GitOps is a paradigm for managing cloud-native applications where a Git repository is the single source of truth for both application code and infrastructure configuration.
This creates a powerful, automated loop: git push -> build & test -> publish image -> update config -> deploy to kubernetes.
This lab requires a running K3s cluster managed by Rancher, as configured in a previous lab
We will use GitHub for our CI process. We will use Git Repository, GitHub Actions to build the images and GitHub Packages to store the images.
Navigate to https://github.com/bfritscher/guestbook-gitops and click the Fork button to create a copy in your own GitHub account.
git clone your forked repository to your local machine.
You now need to replace several placeholder values in the repository files. Use your code editor's "Find and Replace in Files" feature.
your-username/guestbook-gitops and replace with: your-github-username/guestbook-gitops.your-email@he-arc.ch and replace with: your actual email address.host from gb-heg.duckdns.org to a new DNS name you control (e.g., guestbook-username.duckdns.org, you configured in a previous lab). Point this new DNS record to your k3s-server-1 IP address.Commit the changes and push them to your repository's main branch.
In your GitHub repository, click the Actions tab. You will see a workflow running, triggered by your push.
Click on the workflow to see the steps: build, push to container registry, and update manifests.

Once it completes, go to your repository's main page. You will see a new commit authored by "github-actions[bot]". This commit updated the image tag in the apps/guestbook/base/kustomization.yaml file.

On your repository's main page, find the Packages section on the right. Click on your new guestbook-gitops package.
This allows your Kubernetes cluster to pull the image without special credentials.
Now we'll install Argo CD into our cluster to handle the deployment part of the workflow.
Log in to your Rancher UI and navigate to your local cluster. Click the Kubectl Shell icon in the top-right corner.

Execute the following commands in the shell:
$ kubectl create namespace argocd $ kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
Argo CD creates an initial admin password in a secret. Use Rancher'UI to find the argocd-initial-admin-secret in the Rancher UI (Storage -> Secrets) and decode the value from there.
For security, the Argo CD UI is not exposed via an Ingress by default. We will use kubectl port-forward to access it from our local machine.
First, get the kubeconfig file for your cluster from the Rancher UI. Go to the local cluster dashboard, and in the top right, click the Kubeconfig button.
Save the file as local.yaml on your machine.

In a new terminal window on your local machine, run the following command. This command will run continuously.
$ kubectl --kubeconfig local.yaml port-forward svc/argocd-server -n argocd 8080:443
Open a browser and navigate to https://localhost:8080
Your browser will warn you about an invalid certificate. This is expected; click "Advanced" and proceed.
Username: admin
Password: The password you decoded in the previous step.
We will now tell Argo CD to monitor our forked repository. We'll use the "App of Apps" pattern, where one root Argo CD application manages the deployment of other applications.
In another new terminal, navigate to your cloned guestbook-gitops repository directory and apply the root app manifest. Keep the other proxy open and your browser window open to see the live changes.
$ kubectl --kubeconfig local.yaml apply -f argocd/app-of-apps.yaml
app-of-apps.guestbook.guestbook application. Argo CD will now show you the full tree of Kubernetes resources it is creating: Ingress, Services, and Deployments.Initially, the status will be OutOfSync, but Argo CD will quickly start synchronizing, and the status will change to Healthy and Synced.


You can switch views on the top right



Once everything is Healthy and Synced, open a browser and navigate to the DNS name you configured for the guestbook (guestbook-username.duckdns.org). You should see the application running.
Let's trigger the full CI/CD pipeline with a simple code change.
On your local machine, edit a file in the application source. For example, open src/templates/index.html.
h1 tag and change the text from Guestbook to My GitOps Guestbook.sign_here.png to sign_here_v2.pngCI (GitHub): Go to the Actions tab in your GitHub repository. A new workflow is running. Wait for it to build the new image and push the commit that updates the image tag.
CD (Argo CD): Go to the Argo CD UI. After a minute or two, Argo CD will detect that the HEAD of the main branch has changed. The guestbook application status will change to OutOfSync.
guestbook app to speed up detection if you're impatient.Once the application is Synced and Healthy again, refresh the guestbook page in your browser. You should see the new title, "My GitOps Guestbook". The entire update happened automatically after your git push.
Take a screenshot showing:
guestbook application in a Healthy and Synced state.My GitOps Guestbook.Upload the combined screenshot to complete the lab.
If you finished all your labs and want to really clean up, you can destroy the 3 VMs of your cluster in the switch engines console.