Part 1 - Getting Started with GitOps on ArgoCD
- Published on
- Authors
- Name
- Jon Ceanfaglione
Let's get started
Last week I posted about an annoucement that came out of Weaveworks that caught my attention, a best-of-both-worlds scenario where you can integrate GitOps tools ArgoCD and Flux using Flamingo. I want to walk through getting started with Flamingo, and ultimately some practical examples of GitOps with these tools. To do this however, we'll need to establish some basics (and eventually build up to some things not so basic). To start we'll focus on these two foundational elements:
- Kubernetes - We're going to need a Kubernetes cluster
- ArgoCD - We'll need an instance of ArgoCD running
Kubernetes
There are a number of great options out there for running Kubernetes on your development machines, but in my opinion, nothing is easier to get started with than K3D from Rancher. K3D is an easy way to run Rancher Lab’s minimal Kubernetes distribution, K3S. There a lot of great reasons to use K3S as your Kubernetes distribution, and in this case K3S is a perfect match for running Kubernetes on your local machine. One downside that people might point out is that it requires Docker. Docker has been under fire recently in the open source community for some decisions they've made regarding licensing of their tooling, but I think this is mostly a result of what happens when someone takes something away from you that you've been using for free and possibly taking for granted. Regardless of what people believe regarding those decisions, Docker offers a great developer experience if you're developing for or using containers; paying 10 bucks a month to use Docker Desktop is something I'll gladly continue to do.
If you have Docker and K3D installed, it's very easy to get started with a simple cluster. Note, you'll also need kubectl to interact with your environment once it's up and running.
All one has to do to create an evironment with K3D is run:
k3d cluster create mycluster
Once you've done that, you'll have an environment named "mycluster". You can run a command using k3d to see it:
k3d cluster list
You can now run some commands to see what your environment looks like:
kubectl get nodes
Of course, it's never truly that simple, and so I've created a bash library that is open source, and free to use that can help get you started quickly with a kubernetes environment on your development machine. You can find that over at GitHub. I hope you'll find it useful, and I'll be adding features to it over time that help us do things in a GitOps fashon. You can see it in action in below:
Figure 1. Create a K3S development environment.
ArgoCD
So now we've got a kubernetes environment, if we want to practice GitOps then we're going to need a tool like ArgoCD. ArgoCD will handle automating things for us using Git as our source of truth. We could just start deploying things out to the environment using command line tooling like kubectl or helm or whatever, but this isn't a very GitOps way of doing things. So, ArgoCD is the first thing we're going to install in our Kubernetes environment. We start with ArgoCD to enable these key principles of GitOps:
A system managed by GitOps must have its desired state expressed declaratively.
Desired state is stored in a way that enforces immutability, versioning and retains a complete version history.
Software agents automatically pull the desired state declarations from the source.
Software agents continuously observe actual system state and attempt to apply the desired state.
It's pretty easy to install ArgoCD in your Kubernetes cluster - you can install the latest version by running these commands:
kubectl create namespace argocd
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
If you're new to using Kubernetes, the first line creates a namespace which represents a sandbox of sorts, or landing zone for you to deploy things. The second line downloads a Kubernetes deployment manifest from the ArgoCD git repository and executes an apply action against your Kubernetes environment. A manifest describes all the resources necessary for your cluster to deploy whatever it is you want to run. This includes your own custom applications that you package as a container.
Once you've installed ArgoCD you'll be able to access it from your web browser:
Figure 2. ArgoCD browser interface.
Head over to the docs for ArgoCD if you want to learn more about configuration options and features.
If you want to skip ahead, you can also use the bash helper library to install ArgoCD in your local environment. It will install ArgoCD, export the initial password to the command window, and even give you the option of launching the ArgoCD web interface in a browser tab. You can see it in action as part of the environment "bootstrap" options:
Figure 3. Install ArgoCD in your development environment.
Wrap Up
If you made it this far, thanks for reading. So far, we've just covered the basics to get started with GitOps and what we can do with tools like ArgoCD. Next post, we'll dig a little deeper into next steps for ArgoCD and how we can get started with Flamingo and ArgoCD.
If the concept of Kubernetes and GitOps is new to you, I hope you found this worth your time, and will continue to read along. If you are experienced at GitOps and found this worthwhile, I appreciate the engagement and hope you'll continue to check in. Leave some feedback in the comments and let us know! Regardless of where you are on the spectrum of GitOps adoption, I'd love to know the sorts of things you'd like to see covered.