Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Helloworld service

This sample runs two versions of a simple helloworld service that return their version and instance (hostname) when called. It's used to demonstrate canary deployments working in conjunction with autoscaling. See Canary deployments using Istio.

Start the services

If you don't have automatic sidecar injection set in your cluster you will need to manually inject it to the services:

istioctl kube-inject -f helloworld.yaml -o helloworld-istio.yaml

Note that Kubernetes Horizontal Pod Autoscaler only work if all containers in the pods requests cpu. In this sample the deployment containers within the helloworld.yaml are pre-defined with the request. The (manually/automatically) injected istio-proxy containers also have the requests cpu therefore making the helloworld ready for autoscaling.

Now create the deployment using the updated yaml file:

kubectl create -f helloworld-istio.yaml

Follow the instructions to set the INGRESS_HOST and INGRESS_PORT variables then confirm it's running using curl.

curl http://$GATEWAY_URL/hello

Autoscale the services

Enable autoscale on both services:

kubectl autoscale deployment helloworld-v1 --cpu-percent=50 --min=1 --max=10
kubectl autoscale deployment helloworld-v2 --cpu-percent=50 --min=1 --max=10
kubectl get hpa

Generate load

./loadgen.sh &
./loadgen.sh & # run it twice to generate lots of load

Wait for about 2min and check the number of replicas:

kubectl get hpa

If autoscaler is functioning correctly the REPLICAS column should have a value > 1.


kubectl delete -f helloworld-istio.yaml
kubectl delete hpa helloworld-v1 helloworld-v2