GitOpsify Cloud Infrastructure with Crossplane and Flux
In this article we are going to learn how to automate the provisioning of cloud resources via Crossplane and combine it with GitOps practices.
You will most benefit from this blog if you are a Platform or DevOps Engineer, Infrastructure Architect or Operations Specialist.
If you are new to GitOps, read more about it in my blog GitOps with Kubernetes
Let's set the stage by imagining following context. We are working as a part of a Platform Team in a large organization. Our goal is to help Development Teams to onboard get up to speed with using our Cloud Infrastructure. Here are a few base requirements:
- Platform Team doesn't have resources to deal with every request individually, so there must be a very high degree of automation
- Company policy is to adopt the principle of least privilege. We should expose the cloud resources only when needed with the lowest permissions necessary.
- Developers are not interested in managing cloud, they should only consume cloud resources without even needing to login to a cloud console.
- New Teams should get their own set of cloud resources when on-boarding to the Platform.
- It should be easy to provision new cloud resources on demand.
Initial Architecture
The requirements lead us to an initial architecture proposal with following high level solution strategy.
- create template repositories for various types of workloads (using Backstage Software Templates would be helpful)
- once a new Team is on boarded and creates first repository from a template, it will trigger a CI pipeline and deploy common infrastructure components by adding the repository as Source to Flux infrastructure repo
- once a Team wants to create more cloud infrastructure, they can place the Crossplane claim YAMLs in the designated folder in their repository
- adjustments to this process are easily implemented using Crossplane Compositions
In real world scenario we would manage Crossplane also using Flux, but for demo purposes we are focusing only on the application level.
The developer experience should be similar to this:
Tools and Implementation
Knowing the requirements and initial architecture, we can start selecting the tools. For our example, the tools we will use are Flux and Crossplane.
We are going to use Flux as a GitOps engine, but the same could be achieved with ArgoCD or Rancher Fleet.
Let's look at the architecture and use cases that both tools support.