The GitOps Way to Run Your Kubernetes Homelab in 2025
Mischa van den Burg
26,883 views • 1 year ago Save 22 min 10 min read
Video Summary
GitOps is a methodology for managing infrastructure and applications through Git, emphasizing best practices for code delivery. This approach involves defining both infrastructure and application configurations as code, with automation handling updates and rollbacks. A key aspect is using Git as the single source of truth, meaning all changes and desired states are recorded and versioned in the repository.
This workflow is enabled by GitOps controllers, like Flux or Argo CD, which run within a Kubernetes cluster. These controllers continuously monitor the Git repository for changes and automatically apply them to the cluster, ensuring the actual state always matches the desired state defined in Git. This eliminates the need for direct access to the Kubernetes API server for deployments, enhancing security and collaboration through standard Git workflows like pull requests.
The benefits of GitOps include improved auditability, easier collaboration, enhanced security by reducing direct cluster access, and powerful automation capabilities for updates and rollbacks. While both Flux and Argo CD are capable, Flux is highlighted for its command-line focus, integration with Customizes, and its native adoption in Azure's AKS, making it a strong choice for learning GitOps principles and building a robust Kubernetes home lab.
Short Highlights
- GitOps is a set of best practices where the entire code delivery process is controlled via Git.
- It includes infrastructure and application definition as code, along with automation for updates and rollbacks.
- The GitOps controller (Flux or Argo CD) monitors a Git repository and applies changes to the Kubernetes cluster.
- Changes are made through Git pull requests, enabling collaboration and a historical record of all modifications.
- Flux CD is recommended for its command-line focus, integration with Customizes, and native Azure AKS integration.
Related Video Summary
Key Details
What is GitOps? [1:37]
- GitOps is defined as a set of best practices where the entire code delivery process is controlled via Git.
- This includes infrastructure and application definitions as code, coupled with automation for updates and rollbacks.
The core idea is to use Git as the central control mechanism for all code delivery processes, encompassing both infrastructure and applications.
GitOps is a set of best practices where the entire code delivery process is controlled via git including infrastructure and application definition as code and automation to complete updates and rollbacks.
How GitOps Works: The Reconciliation Loop [3:51]
- A GitOps controller (Flux or Argo CD) runs within the Kubernetes cluster.
- This controller continuously monitors a designated Git repository.
- It constantly checks for any necessary changes between the Git repository's state and the cluster's current state.
- This process is known as a Reconciliation Loop.
- The controller applies the configuration files from the Git repo to the Kubernetes cluster, ensuring synchronization.
- When a change is made in the Git repository, the controller implements it in the cluster.
- An example given is changing the storage size of a database cluster in a YAML file in Git; the controller detects this and applies the change.
- Instead of imperatively telling
kubectlto apply a file, GitOps defines a desired state in Git, which the controller then implements.
This describes the fundamental mechanism of GitOps, where a controller actively works to keep the cluster's state aligned with what's defined in Git.
The controller is constantly looking at the git repository and maybe let's uh give that a circle git repo so this controller is constantly looking at the git repository it's constantly looking do I need to change something do I need to change something do I need to change something and this is known as a Reconciliation Loop.
Benefits and Implications of GitOps [6:59]
- GitOps shifts the requirement from needing direct access to the Kubernetes cluster's API server to simply needing access to the Git repository.
- Git, designed for collaboration, allows for managing Kubernetes configurations through code.
- Changes can be implemented by creating and merging pull requests to the Git repository.
- An automation example is using a tool like Renovate to check for available updates for images running in the cluster.
- Merging a pull request that updates an image tag in the Git repository leads to the GitOps controller detecting this change and updating the cluster.
- This workflow avoids manual
kubectlapplication and instead relies on defining a desired state in Git. - This fundamental principle of GitOps allows for a managed and controlled deployment process.
The shift to Git as the primary interface for managing infrastructure offers significant advantages in terms of collaboration, security, and auditable changes.
now instead of needing access to the kubernetes cluster itself instead of needing access to the cube API server now all we need is access to the git repo and as you know git is of course created to collaborate on code basis.
Infrastructure and Application Definition as Code [13:26]
- GitOps involves defining both infrastructure resources and application deployments as code.
- Infrastructure includes components like monitoring tools, Ingress controllers, and database controllers.
- Application definition refers to the configuration of how applications run within the cluster.
- Both infrastructure and application configurations are managed within the Git repository.
- For example, a repository can contain directories for applications (like homepage, Linkedin) and for infrastructure (like controllers for certificate manager, CSI drivers, Ingress controllers).
This aspect highlights the comprehensive nature of GitOps, extending beyond just application code to encompass the entire operational environment.
on a kubernetes cluster there are several kinds of resources there is the infrastructure which is like your monitoring tooling your Ingress controller your database controller Etc that's what we call infrastructure so that is defined as code and application definition is defined as code.
Automation for Updates and Rollbacks [14:36]
- Automation is crucial for completing updates and enabling rollbacks.
- Tools like Renovate can automatically check for and suggest updates to image versions running in the cluster.
- This automation reduces the manual effort of tracking changelogs and applying updates.
- Users only need to merge the pull requests generated by the automation.
- If a change leads to problems, Git provides a history of commits, allowing for easy identification and reverting of problematic changes.
- This history provides a full record of what was changed, when, and by whom, enabling quick recovery.
- This Git-based history facilitates security, collaboration, and automation.
The ability to easily revert to previous stable states is a major advantage of the GitOps model.
code in automation to complete updates and roll backs now that is also important because if I now go here and I go to my code and then I go to my commits I you see I have almost a thousand commits to this repo but here we see we have merged this pool request but if this somehow was not right if I if this led to problems then here I have in G the history of what happened.
Key GitOps Principles [19:12]
- The entire system, including infrastructure and applications, is described declaratively in code.
- The canonical desired system state is versioned in Git, providing a history of all changes.
- Approved changes are automated and applied to the system.
- Software agents (GitOps controllers) ensure correctness and alert on divergence between the desired and actual states.
- The state of the cluster is always described in Git, not just the source code.
- The GitOps controller constantly matches the Git state with the cluster state, implementing any detected drift.
These principles form the foundation of the GitOps methodology, ensuring a reliable and manageable deployment process.
the key giops principles are the entire system infrastructure and applications is described declaratively so like I mentioned you describe it in code and flux handles it for you the canonical desired System state is verion in git we have the history we can check back which commits changed what changes approved are automated and applied to the system.
Git Repository Structure: Application Code vs. Manifests [20:22]
- The Git repository used for GitOps primarily contains Kubernetes manifests, not the actual application source code.
- Application source code resides in separate repositories.
- When application code changes, an automation process creates a new version of the Docker image.
- This new image version is then used to update the tag in the GitOps repository.
- The GitOps controller detects this tag update and deploys the new application version to the cluster.
- This separation allows development teams to manage their application code independently while still leveraging GitOps for deployment.
This distinction is crucial for understanding how GitOps orchestrates deployments, separating the "what" (configuration) from the "how" (application logic).
so one thing to note here is that this code it's not the actual application code it's not the actual source code of the application this is just the code for example if I show you my um Health API let's check out that one my health API and I'm going to explain this directory structure in the next module but my health API deployment this one this is just the deployment file that contains the Manifest of this application of how I want to run this in my kubernetes cluster.
GitOps Controllers: Flux CD vs. Argo CD [24:41]
- There are two main GitOps controllers: Flux CD and Argo CD.
- Both perform similar functions but have different approaches and features.
- Flux CD is favored for its command-line interface (CLI) and its encouragement of a GitOps-centric workflow.
- It has a less prominent UI, motivating users to interact more via the CLI, which is seen as a strength for learning GitOps principles.
- Argo CD features a rich UI that allows for many actions and has robust role-based access control (RBAC), making it suitable for team collaboration.
- However, the rich UI of Argo CD can be overwhelming for beginners and might lead to less hands-on CLI practice.
- Flux CD's integration with Customizes is another key advantage.
- Flux is adopted by large companies and is natively integrated into Azure's AKS managed GitOps offering.
The choice between Flux and Argo CD often comes down to preference for UI-driven versus CLI-driven workflows and specific integration needs.
basically there are two big players in this space there's flock CD and there's Argo CD CD standing for continuous deployment and um if you have been looking for jobs then you might have seen both of these uh featured in job descriptions I mean they they do the same job but they have some differences.
Advantages of Flux CD and Customizes [28:47]
- Flux CD heavily relies on Customizes for managing Kubernetes manifests.
- Customizes is a templating language for Kubernetes manifests, enabling declarative management.
- It allows users to define base manifests and then apply overlays or modifications for different environments (e.g., development, production).
- This integration forces users to learn and utilize Customizes, which is a valuable skill.
- While Argo CD can use Customizes, it often leads to reliance on Helm or other deployment tools, with Customizes being less frequently used in practice.
- Flux CD's mandatory use of Customizes makes it a strong choice for engineers aiming to master this powerful Kubernetes tool.
The deep integration of Customizes with Flux CD is presented as a significant benefit for learning and implementing advanced Kubernetes configuration management.
another reason why I like flux a lot is because the native AKs offering in azure so manage kubernetes service in Microsoft Azure they have a gitops integration which is using flux so if you are a Azure focused engineer who is going to be working with AKs then you will it is a really good move to have more understanding of flux.