Recent days infrastructure automation is one of the most focused across most of the organization, why? One of the main reasons is cloud adaptation. So, with that they can manage the complete infrastructure on AWS, Azure, GCE and other cloud providers.
As there are more tools to manage the infrastructure, it will be hard to manage and learn more tools for your SRE or DevOps team. What if you can manage your infrastructure via Kubernetes? Yes, you read correct. In this case, you are going to love Crossplane for sure. Let’s see what is crossplane and how to use it, also will try to compare with Terraform.
What is Crossplane?
Crossplane is a tool created by Upbound which has been released in December of 2018. It has been accepted as an incubating project by the CNCF (Cloud Native Computing Foundation) in 2020.
Crossplane is developed as a Kubernetes add-on and extends any Kubernetes cluster with the flexibility to provision and manage cloud infrastructure, services, and applications. Crossplane uses Kubernetes-styled declarative and API-driven configuration and management of infrastructure, on-premises or within the cloud.
Crossplane can be considered as a Kubernetes add-on, which means that it makes use of custom resources to provide all of its functionality. There are 4 kinds of resources,
Benefits of Crossplane?
Here we have captured some benefits of using Crossplane in your infrastructure.
As we have seen, GitOps may be a future, with that considering and Using Crossplane, we able to implement GitOps best practices not only on the resources running within our Kubernetes cluster but also on our infrastructure resources. Thus, all of our resources are kept in Git. An agent running within our cluster will be provided with access to our Git repository to pull any changes within Git into our Cluster.
This allows us to set up advanced deployment mechanisms. Whenever any changes occur, whether on our resources or our infrastructure, the agent will recognize those changes and pull them automatically into our cluster; should they pass our checks.
Crossplane helps that we can declaratively manage our infrastructure. Meaning, we will specify within our code the properties of our infrastructure resources and Crossplane will ensure those are created as defined. The code, which details our infrastructure, is referred to as our desired state and the resources that Crossplane will create become the actual state of our infrastructure.
Once the resources have been created, Crossplane will continuously monitor the state of our infrastructure resources. Which makes sure the actual state same as desired state if not, Crossplane will then try to modify the actual state to match the desired state.
As Crossplane allows us to define our infrastructure resources in Git. One way maintaining our infrastructure in code makes it possible to easily can manage and share across. Instead of allowing someone to make any manual changes, we can just share the files with other teams to create a new Kubernetes Cluster or similar. As a result, our infrastructure can become more consistent across teams.
Shifting Left is the process of empowering developers by ensuring they are equipped to participate in infrastructure management and deployments. Instead of a dedicated DevOps team being responsible for creating and managing infrastructure in response to requests by the engineering teams, the engineering teams are provided with the necessary tools to address most common use cases themselves.
Using Crossplane, the DevOps team can define what type of infrastructure resources can be created and then provide the engineering team with examples of those resources. In contrast, if engineers have to have access to a cloud provider account to create resources, they may have less direction on which resources to create, how to create them, and how to manage the system most efficiently.
Thus, Crossplane makes it easier to empower engineering teams across the organization.
Installation of Crossplane
Let’s take a look at how Crossplane allows us to provision cloud resources.
Use Helm 3 to install the latest official stable release of Crossplane.
# kubectl create namespace crossplane # helm repo add crossplane-stable https://charts.crossplane.io/stable # helm repo update # helm install crossplane --namespace crossplane crossplane-stable/crossplane
Check Crossplane Status.
# helm list -n crossplane # kubectl get all -n crossplane
Install Crossplane Command Line Interface (CLI)
Use the following command to install crossplane CLI
# curl -sL https://raw.githubusercontent.com/crossplane/crossplane/release-1.5/install.sh | sh
Move executable to path
# mv kubectl-crossplane /usr/local/bin
Verify the installation.
# kubectl-crossplane --version
Terraform vs Crossplane
If you are more bound with terraform or spend more time on learning it, you can ask, why should I use Crossplane, as I can manage everything with Terraform. Well, that’s valid question, as both the tools are doing the same at last, provision infrastructure as a code. Still, there is too long to go with cloud, as we are still on earlier stage on cloud, the future may be very huge. So, it is important with pick the best one or two and see where we can use which one. So, Let’s understand by analyzing a few key differences between these tools.