Files I produced during the "Service Mesh with Istio" classes of my Microservices Full Cycle 3.0 course.
istioctl install -y
kubectl apply -f https://github.com/istio/istio/raw/release-1.10/samples/addons/grafana.yaml
kubectl apply -f https://github.com/istio/istio/raw/release-1.10/samples/addons/jaeger.yaml
kubectl apply -f https://github.com/istio/istio/raw/release-1.10/samples/addons/kiali.yaml
kubectl apply -f https://github.com/istio/istio/raw/release-1.10/samples/addons/prometheus.yaml
istioctl dashboard kiali
while true
do
curl http://localhost:8000
sleep 0.5
done
kubectl apply -f https://raw.githubusercontent.com/istio/istio/release-1.10/samples/httpbin/sample-client/fortio-deploy.yaml
export FORTIO_POD=$(kubectl get pods -lapp=fortio -o 'jsonpath={.items[0].metadata.name}')
kubectl exec "$FORTIO_POD" -c fortio -- fortio load -c 2 -qps 0 -t 200s -loglevel Warning http://nginx-service:8000
kubectl apply -f consistent-hash.yaml
POD=$(kubectl get pods | grep nginx-a | head -n1 | cut -d' ' -f1)
kubectl exec -it $POD -- bash
# Then, inside the pod
curl --header "x-user: user1" http://nginx-service:8000
curl --header "x-user: user1" http://nginx-service:8000
curl --header "x-user: user1" http://nginx-service:8000
curl --header "x-user: user1" http://nginx-service:8000
curl --header "x-user: user1" http://nginx-service:8000
curl --header "x-user: user1" http://nginx-service:8000
curl --header "x-user: user1" http://nginx-service:8000
# Note that all requests will get the same response
curl --header "x-user: user2" http://nginx-service:8000
curl --header "x-user: user2" http://nginx-service:8000
curl --header "x-user: user2" http://nginx-service:8000
curl --header "x-user: user2" http://nginx-service:8000
curl --header "x-user: user2" http://nginx-service:8000
curl --header "x-user: user2" http://nginx-service:8000
curl --header "x-user: user2" http://nginx-service:8000
# Note that all requests will get the same response
curl --header "x-user: user3" http://nginx-service:8000
curl --header "x-user: user3" http://nginx-service:8000
curl --header "x-user: user3" http://nginx-service:8000
curl --header "x-user: user3" http://nginx-service:8000
curl --header "x-user: user3" http://nginx-service:8000
curl --header "x-user: user3" http://nginx-service:8000
curl --header "x-user: user3" http://nginx-service:8000
# Note that all requests will get the same response
kubectl apply -f fault-injection.yaml
If you're creating a cluster in the cloud, go to "Finally, you can:".
When I created my local cluster, I run:
k3d cluster create -p "8000:30000@loadbalancer" --agents 2
So, when I access localhost:8000 I'm redirected to the port 30000 in my cluster,
this way, I can access the LoadBalancer of deployment.yaml
.
But now, we wanna access localhost:8000 and get redirected to the istio-ingressgateway. First, open deployment.yaml
and edit the LoadBalancer nodePort to 30001 to let port 30000 free.
Now, run kubectl get svc -n istio-system
and discover the NodePort of istio-ingressgateway:
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S)
istio-ingressgateway LoadBalancer 10.43.31.68 <pending> 15021:30847/TCP,80:31784(<---- this one)/TCP
Then, edit the istio-ingressgateway service NodePort:
kubectl edit svc istio-ingressgateway -n istio-system
# Search for:
# - name: http2
# nodePort: 31784 # Change 31784 to 30000 and save
# port: 80
Finally, you can:
kubectl apply -f gateway.yaml
Just remember to add "a.fullcycle.com" and "b.fullcycle.com" to /etc/hosts and then:
kubectl apply -f gateway-subdomains.yaml