curl https://raw.githubusercontent.com/kubernetes/helm/master/scripts/get > get_helm.sh
chmod +x get_helm.sh
./get_helm.shkubectl apply -f tiller-rbac.yaml
helm init --service-account tiller
helm install stable/metrics-server --name metrics-server --version 2.0.4 --namespace metrics`
kubectl get apiservice v1beta1.metrics.k8s.io -o yamlkubectl run php-apache --image=k8s.gcr.io/hpa-example --requests=cpu=200m --expose --port=80
kubectl autoscale deployment php-apache --cpu-percent=50 --min=1 --max=10
kubectl get hpa
In a new terminal session:
kubectl run -i --tty load-generator --image=busybox /bin/sh
while true; do wget -q -O - http://php-apache; doneIn another terminal:
kubectl get hpa -w
Find autoscaling group using the AWS Management Console, noting its name.
Edit the ASG's min/max size to 2 and 8 nodes, respectively.
Edit cluster_autoscaler.yaml, replacing <AUTOSCALING GROUP NAME> with the ASG name you found in the console.
Optionally change the AWS_REGION to something other than us-east-1 if you are working in a different region.
Deploy the autoscaler:
kubectl apply -f cluster_autoscaler.yaml
Watch the logs:
kubectl logs -f deployment/cluster-autoscaler -n kube-system
Scale out:
kubectl apply -f nginx.yaml
kubectl get deployment/nginx-scaleout
kubectl scale --replicas=10 deployment/nginx-scaleoutDelete the cluster autoscaler and nginx deployments:
kubectl delete -f cluster_autoscaler.yaml
kubectl delete -f nginx.yamlDelete the horizontal pod autoscaler and load test
kubectl delete hpa,svc php-apache
kubectl delete deployment php-apache load-generatorkubectl delete -f deplyment.yaml