Last active
July 20, 2022 09:57
-
-
Save vfarcic/9e8c8a78d669c84a803aac2d5446127c 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/9e8c8a78d669c84a803aac2d5446127c | |
###################################################################### | |
# Monitor and Manage Cost Of Kubernetes Clusters And Cloud Resources # | |
# https://youtu.be/GpChs_4exxQ # | |
###################################################################### | |
# Additional Info: | |
# - Kubecost: https://kubecost.com | |
# - Cost-Aware Kubernetes Cluster Autoscaling With Cast AI: https://youtu.be/r2VS8DV1Lpk | |
# - Kustomize - How to Simplify Kubernetes Configuration Management: https://youtu.be/Twtbg6LFnAg | |
######### | |
# Setup # | |
######### | |
# Create a Kubernetes cluster | |
# Using AWS EKS for the demo, but it can be any other Kubernetes cluster with Ingress. | |
# Please note that some of the benefits are reserved for clusters running in AWS, Azure, or GCP. | |
# Replace `[...]` with the external IP of the Ingress service | |
export KUBECOST_HOST=kubecost.$INGRESS_HOST.nip.io | |
git clone https://github.com/vfarcic/kubecost-demo | |
cd kubecost-demo | |
# Open https://www.kubecost.com/install#show-instructions and copy the token (we'll use slightly diffrerent commands than those in the instructions). | |
# Replace `[...]` with the token | |
export KUBECOST_TOKEN=[...] | |
helm repo add kubecost \ | |
https://kubecost.github.io/cost-analyzer | |
helm repo update | |
helm upgrade --install \ | |
kubecost kubecost/cost-analyzer \ | |
--namespace kubecost \ | |
--create-namespace \ | |
--set kubecostToken=$KUBECOST_TOKEN \ | |
--wait | |
kubectl create namespace production | |
kubectl --namespace production apply \ | |
--kustomize app/overlays/production | |
###################### | |
# Exploring KubeCost # | |
###################### | |
kubectl --namespace kubecost \ | |
port-forward \ | |
deployment/kubecost-cost-analyzer \ | |
9090 & | |
# Open `http://localhost:9090` in a browser | |
kubectl --namespace production get pods | |
# Open `app/base/deployment.yaml` in an editor | |
# Set `spec.template.spec.containers[0].resources.requests.cpu` to `10m` | |
# Set `spec.template.spec.containers[0].resources.requests.memory` to `20Mi` | |
# Set `spec.template.spec.containers[0].resources.limits.cpu` to `50m` | |
# Set `spec.template.spec.containers[0].resources.limits.memory` to `100Mi` | |
kubectl --namespace production apply \ | |
--kustomize app/overlays/production | |
kubectl --namespace production get pods | |
# Open https://docs.kubecost.com/getting-started#cloud-integration | |
########### | |
# Destroy # | |
########### | |
pkill kubectl | |
cp orig/deployment.yaml app/base/. | |
# Reset of destroy the Kubernetes cluster |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment