These exercises will guide you through deploying Helloweb and Greeter service and trying out different ways to manage traffic between those sevrices.
In this part you will deploy the Hello Web and a Greeter service v1 to the cluster. Once you've deployed it, you will create gateway and a virtual service to be able to access the Hello Web from outside.
-
Create the Hello Web deployment and service with Istio sidecar injected:
kubectl create -f helloweb.yaml
-
Verify the deployment by running
kubectl get deploy helloweb
:$ kubectl get deploy helloweb NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE helloweb 3 3 3 3 2m
-
Also run
kubectl get pods
to ensure there are 2 containers being created for each replica (one is the hello web, the second one is the Envoy proxy) -
Create the Greeter V1 deployment and service with Istio sidecar injected:
kubectl create -f greeter-v1.yaml
-
Verify the deployment by running
kubect get deploy greeter-service-v1
:$ kubectl get deploy greeter-service-v1 NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE greeter-service-v1 3 3 3 3 44s
We will use the Istio ingress gateway to access our service. Since you can't expose services through an external IP (i.e. the LoadBalancer service type), you will need to run a port forward command, that will forward all traffic from your computer (e.g. http://localhost:8080
) to the service running inside the cluster (istio-ingressgateway
)
Regardless, you still need to deploy a gateway and a virtual service.
- Deploy the gateway:
kubectl create -f gateway.yaml
- Deploy the Hello Web virtual service:
kubectl create -f helloweb-virtualservice.yaml
- Open a separate terminal window and run:
kubectl port-forward -n istio-system --address localhost service/istio-ingressgateway 8080:80
Note: you can also run the above command with
sudo
and expose the service onhttp://localhost
, but it doesn't make much difference - everything will work the same way.
- Now you can try and access the service at
http://localhost:8080
If you are continuing with the next exercise, you don't have to delete anything. If you are doing a different exercise, make sure you remove everything (you can leave the gateway as we won't change it).
kubectl delete -f helloweb.yaml
kubectl delete -f greeter-v1.yaml
kubectl delete -f helloweb-virtualservice.yaml
-
Make sure you have Hello web and Greeter service v1 and v2 deployed, with the corresponding virtual services (one for Hello web and another one for Greeter service). If you already have Hello web and greeter v1 deploy, only deploy the greeter service v2 and the greeter virtual service.
kubectl apply -f greeter-v2.yaml kubectl apply -f greeter-virtualservice.yaml
-
Deploy the destination rule where we define the version subsets (v1 and v2):
kubectl apply -f dest-rule.yaml
- Open http://localhost:8080 and refresh the page a couple of times - you should get different responses from the greeter service, because we haven't defined any traffic routing rules yet.
- Update the virtual service to route 30% of traffic to the v2 version and 70% to the v1 version of the Greeter service.
Hint: Look at the examples in greeter-virtualservice-all-v1.yaml
and greeter-virtualservice-all-v2.yaml
.
The v3 version of the greeter service uses an image named learnistio/greeter-service:3.0.0
. Create the v3 deployment, update the destination rule and the virtual service, so 10% of the traffic goes to v3, 40% goes to v2 and 50% goes to v1. Once you verified that works, route all traffic to v3 version.
- Deploy the virtual service that routes requests coming from Firefox to v2, and all other requests to v1:
kubectl apply -f greeter-virtualservice-v2-firefox.yaml
You can use the following
curl
command to 'fake' the requests from a Firefox browser:curl -H "User-Agent: Firefox" localhost:8080
- Update the virtual service to route all traffic with header
x-user: alpha
to v3 and traffic with headerx-user: beta
to v2, while all other traffic gets routed to v1.
Make sure you clean up the Hello web and Greeter service deployments, virtual services, and destination rules before continuing. You can use kubectl delete -f [filename.yaml]
to delete all resources that were defined in the filename.yaml
.
We will deploy a Movie Web frontend that tries to access and talk to an external API (themoviedb.org).
-
Get the API from http://themoviedb.org (detailed instructions are here) and update the
movieweb.yaml
(replace the value <API_KEY_HERE> with an actual API KEY) -
Deploy the Movie Web + virtual service
kubectl create -f movieweb.yaml kubectl create -f movieweb-virtualservice.yaml
-
Create the service entry that allows access to themoviedb.org:
kubectl create -f movieweb-serviceentry.yaml
kubectl delete -f movieweb.yaml
kubectl delete -f movieweb-virtualservice.yaml
kubectl delete -f movieweb-serviceentry.yaml