-
-
Save lmasiero/8c0714aaaafbf1a648668ce5f606189f to your computer and use it in GitHub Desktop.
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
# Source: https://gist.github.com/f0d35ef2260208b15ddd390007fdd552 | |
###################################################################### | |
# Production-Ready Kubernetes Clusters Using Crossplane Compositions # | |
# https://youtu.be/uMC2QQfMctg # | |
###################################################################### | |
# Referenced videos: | |
# - Crossplane - GitOps-based Infrastructure as Code through Kubernetes API: https://youtu.be/n8KjVmuHm7A | |
# - How To Shift Left Infrastructure Management Using Crossplane Composites: https://youtu.be/AtbS1u2j7po | |
################# | |
# Setup Cluster # | |
################# | |
# Watch https://youtu.be/BII6ZY2Rnlc if you are not familiar with GitHub CLI | |
gh repo fork vfarcic/devops-toolkit-crossplane \ | |
--clone | |
cd devops-toolkit-crossplane | |
# Using Rancher Desktop for the demo, but it can be any other Kubernetes cluster with Ingress | |
# If not using Rancher Desktop, replace `127.0.0.1` with the base host accessible through NGINX Ingress | |
export INGRESS_HOST=127.0.0.1 | |
kubectl create namespace crossplane-system | |
kubectl create namespace a-team | |
############# | |
# Setup AWS # | |
############# | |
# Replace `[...]` with your access key ID` | |
export AWS_ACCESS_KEY_ID=[...] | |
# Replace `[...]` with your secret access key | |
export AWS_SECRET_ACCESS_KEY=[...] | |
echo "[default] | |
aws_access_key_id = $AWS_ACCESS_KEY_ID | |
aws_secret_access_key = $AWS_SECRET_ACCESS_KEY | |
" >aws-creds.conf | |
kubectl --namespace crossplane-system \ | |
create secret generic aws-creds \ | |
--from-file creds=./aws-creds.conf | |
#################### | |
# Setup Crossplane # | |
#################### | |
helm repo add crossplane-stable \ | |
https://charts.crossplane.io/stable | |
helm repo update | |
helm upgrade --install \ | |
crossplane crossplane-stable/crossplane \ | |
--namespace crossplane-system \ | |
--create-namespace \ | |
--wait | |
kubectl apply \ | |
--filename crossplane-config/provider-aws.yaml | |
kubectl apply \ | |
--filename crossplane-config/provider-config-aws.yaml | |
# Please re-run the previous command if the output is `unable to recognize ...` | |
kubectl apply \ | |
--filename crossplane-config/provider-helm.yaml | |
kubectl apply \ | |
--filename crossplane-config/provider-kubernetes.yaml | |
kubectl apply \ | |
--filename crossplane-config/config-k8s.yaml | |
kubectl get pkgrev | |
# Wait until all packages are healthy | |
############################# | |
# Production-Ready Clusters # | |
############################# | |
cat examples/aws-eks.yaml | |
kubectl --namespace a-team apply \ | |
--filename examples/aws-eks.yaml | |
kubectl get managed,releases,objects | |
cat packages/k8s/definition.yaml | |
cat packages/k8s/eks.yaml | |
kubectl get managed,releases,objects | |
kubectl --namespace crossplane-system \ | |
get secret a-team-eks-cluster \ | |
--output jsonpath="{.data.kubeconfig}" \ | |
| base64 -d >kubeconfig.yaml | |
cat kubeconfig.yaml | |
export KUBECONFIG=$PWD/kubeconfig.yaml | |
kubectl get namespaces | |
# Show each of the tools installed | |
cat examples/aws-eks.yaml | |
########### | |
# Destroy # | |
########### | |
unset KUBECONFIG | |
kubectl --namespace a-team delete \ | |
--filename examples/aws-eks.yaml | |
kubectl get managed | |
# Repeat the previous command until all the managed resources are removed | |
# Destroy or reset the management cluster | |
# Destroy the GitOps repo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment