Deploy Kubernetes Resources using Terraform
Streamline Kubernetes with Terraform! Learn when and why to use it, benefits, and step-by-step setup for efficient, consistent deployments.
Deploy AWS resources using Crossplane. Step-by-step guide to configure the AWS provider and create a S3 bucket.
In this article we will be talking about Crossplane as an Infrastructure as Code (IaC) tool that is running on Kubernetes, why should we use it and how you configure AWS provider to start creating resources, we will be going through a full step by step example for you to be able to create your first resource with Crossplane
I had some discussions with engineers that had some trouble to get started with Crossplane, it may be a little less straightforward than a well established tool like Terraform, some documentation isn’t precise for different use cases and providers and even ChatGPT’s code doesn’t seem to work at times. And here I am saving the day to make your life easier by giving you a step by step guide where you install and configure everything and deploy your first AWS resource using Crossplane.
There are certain use cases where Crossplane provides very powerful capabilities being able to create both applications and cloud resources, those can be used for ephemeral environments for example or for having a SaaS company provide full environments that could be self created by a tenant. Those environments could be created by just applying a Kubernetes manifest which is much simpler than starting to run traditional IaC plan and apply commands.
Link to the Github Repository: https://github.com/MeteorOps/crossplane-aws-provider-bootstrap.git
creds
filecrossplane-provider-conf
filecrossplane-provider-bootstrap
filebucket-definitions
& bucket-crd
filesComposition
resource relies on the CompositeResourceDefinition
.bucket-example
file
Get your AWS IAM User (not an SSO user as it requires a token to work) access keys and fill them in the credentials file
Add the Helm repository from which the Crossplane Helm Charts will be fetched
Deploy Crossplane on your Kubernetes cluster in a new namespace named crossplane-system
Then, you should see 2 pods: crossplane & crossplane-rbac-manager
Insert your AWS credentials to the creds file and run the following from the same folder:
You should see the aws-credentials secret:
Creating a Crossplane AWS Provider requires creating a bunch of resources: ServiceAccount, DeploymentRuntimeConfig, Provider, ClusterRole & ClusterRoleBindings, and ProviderConfig
We divided the resources creation into 2 phases:
crossplane-provider-bootstrap.yaml:
crossplane-provider-conf.yaml
:The reason for dividing it into 2 phases is that the creation of the ProviderConfig fails if we attempt to create it before the first set of Provider resources and dependencies is ready.
You should see something like this:
It might take 1-2 minutes to become Healthy.
When we installed the AWS Provider, it was installed with some Crossplane CRDs of the AWS Provider.
One of those CRDs is bucket
.
Now we can check if the bucket was created by running kubectl get bucket
against our Kubernetes cluster
We’ll start by deleting the S3 Bucket Crossplane resource in Kubernetes, which will end up deleting the resource in AWS.
Eventually, if we used kind
to spin up a local Kubernetes cluster, we’ll terminate the cluster to keep our workstation nice and clean.