Skip to content

Instantly share code, notes, and snippets.

@vfarcic
Last active March 2, 2023 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save vfarcic/17b9c1f01baa4064e1e7633b03f4e5b8 to your computer and use it in GitHub Desktop.
Save vfarcic/17b9c1f01baa4064e1e7633b03f4e5b8 to your computer and use it in GitHub Desktop.
# Source: https://gist.github.com/17b9c1f01baa4064e1e7633b03f4e5b8
##########################################################
# Cost-Aware Kubernetes Cluster Autoscaling With Cast AI #
# https://youtu.be/r2VS8DV1Lpk #
##########################################################
# Additional Info:
# - https://cast.ai
# - How To Auto-Scale Kubernetes Clusters With Karpenter: https://youtu.be/C-2v7HT-uSA
#########
# Setup #
#########
# Create an AWS EKS, GCP GKE, Azure AKS, or AWS KOPS cluster
# Do NOT use cluster autoscaler
git clone https://github.com/vfarcic/cast-demo
cd cast-demo
helm repo add prometheus \
https://prometheus-community.github.io/helm-charts
helm repo update
helm upgrade --install \
prometheus prometheus/prometheus \
--namespace monitoring \
--create-namespace \
--wait
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 create namespace production
kubectl --namespace production apply \
--kustomize kustomize/overlays/production
############################################################
# Exploring Cast AI Kubernetes Autoscaling And Rebalancing #
############################################################
# Open https://cast.ai in a browser
# Open kustomize/base/deployment.yaml in an editor.
# Add the following entries:
# `scheduling.cast.ai/spot: "true"` to `spec.template.spec.nodeSelector`
# `- key: scheduling.cast.ai/spot` and `operator: Exists` to `spec.template.spec.tolerations`
# Change `spec.replicas: 1` to `spec.replicas: 20`
kubectl --namespace production apply \
--kustomize kustomize/overlays/production
###########
# Destroy #
###########
cp orig/deployment.yaml kustomize/base/.
# Disconnect the cluster from Cast AI (that will delete the nodes created by it)
# Destroy the cluster
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment