This project is a collection of hands-on labs for learning about cloud-native technologies, with a focus on Kubernetes and GitOps. The project is divided into several parts, each demonstrating a different aspect of modern application deployment and management.
The labs progress from basic Kubernetes cluster setup to advanced GitOps workflows with CI/CD integration. The technologies used include:
- Virtualization and Containerization: Vagrant, Docker
- Kubernetes: k3s, k3d
- Configuration Management: Kustomize
- CI/CD and GitOps: ArgoCD, GitLab
- Application Development: Django
The p1 directory contains a Vagrantfile and provisioning scripts to create a simple 2-node k3s cluster.
- Master Node:
abdel-ouS(192.168.56.110) - Worker Node:
abdel-ouSW(192.168.56.111)
- Navigate to the
p1directory:cd p1 - Start the Vagrant environment:
vagrant up
This will create and provision two virtual machines, a master and a worker, and automatically join the worker to the master's cluster.
The p2 directory demonstrates how to deploy multiple applications to a single-node k3s cluster. The provisioning script in this part automatically deploys three sample applications and sets up an Ingress to route traffic to them.
- app1: A "hello-kubernetes" application, accessible at
http://app1.com. - app2: Another "hello-kubernetes" application, accessible at
http://app2.com. - app3: A third "hello-kubernetes" application, which acts as the default backend for any other traffic.
- Navigate to the
p2directory:cd p2 - Start the Vagrant environment:
vagrant up
The p2 directory contains a volumes directory with index.html files for three nginx applications. However, the deployed applications use the paulbouwer/hello-kubernetes image, not nginx. This directory is not currently used by the Kubernetes configuration and appears to be a remnant of a previous or alternative implementation.
The p3 directory showcases a complete GitOps workflow for deploying a custom Django application.
- Local Development: The
simple-appdirectory contains the source code for a Django application and aDockerfileto containerize it. - Cluster Setup: The
scripts/start.shscript automates the creation of a k3d cluster. - ArgoCD Installation: The script then installs ArgoCD into the cluster.
- Application Deployment: Finally, it configures ArgoCD to watch a GitHub repository. ArgoCD automatically deploys the Django application based on the manifests in the
p3/app-confdirectory of the repository.
- Navigate to the
p3/scriptsdirectory:cd p3/scripts - Run the
start.shscript:./start.sh
This will set up the entire environment and deploy the application. The ArgoCD password will be printed to the console, and the ArgoCD UI will be accessible at localhost:8080. The Django application will be available at localhost:8888.
The bonus directory extends the GitOps workflow from p3 by introducing GitLab into the mix. This creates a fully self-contained platform for CI/CD and GitOps.
The bonus section automates the deployment of GitLab within the Kubernetes cluster. A script is then used to:
- Create a new user and an access token in GitLab.
- Create a new public repository.
- Push the application's Kubernetes manifests to the new repository.
ArgoCD is then configured to watch this new GitLab repository instead of the public GitHub repository. This means that the entire lifecycle of the application, from source code management to deployment, is handled within the local cluster.
The scripts in the bonus directory are designed to be used in a similar way to p3, but they require a running GitLab instance. The gitlab/gitlab.yaml file can be used to deploy GitLab to the cluster. The gitlab/script.sh is intended to be run within the GitLab pod to configure the repository.
This project provides a comprehensive, hands-on introduction to a variety of cloud-native tools and practices. By working through the different parts of this project, you can gain practical experience with Kubernetes, GitOps, and CI/CD, and learn how to build and deploy applications in a modern, automated fashion.