Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Pod autoscaling with custom-metrics

Pod autoscaling with custom-metrics

How can you use your custom-metrics that are in your monitoring system to scale your pods.

Mattias Gees

March 21, 2018
Tweet

More Decks by Mattias Gees

Other Decks in Programming

Transcript

  1. Mattias Gees • Cloud Engineer @skyscrapers • Avid runner •

    Likes to experiment github.com/mattiasgees twitter.com/mattiasgees blog.mattiasgees.be
  2. API

  3. Some history! • SIG Instrumentation • Tackled Heapster • Metrics-server

    (beta 1.8) • Annotations (1.2 - 1.5) • Blogposts Q1 2017 are outdated! • Autoscaler (1.6 - ...)
  4. Requirements • API aggregation layer • Resource Metrics API •

    Custom metrics API • kube-controller-manager • --horizontal-pod-autoscaler-use-rest-clients • --kubeconfig <path-to-kubeconfig> OR --master <ip- address-of-apiserver>
  5. Prometheus helm install coreos/prometheus-operator \ --name prometheus-operator \ --namespace monitoring

    helm install coreos/kube-prometheus \ --name kube-prometheus \ --namespace monitoring \ -f prometheus.yaml
  6. Prometheus-adapter • Create cert • Upload cert as secret kubectl

    -n custom-metrics create secret tls cm- adapter-serving-certs --cert=server.crt -- key=server-key.pem • Deploy prometheus-adapter kubectl apply -f manifests
  7. Test kubectl get --raw \ "/apis/custom.metrics.k8s.io/v1beta1/namespaces/default/ pods/*/http_requests" \ | jq

    kubectl get --raw \ "/apis/custom.metrics.k8s.io/v1beta1/namespaces/default/ service/sample-metrics-app/http_requests" \ | jq