Provisioning an S3 bucket with Crossplane

a man wearing a virtual reality headset
Reading Time: 3 minutes

Crossplane has been gaining popularity in recent times. Crossplane works well with Kubernetes in the frame. We can now manage the deployment of microservices in the k8s cluster and also the managed components of the cloud (cloud services) using a single tool. Moreover, you can configure the same deployment tool (like, Argocd) for the same.

Pre-requisites

AWS credentials

You will have to get the base64 encoded credentials. For example,

accesskey=AKIAZDGREVP3HOJRLOEU

secretkey=D868Rywx0weUaJB2k5R+nQfoxIcq4h7T3P6/GwBv

Create a secret

apiVersion: v1
kind: Secret
metadata:
name: aws-creds
namespace: crossplane-system
type: Opaque
data:  creds: $BASE64ENCODED_AWS_ACCOUNT_CREDS

Create aws-provider.yaml

apiVersion: pkg.crossplane.io/v1
kind: Provider
metadata:
name: provider-aws
spec:
package: crossplane/provider-aws:v0.24.1
controllerConfigRef:
name: aws-config

Create a provider-config.yaml

apiVersion: aws.crossplane.io/v1beta1
kind: ProviderConfig
metadata:
name: default
spec:
credentials:
source: Secret
secretRef:
namespace: crossplane-system
name: aws-creds  
key: creds

Create a Controller-Config.yaml

apiVersion: pkg.crossplane.io/v1alpha1
kind: ControllerConfig
metadata:
name: aws-config
annotations:
eks.amazonaws.com/role-arn: arn:aws:iam::894897474192:role/crossplane-role
spec:
podSecurityContext:
fsGroup: 2000

Create a snippet for an s3 bucket in a bucket.yaml file.

apiVersion: s3.aws.crossplane.io/v1beta1
kind: Bucket
metadata:
name: knoldus-crossplane-bucket
namespace: crossplane-system
spec:
forProvider:
acl: private
locationConstraint: us-east-1
versioningConfiguration:
status: Enabled
providerConfigRef:
name: default

Apply the aws-provider.yaml and providerConfig.yaml

Describe this bucket to know the details.

Viewing from AWS console

You can view the same thing in the console.

Destroy the infrastructure:

Written by 

Vidushi Bansal is a Software Consultant [Devops] at Knoldus Inc. She is passionate about learning and exploring new technologies.

Discover more from Knoldus Blogs

Subscribe now to keep reading and get access to the full archive.

Continue reading