|
| 1 | +# Istio Sample Project - helloworld |
| 2 | + |
| 3 | +## Deploy Sample Apps, Ingress Gateway, and Destination Rules |
| 4 | +```sh |
| 5 | +# helloworld v1 & v2 App |
| 6 | +kubectl apply -f <(istioctl kube-inject --debug -f helloworld-app.yaml) |
| 7 | +# or if automatic injestion is enabled |
| 8 | +kubectl apply -f helloworld-app.yaml |
| 9 | + |
| 10 | +# Istio Destination Rules |
| 11 | +kubectl apply -f istio-destinationrule.yaml |
| 12 | + |
| 13 | +# Istio Ingress Gateway |
| 14 | +kubectl apply -f istio-gateway.yaml |
| 15 | +``` |
| 16 | + |
| 17 | +Get the URL of the ingress controller |
| 18 | +```sh |
| 19 | +GATEWAY_URL=$(kubectl get svc istio-ingressgateway -n istio-system -o 'jsonpath={.status.loadBalancer.ingress[0].ip}'):$(kubectl get svc istio-ingressgateway -n istio-system -n istio-system -o 'jsonpath={.spec.ports[0].targetPort}') |
| 20 | +echo $GATEWAY_URL |
| 21 | +``` |
| 22 | + |
| 23 | +## Configure Istio VirtualService to control traffic |
| 24 | + |
| 25 | +### Route 50% traffic to v1 & 50% to v2 version |
| 26 | +```sh |
| 27 | +kubectl apply -f istio-virtualservice-even.yaml |
| 28 | +``` |
| 29 | + |
| 30 | +Access Test: Request to Gateway (Ingest) |
| 31 | +```sh |
| 32 | +while true; do curl http://$GATEWAY_URL/hello; sleep 1; done |
| 33 | + |
| 34 | +Hello version: v2, instance: helloworld-green-6b8b6b674d-b5nbs |
| 35 | +Hello version: v1, instance: helloworld-blue-84c7b5cf84-5rttf |
| 36 | +Hello version: v2, instance: helloworld-green-6b8b6b674d-b5nbs |
| 37 | +Hello version: v2, instance: helloworld-green-6b8b6b674d-b5nbs |
| 38 | +Hello version: v1, instance: helloworld-blue-84c7b5cf84-5rttf |
| 39 | +Hello version: v1, instance: helloworld-blue-84c7b5cf84-5rttf |
| 40 | +``` |
| 41 | + |
| 42 | +### Route 10% traffic to v1 & 90% to v2 |
| 43 | +```sh |
| 44 | +kubectl apply -f istio-virtualservice-blue10-green90.yam |
| 45 | +``` |
| 46 | + |
| 47 | +Access Test: Request to Gateway (Ingest) |
| 48 | +```sh |
| 49 | +while true; do curl http://$GATEWAY_URL/hello; sleep 1; done |
| 50 | + |
| 51 | +Hello version: v2, instance: helloworld-green-6b8b6b674d-b5nbs |
| 52 | +Hello version: v1, instance: helloworld-blue-84c7b5cf84-5rttf |
| 53 | +Hello version: v2, instance: helloworld-green-6b8b6b674d-b5nbs |
| 54 | +Hello version: v2, instance: helloworld-green-6b8b6b674d-b5nbs |
| 55 | +Hello version: v2, instance: helloworld-green-6b8b6b674d-b5nbs |
| 56 | +Hello version: v2, instance: helloworld-green-6b8b6b674d-b5nbs |
| 57 | +Hello version: v2, instance: helloworld-green-6b8b6b674d-b5nbs |
| 58 | +Hello version: v2, instance: helloworld-green-6b8b6b674d-b5nbs |
| 59 | +.. |
| 60 | +``` |
| 61 | + |
| 62 | +### Route 100% traffic to v2 only when foo in Header is equal to bar |
| 63 | +```sh |
| 64 | +kubectl apply -f istio-virtualservice-conditional.yam |
| 65 | +``` |
| 66 | + |
| 67 | +Access Test: Request to Gateway (Ingest) |
| 68 | +```sh |
| 69 | +while true; do curl -H "foo: bar" http://$GATEWAY_URL/hello; sleep 1; done |
| 70 | + |
| 71 | +Hello version: v2, instance: helloworld-green-6b8b6b674d-b5nbs |
| 72 | +Hello version: v2, instance: helloworld-green-6b8b6b674d-b5nbs |
| 73 | +Hello version: v2, instance: helloworld-green-6b8b6b674d-b5nbs |
| 74 | +Hello version: v2, instance: helloworld-green-6b8b6b674d-b5nbs |
| 75 | +Hello version: v2, instance: helloworld-green-6b8b6b674d-b5nbs |
| 76 | +Hello version: v2, instance: helloworld-green-6b8b6b674d-b5nbs |
| 77 | +Hello version: v2, instance: helloworld-green-6b8b6b674d-b5nbs |
| 78 | +Hello version: v2, instance: helloworld-green-6b8b6b674d-b5nbs |
| 79 | +Hello version: v2, instance: helloworld-green-6b8b6b674d-b5nbs |
| 80 | +Hello version: v2, instance: helloworld-green-6b8b6b674d-b5nbs |
| 81 | +Hello version: v2, instance: helloworld-green-6b8b6b674d-b5nbs |
| 82 | +Hello version: v2, instance: helloworld-green-6b8b6b674d-b5nbs |
| 83 | +Hello version: v2, instance: helloworld-green-6b8b6b674d-b5nbs |
| 84 | +Hello version: v2, instance: helloworld-green-6b8b6b674d-b5nbs |
| 85 | +... |
| 86 | +``` |
| 87 | + |
| 88 | +## Delete Projects |
| 89 | +Delete all Virtual Services |
| 90 | +```sh |
| 91 | +$ kubectl get virtualservice |
| 92 | + |
| 93 | +NAME AGE |
| 94 | +bookinfo 1d |
| 95 | +helloworld 21m |
| 96 | + |
| 97 | +$ kubectl delete virtualservice helloworld |
| 98 | +``` |
| 99 | + |
| 100 | +Delete all Destination Rules |
| 101 | +```sh |
| 102 | +$ kubectl get destinationrule |
| 103 | + |
| 104 | +NAME AGE |
| 105 | +helloworld 48m |
| 106 | + |
| 107 | +$ kubectl delete destinationrule helloworld |
| 108 | +``` |
| 109 | +Delete all Ingress Gateway |
| 110 | +```sh |
| 111 | +$ kubectl get gateway |
| 112 | + |
| 113 | +NAME AGE |
| 114 | +bookinfo-gateway 1d |
| 115 | +helloworld-gateway 49m |
| 116 | + |
| 117 | +$ kubectl delete gateway helloworld-gateway |
| 118 | +``` |
| 119 | + |
| 120 | +Delete all deployments |
| 121 | +``` |
| 122 | +kubectl delete -f helloworld-v1.yaml |
| 123 | +kubectl delete -f helloworld-v2.yaml |
| 124 | +``` |
| 125 | + |
| 126 | +## Misc Istio Commands - istioctl |
| 127 | +Get all proxy status |
| 128 | +```sh |
| 129 | +$ istioctl proxy-status |
| 130 | + |
| 131 | +Stderr when execute [/usr/local/bin/pilot-discovery request GET /debug/syncz ]: gc 1 @0.011s 9%: 0.026+1.2+1.2 ms clock, 0.053+0.26/0.10/1.0+2.4 ms cpu, 4->4->2 MB, 5 MB goal, 2 P |
| 132 | +gc 2 @0.022s 11%: 0.007+1.3+1.2 ms clock, 0.014+0.15/0.36/1.1+2.4 ms cpu, 4->4->2 MB, 5 MB goal, 2 P |
| 133 | + |
| 134 | +PROXY CDS LDS EDS RDS PILOT VERSION |
| 135 | +details-v1-6764bbc7f7-sdc7m.default SYNCED SYNCED SYNCED (98%) SYNCED istio-pilot-864dc8c497-pmzl2 1.0.2 |
| 136 | +istio-egressgateway-7cf89fb4f7-g4flm.istio-system SYNCED SYNCED SYNCED (98%) NOT SENT istio-pilot-864dc8c497-pmzl2 1.0.2 |
| 137 | +istio-ingressgateway-6996d566d4-spxkz.istio-system SYNCED SYNCED SYNCED (98%) SYNCED istio-pilot-864dc8c497-pmzl2 1.0.2 |
| 138 | +productpage-v1-54b8b9f55-gthrr.default SYNCED SYNCED SYNCED (98%) SYNCED istio-pilot-864dc8c497-pmzl2 1.0.2 |
| 139 | +ratings-v1-7bc85949-vcnlw.default SYNCED SYNCED SYNCED (100%) SYNCED istio-pilot-864dc8c497-pmzl2 1.0.2 |
| 140 | +reviews-v1-fdbf674bb-ddw9w.default SYNCED SYNCED SYNCED (98%) SYNCED istio-pilot-864dc8c497-pmzl2 1.0.2 |
| 141 | +reviews-v2-5bdc5877d6-tjgmg.default SYNCED SYNCED SYNCED (100%) SYNCED istio-pilot-864dc8c497-pmzl2 1.0.2 |
| 142 | +reviews-v3-dd846cc78-9lldp.default SYNCED SYNCED SYNCED (98%) SYNCED istio-pilot-864dc8c497-pmzl2 1.0.2 |
| 143 | + |
| 144 | +``` |
0 commit comments