Skip to content

Instantly share code, notes, and snippets.

@richardcase
Created June 26, 2023 14:44
Show Gist options
  • Select an option

  • Save richardcase/ec49f543f40022a7b464a314c668d4a0 to your computer and use it in GitHub Desktop.

Select an option

Save richardcase/ec49f543f40022a7b464a314c668d4a0 to your computer and use it in GitHub Desktop.
Crossplane EKS

Steps

  1. Create file with the AWS creds called aws-creds.conf
aws_access_key_id = <AWS_ACCESS_KEY_I>
aws_secret_access_key = <AWS_SECRET_ACCESS_KE>

Create the secret:

kubectl -n crossplane-system \
    create secret generic aws-creds \
    --from-file creds=./aws-creds.conf
  1. Add cross plane helm repo
helm repo add crossplane-stable https://charts.crossplane.io/stable
helm repo update
  1. Install crossplane
kubectl create namespace crossplane-system
helm upgrade --install \
    crossplane crossplane-stable/crossplane \
    --namespace crossplane-system \
    --create-namespace \
    --wait

and the cli

curl -sL https://raw.githubusercontent.com/crossplane/crossplane/master/install.sh | sh
  1. Create provider-aws.yaml with
apiVersion: pkg.crossplane.io/v1
kind: Provider
metadata:
  name: crossplane-provider-aws
spec:
  package: crossplane/provider-aws:v0.22.0
  1. Apply the provider
kubectl apply -f provider-aws.yaml
  1. Create provider-config-aws.yaml with:
apiVersion: aws.crossplane.io/v1beta1
kind: ProviderConfig
metadata:
  name: default
spec:
  credentials:
    source: Secret
    secretRef:
      namespace: crossplane-system
      name: aws-creds
      key: creds
  1. Apply the provider config
kubectl apply -f provider-aws.yaml
  1. Create provider-helm.yaml:
apiVersion: pkg.crossplane.io/v1
kind: Provider
metadata:
  name: crossplane-provider-helm
spec:
  package: crossplane/provider-helm:v0.9.0
  1. Apply the provider config
kubectl apply -f provider-helm.yaml
  1. Create provider-k8s.yaml:
apiVersion: pkg.crossplane.io/v1
kind: Provider
metadata:
  name: crossplane-provider-kubernetes
spec:
  package: crossplane/provider-kubernetes:main
  1. Apply provider:
kubectl apply -f provider-k8s.yaml
  1. APply XRD, composiste etc from OCI registry. Create config-k8s.yaml:

Based on this repo: https://github.com/cem-altuner/crossplane-prod-ready-eks/tree/master/packages/k8s

apiVersion: pkg.crossplane.io/v1
kind: Configuration
metadata:
  name: crossplane-k8s
spec:
  package: cemaltuner/crossplane-k8s:v0.2.14
  1. Apply the config:
kubectl apply -f config.k8s.yaml
  1. Check the status of the providers:
kubectl get pkgrev
  1. Create namespace for a team:
kubectl create namespace team-a
  1. Create a ClusterClaim for team-a to create an EKS cluster. Create aws-eks.yaml:
apiVersion: prodready.cluster/v1alpha1
kind: ClusterClaim
metadata:
  name: team-a-eks
  labels:
    cluster-owner: cem
spec:
  id: team-a-eks
  compositionSelector:
    matchLabels:
      provider: aws
      cluster: eks
  parameters:
    nodeSize: small
    minNodeCount: 1
    version: "1.25"
  1. Apply cluster definitions:
kubectl -n team-a apply -f aws-eks.yaml
  1. Wait for the ClusterClaim to be Ready
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment