-
-
Save oleoneto/3cabd590fbcbb9076fef796e1f9f7499 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/8adaf8fd6496bc99a466ba55834e1838 | |
############################################################### | |
# Metacontroller - Custom Kubernetes Controllers The Easy Way # | |
# https://youtu.be/3xkLYOpXy2U # | |
############################################################### | |
# Additional Info: | |
# - Metacontroller: https://metacontroller.github.io/metacontroller | |
# - DevOps MUST Build Internal Developer Platform (IDP): https://youtu.be/j5i00z3QXyU | |
# - Crossplane - GitOps-based Infrastructure as Code through Kubernetes API: https://youtu.be/n8KjVmuHm7A | |
# - Terraform vs. Pulumi vs. Crossplane - Infrastructure as Code (IaC) Tools Comparison: https://youtu.be/RaoKcJGchKM | |
# - How To Apply GitOps To Everything - Combining Argo CD And Crossplane: https://youtu.be/yrj4lmScKHQ | |
# - How To Shift Left Infrastructure Management Using Crossplane Compositions: https://youtu.be/AtbS1u2j7po | |
# - Cloud-Native Apps With Open Application Model (OAM) And KubeVela: https://youtu.be/2CBu6sOTtwk | |
# - Combining Argo CD (GitOps), Crossplane (Control Plane), And KubeVela (OAM): https://youtu.be/eEcgn_gU3SM | |
# - Should We Replace Docker Desktop With Rancher Desktop?: https://youtu.be/bYVfCp9dRTE | |
######### | |
# Setup # | |
######### | |
git clone https://github.com/vfarcic/metacontroller-demo | |
cd metacontroller-demo | |
# Create a Kubernetes cluster with Ingress controller enabled and set as default. | |
# This demo was tested on Rancher Desktop, but it should work with any Kubernetes cluster | |
# Please watch https://youtu.be/bYVfCp9dRTE if you are not familiar with Rancher Desktop | |
# Replace `127.0.0.1` with the Ingress Service IP if not using kind | |
export INGRESS_HOST=127.0.0.1 | |
kubectl apply \ | |
--kustomize https://github.com/metacontroller/metacontroller/manifests/production | |
kubectl create namespace production | |
kubectl create namespace controllers | |
# Install `yq` from https://github.com/mikefarah/yq if you do not have it already | |
yq --inplace \ | |
".spec.host = \"silly-demo.$INGRESS_HOST.nip.io\"" \ | |
my-app.yaml | |
yq --inplace \ | |
".spec.host = \"silly-demo.$INGRESS_HOST.nip.io\"" \ | |
my-app-1-0-7.yaml | |
################################################# | |
# Kubernetes Custom Resource Definitions (CRDs) # | |
################################################# | |
cat crds.yaml | |
kubectl apply --filename crds.yaml | |
kubectl get crds | |
kubectl explain apps --recursive | |
cat slack.yaml | |
kubectl apply --filename slack.yaml | |
kubectl get slacks | |
cat my-app.yaml | |
kubectl --namespace production apply \ | |
--filename my-app.yaml | |
kubectl --namespace production \ | |
get apps | |
kubectl --namespace production delete \ | |
--filename my-app.yaml | |
################################# | |
# Custom Kubernetes Controllers # | |
################################# | |
cat composite-controllers.yaml | |
kubectl apply \ | |
--filename composite-controllers.yaml | |
kubectl get compositecontrollers | |
cat main.go | |
cat app.py | |
kubectl --namespace controllers \ | |
create configmap app \ | |
--from-file=app.py | |
cat controllers.yaml | |
kubectl --namespace controllers apply \ | |
--filename controllers.yaml | |
############################ | |
# Metacontroller In Action # | |
############################ | |
cat my-app.yaml | |
kubectl --namespace production apply \ | |
--filename my-app.yaml | |
kubectl --namespace controllers logs \ | |
--selector app=slack-controller | |
kubectl --namespace production \ | |
get apps | |
kubectl --namespace production \ | |
get all,ingresses | |
diff my-app.yaml my-app-1-0-7.yaml | |
kubectl --namespace production apply \ | |
--filename my-app-1-0-7.yaml | |
kubectl --namespace production \ | |
get all,ingresses | |
curl "http://silly-demo.$INGRESS_HOST.nip.io" | |
kubectl --namespace production delete \ | |
--filename my-app-1-0-7.yaml | |
kubectl --namespace production \ | |
get all,ingresses | |
########### | |
# Destroy # | |
########### | |
# Destroy or reset the Kubernetes cluster | |
# ... or ... | |
kubectl delete \ | |
--filename composite-controllers.yaml | |
kubectl delete --filename slack.yaml | |
kubectl delete --filename crds.yaml | |
kubectl delete ns controllers | |
kubectl delete ns metacontroller | |
kubectl delete ns production |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment