Exercise 11.1: Service Mesh
{ curl -sL run.linkerd.io/install | sh export PATH=$PATH:/root/.linkerd2/bin echo "export PATH=$PATH:/root/.linkerd2/bin" >> $HOME/.bashrc linkerd check --pre linkerd install --crds | kubectl apply -f - linkerd install | kubectl apply -f - linkerd check linkerd viz install --set dashboard.enforcedHostRegexp=" " | kubectl apply -f - linkerd check linkerd viz check --wait 1m0s }{ linkerd viz dashboard & }kubectl patch svc web --patch '{"spec":{"type":"NodePort"}}' -n linkerd-vizkubectl get svc web -n linkerd-vizecho "$(curl -s ifconfig.io):$(kubectl -n linkerd-viz get svc web -o=jsonpath='{.spec.ports[?(@.port==8084)].nodePort}')"cat <<EOF | kubectl apply -f - apiVersion: v1 kind: Namespace metadata: name: accounting --- apiVersion: apps/v1 kind: Deployment metadata: name: nginx-one labels: app: nginx-one namespace: accounting spec: selector: matchLabels: app: nginx-one replicas: 1 template: metadata: labels: app: nginx-one spec: containers: - image: nginx:1.20.1 name: nginx ports: - containerPort: 80 protocol: TCP --- apiVersion: v1 kind: Service metadata: name: nginx-one namespace: accounting spec: type: NodePort selector: app: nginx-one ports: - port: 80 EOFkubectl -n accounting get deploy nginx-one -o yaml | \ linkerd inject - | kubectl apply -f -kubectl get pod -n accountingkubectl get svc nginx-one -n accountingwatch -n 0.1 curl SERVICE_CLUSTER_IPwatch -n 0.1 curl \ $(kubectl get svc nginx-one -o=jsonpath='{.spec.clusterIP}' -n accounting)kubectl -n accounting scale deploy nginx-one --replicas=5watch -n 0.1 curl SERVICE_CLUSTER_IPwatch -n 0.1 curl \ $(kubectl get svc nginx-one -o=jsonpath='{.spec.clusterIP}' -n accounting)kubectl delete ns accounting
Last updated