Skip to content

Instantly share code, notes, and snippets.

@mhausenblas
Last active September 16, 2018 05:22
Show Gist options
  • Save mhausenblas/a340958ad4583e4cc92aca7175adde7e to your computer and use it in GitHub Desktop.
Save mhausenblas/a340958ad4583e4cc92aca7175adde7e to your computer and use it in GitHub Desktop.
VPA demo

VPA demo

Based on the official docs and the Banzai Cloud blog post by Toader Sebastian.

Prerequisites

Environment:

$ minishift version
minishift v1.21.0+a8c8b37

$ kubectl version --short
Client Version: v1.9.1
Server Version: v1.9.1+a0ce1bc657

$ minishift start --cpus=4 --memory=4GB
$ oc login -u system:admin

Install VPA

Get VPA bits and set it up:

$ git clone https://github.com/kubernetes/autoscaler.git
$ cd autoscaler/vertical-pod-autoscaler
$ ./hack/vpa-up.sh

Expect now to see the following:

$ kubectl get po -n kube-system
NAME                                        READY     STATUS    RESTARTS   AGE
vpa-admission-controller-6b758d8678-9kddd   1/1       Running   0          55s
vpa-recommender-5dfc7669f7-m44vg            1/1       Running   0          58s
vpa-updater-5d596b7897-gm9zx                1/1       Running   0          58s

$ kubectl get crd
NAME                                                      AGE
verticalpodautoscalercheckpoints.poc.autoscaling.k8s.io   1m
verticalpodautoscalers.poc.autoscaling.k8s.io             1m

Install Prometheus

Note: Prometheus must be deployed into the monitoring namespace with a service named prometheus pointing to it. Using Prometheus for OpenShift standalone as the basis.

$ oc new-project monitoring
$ oc create secret generic prom --from-file=prometheus/prometheus.yml
$ oc process -f prometheus/app.yaml | oc apply -f -

Test and use VPA

$ oc new-project vpa-demo
$ kubectl apply -f test/app.yaml
$ kubectl apply -f test/vpa.yaml
global:
scrape_interval: 5s
evaluation_interval: 5s
scrape_configs:
- job_name: 'kubernetes-nodes'
scheme: https
tls_config:
ca_file: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
kubernetes_sd_configs:
- role: node
relabel_configs:
- action: labelmap
regex: __meta_kubernetes_node_label_(.+)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment