Skip to content

Commit

Permalink
Updated README.md to match changes in istio-proxy container template. F…
Browse files Browse the repository at this point in the history
  • Loading branch information
ymesika authored and frankbu committed May 18, 2018
1 parent 1aac4be commit b7c4255
Showing 1 changed file with 25 additions and 16 deletions.
41 changes: 25 additions & 16 deletions samples/helloworld/README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,26 @@
# 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](https://istio.io/blog/canary-deployments-using-istio.html).
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](https://istio.io/blog/2017/0.1-canary.html).

## Start the services

Note that kubernetes horizontal pod autosclalers only work if every container in the pods requests
cpu. Since the Istio proxy container added by kube-inject does not currently do it, we
need to edit the yaml before creating the deployment.
If you don't have [automatic sidecar injection](https://istio.io/docs/setup/kubernetes/sidecar-injection.html#automatic-sidecar-injection)
set in your cluster you will need to manually inject it to the services:

```bash
istioctl kube-inject -f helloworld.yaml -o helloworld-istio.yaml
```
Edit `helloworld-istio.yaml` to add the following to the proxy container
definition in both of the Deployment templates (helloworld-v1 and helloworld-v2)

```yaml
resources:
requests:
cpu: 100m
```
Note that Kubernetes [Horizontal Pod Autoscaler](https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/)
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.
Now create the deployment using the updated yaml file:

```bash
kubectl create -f helloworld-istio.yaml
Expand All @@ -37,6 +35,8 @@ curl http://$HELLOWORLD_URL/hello

## Autoscale the services

Enable autoscale on both services:

```bash
kubectl autoscale deployment helloworld-v1 --cpu-percent=50 --min=1 --max=10
kubectl autoscale deployment helloworld-v2 --cpu-percent=50 --min=1 --max=10
Expand All @@ -50,9 +50,18 @@ kubectl get hpa
./loadgen.sh & # run it twice to generate lots of load
```

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

```bash
kubectl get hpa
```

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

## Cleanup

```bash
kubectl delete -f helloworld.yaml
kubectl delete hpa --all
kubectl delete -f helloworld-istio.yaml
kubectl delete hpa helloworld-v1 helloworld-v2
```

0 comments on commit b7c4255

Please sign in to comment.