Last active
July 30, 2023 02:43
-
-
Save theipster/231a45ac2c17136f434ea2004eb1b678 to your computer and use it in GitHub Desktop.
Install custom built Crossplane provider on EKS (via CloudShell and ECR)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# In CloudShell... | |
# Checkout custom provider Git repo | |
CUSTOM_PROVIDER_PATH=... # repo-org/repo-path | |
CLONE_DIR=custom-provider | |
BRANCH_NAME=... | |
git clone https://github.com/$CUSTOM_PROVIDER_PATH.git --branch $BRANCH_NAME $CLONE_DIR | |
cd $CLONE_DIR | |
# Build custom provider from the directory containing the crossplane.yaml file | |
cd $(find . -name crossplane.yaml | xargs dirname) | |
kubectl crossplane build provider | |
git status -u | grep .xpkg | |
# Create ECR private repository | |
REGISTRY_ID=$(aws ecr create-repository --repository-name $CUSTOM_PROVIDER_PATH --query "repository.registryId" --output text) | |
# Login to ECR private registry | |
REGISTRY_PATH="$REGISTRY_ID.dkr.ecr.$AWS_REGION.amazonaws.com" | |
aws ecr get-login-password --region $AWS_REGION | docker login --username AWS --password-stdin $REGISTRY_PATH | |
# Publish custom provider to ECR | |
IMAGE_TAG=$(git rev-parse HEAD) | |
kubectl crossplane push provider $REGISTRY_PATH/$CUSTOM_PROVIDER_PATH:$IMAGE_TAG | |
# Install custom provider into cluster | |
# (Cluster pod execution role must | |
kubectl crossplane install provider $REGISTRY_PATH/$CUSTOM_PROVIDER_PATH:$IMAGE_TAG | |
kubectl get providers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# In CloudShell... | |
# Ensure EKS cluster is accessible | |
CLUSTER_NAME=... | |
aws eks update-kubeconfig --name $CLUSTER_NAME --region $AWS_REGION | |
kubectl get pods -A | |
# Ensure Crossplane is setup | |
install_helm | |
install_crossplane_on_cluster | |
install_crossplane_cli | |
# Install Docker for pushing the custom provider | |
install_docker |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
install_helm() { | |
# https://helm.sh/docs/intro/install/#from-script | |
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | |
chmod 700 get_helm.sh | |
./get_helm.sh | |
# Verify | |
helm --help | |
} | |
install_crossplane_on_cluster() { | |
# https://docs.crossplane.io/latest/software/install/ | |
helm repo add crossplane-stable https://charts.crossplane.io/stable | |
helm repo update | |
helm install crossplane \ | |
--namespace crossplane-system \ | |
--create-namespace crossplane-stable/crossplane | |
# Verify | |
kubectl get all -n crossplane-system | |
} | |
install_crossplane_cli() { | |
curl -sL https://raw.githubusercontent.com/crossplane/crossplane/master/install.sh | sh | |
sudo mv kubectl-crossplane /usr/local/bin | |
# Verify | |
kubectl crossplane --help | |
} | |
install_docker() { | |
# https://stackoverflow.com/a/76041922 | |
sudo yum update -y | |
yes | sudo amazon-linux-extras install docker | |
# Verify | |
docker --help | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment