GithubHelp home page GithubHelp logo

rodgermm / example-istio-hpa Goto Github PK

View Code? Open in Web Editor NEW

This project forked from devopsbox-io/example-istio-hpa

0.0 0.0 0.0 3 KB

Horizontal Pod autoscaling based on istio_requests_total metric

License: MIT License

example-istio-hpa's Introduction

Prerequisites

  • minikube (tested with v1.10.1, kubernetes v1.17.12)
  • kvm (required by minikube)
  • kubectl (tested with v1.17.12)
  • helm (tested with v3.2.1)
  • siege (tested with 4.0.4)
  • istioctl (tested with 1.7.2)

You can use any other kubernetes distribution or load testing tool which supports HTTP/1.1 (e.g. hey). You can also probably use different versions and different virtualization solution.

Steps

Start minikube

minikube start --driver=kvm2 --kubernetes-version v1.17.12 --memory=8192 --cpus=4 && minikube tunnel

It will ask for your sudo password!

Install Istio

In a separate terminal window:

istioctl install -y

Create namespaces

kubectl create namespace monitoring
kubectl create namespace dev

Enable Istio automatic sidecar injection

kubectl label namespace dev istio-injection=enabled

Deploy the sample application

kubectl -n dev apply -f sample-app-with-istio.yaml

Wait for your application deployment (probably few minutes):

export INGRESS_HOST=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
until curl -f http://$INGRESS_HOST; do echo "Waiting for the application to start..."; sleep 1; done

Install prometheus

helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo add stable https://kubernetes-charts.storage.googleapis.com/
helm repo update

helm -n monitoring install prometheus prometheus-community/prometheus

Install prometheus adapter

helm -n monitoring install prometheus-adapter prometheus-community/prometheus-adapter -f prometheus-adapter-values.yaml

Deploy horizontal Pod autoscaling configuration

kubectl -n dev apply -f hpa.yaml

Wait for the metric availability:

until kubectl -n dev describe hpa | grep "\"istio_requests_per_second\" on pods:" | grep -v "<unknown> / 10"; do echo "Waiting for the metric availability..."; sleep 1; done

Check how many Pods are running

watch kubectl -n dev get pod

Run the load test

In a separate terminal window run (adjust number of concurrent users and test time to your environment):

export INGRESS_HOST=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
siege -c 2 -t 5m http://$INGRESS_HOST

Check

After few minutes you should see more pods in window with watch kubectl -n dev get pod

You can also describe your horizontal pod autoscaler and see what is happening:

kubectl -n dev describe hpa httpbin

Cleanup

minikube delete

example-istio-hpa's People

Contributors

mraszplewicz avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.