Service mesh exercises using Istio and Kubernetes
ISTIO
related stuff can be found in devops/istio
directory.
- Install custom resource definitions for Istio
kubectl apply -f devops/istio/crds.yaml
- Create namespace for Istio
kubectl create namespace istio-system
- Install Istio
kubectl apply -f devops/istio/istio.yaml
kubectl delete namespace istio-system
or
kubectl delete -f devops/istio
- Checking stats
kubectl exec -it $POD -c istio-proxy -- sh -c 'curl localhost:15000/stats' | grep httpbin | grep pending
Sample app is based on ISTIO example.
All services have been split into separate file can be found in devops/bookinfo
directory.
- Pre-requsite
a) enable side-car auto-injection for proper namespace
kubectl label namespace default istio-injection=enabled
- Make a deployment to
K8s
kubectl apply -f devops/bookinfo
- Check gateway info
kubectl get gateway
- Check destination rules
kubectl get destinationrules
kubectl delete -f devops/bookinfo
Description how to check your service address can be found here.
- Minikube
export INGRESS_HOST=$(minikube ip)
export INGRESS_PORT=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.spec.ports[?(@.name=="http2")].nodePort}')
export SECURE_INGRESS_PORT=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.spec.ports[?(@.name=="https")].nodePort}')
export GATEWAY_URL=$INGRESS_HOST:$INGRESS_PORT
and then
curl -o /dev/null -s -w "%{http_code}\n" http://${GATEWAY_URL}/productpage
- Create namespaces with auto-injection
kubectl create namespace foo
kubectl label namespace foo istio-injection=enabled
kubectl create namespace bar
kubectl label namespace bar istio-injection=enabled
kubectl create namespace legacy
- Check security rules
kubectl get policies.authentication.istio.io --all-namespaces
kubectl get meshpolicies.authentication.istio.io
kubectl get destinationrules.networking.istio.io --all-namespaces -o yaml | grep "host:"
Expected output:
host: istio-policy.istio-system.svc.cluster.local
host: istio-telemetry.istio-system.svc.cluster.local
- Checking certs
kubectl exec ${pod_id} -it -c istio-proxy -- ls /etc/certs