Skip to content

Instantly share code, notes, and snippets.

@vfarcic
Last active October 14, 2022 15:25
Show Gist options
  • Save vfarcic/57689b4095d9c7825baef3c2aec201ea to your computer and use it in GitHub Desktop.
Save vfarcic/57689b4095d9c7825baef3c2aec201ea to your computer and use it in GitHub Desktop.
# Source: https://gist.github.com/57689b4095d9c7825baef3c2aec201ea
#######################################################################
# How To Manage Kubernetes Applications Using Crossplane Compositions #
# https://youtu.be/eIQpGXUGEow #
#######################################################################
# Referenced videos:
# - Production-Ready Kubernetes Clusters Using Crossplane Compositions: https://youtu.be/uMC2QQfMctg
# - How To Shift Left Infrastructure Management Using Crossplane Compositions: https://youtu.be/AtbS1u2j7po
#########
# Setup #
#########
# 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 a-team
cat examples/app-frontend.yaml \
| sed -e "s@host: .*@host: devops-toolkit.$INGRESS_HOST.nip.io@g" \
| tee examples/app-frontend.yaml
####################
# 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-kubernetes-incluster.yaml
kubectl apply \
--filename crossplane-config/config-app.yaml
########
# Demo #
########
cat examples/app-frontend.yaml
# GitOps?
kubectl --namespace a-team apply \
--filename examples/app-frontend.yaml
kubectl --namespace a-team get appclaims
kubectl --namespace a-team \
get all,ingresses
echo "http://devops-toolkit.$INGRESS_HOST.nip.io"
# Open it in a browser
cat examples/app/backend.yaml
kubectl --namespace a-team apply \
--filename examples/app/backend.yaml
kubectl --namespace a-team \
get all,ingresses
# Change `spec.parameters.image` to `vfarcic/devops-toolkit-series:4.1.0` in `examples/app-frontend.yaml`
kubectl --namespace a-team apply \
--filename examples/app-frontend.yaml
cat crossplane-config/config-app.yaml
cat packages/app/definition.yaml
cat packages/app/frontend.yaml
cat packages/app/backend.yaml
# Those were simple examples!
###########
# Destroy #
###########
kubectl --namespace a-team delete \
--filename examples/app-frontend.yaml
kubectl --namespace a-team delete \
--filename examples/app/backend.yaml
kubectl get objects
kubectl --namespace a-team get all
cat examples/app-frontend.yaml \
| sed -e "s@image: .*@image: vfarcic/devops-toolkit-series:4.0.0@g" \
| tee examples/app-frontend.yaml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment