Cost optimization

GKE

.https://cloud.google.com/solutions/best-practices-for-running-cost-effective-kubernetes-applications-on-gke

Disable non-prod add-ons in kubernetes

# Disable Horizontal Pod Autoscaling
gcloud container clusters update <cluster-name> \
  --update-addons=HorizontalPodAutoscaling=DISABLED

# Disable Kube DNS
kubectl scale --replicas=0 kube-dns-autoscaler \
  --namespace=kube-system

# Limit Kube DNS scaling
kubectl scale --replicas=0 deployment/kube-dns-autoscaler \
  --namespace=kube-system

kubectl scale --replicas=1 deployment/kube-dns \
  --namespace=kube-system
Pod Disruption Budget

Multitenant clusters

  • Utilize multiple namespaces to group & isolate teams or workloads in a GKE cluster

  • Role-based access control

  • Kubernetes resource quotas

  • Configure monitoring dashboards to view resource usage by namespace

Bin packing

.https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/

  • Make sure the workload fit well inside the machine size

  • We can create multiple node pools and use either nodeSelector or NodeAffinity to select which node your pod must run

GKE autoscaling strategies

Lab: https://www.qwiklabs.com/focuses/15636?parent=catalog

Flow
Scalability dimensions

Configuring pod disruptions - https://kubernetes.io/docs/tasks/run-application/configure-pdb/

Optimizing virtual machine choices

.https://cloud.google.com/solutions/best-practices-for-running-cost-effective-kubernetes-applications-on-gke#choose_the_right_machine_type

GKE workload optimization

Modes of operation of Kubernetes

Logs

exclusion rules

As the metric server needs to run somewhere, as with each new cluster update the metrics server gets updated and adds to lag in functioning of autoscaling. For this release, it is better to own the metric deployment configuration:

Use kpt for configuration with Anthos.

Last updated

Was this helpful?