Istio 三分鐘就入坑 佈署篇

Share on:

Create GKE

 1gcloud beta container --project "istio-playground-239810" clusters create "istio-playground" \
 2  --zone "asia-east1-b" \
 3  --username "admin" \
 4  --cluster-version "1.11.8-gke.6" \
 5  --machine-type "n1-standard-2" \
 6  --image-type "COS" \
 7  --disk-type "pd-standard" \
 8  --disk-size "100" \
 9  --preemptible \
10  --num-nodes "1" \
11  --enable-cloud-logging \
12  --enable-cloud-monitoring \
13  --no-enable-ip-alias \
14  --addons HorizontalPodAutoscaling,HttpLoadBalancing,KubernetesDashboard,Istio \
15  --istio-config auth=MTLS_PERMISSIVE \
16  --no-enable-autoupgrade \
17  --enable-autorepair

Take a Peek

 1$ kubectl get namespaces
 2
 3NAME           STATUS    AGE
 4default        Active    2m
 5istio-system   Active    1m
 6kube-public    Active    2m
 7kube-system    Active    2m
 8
 9$ kubectl get po -n istio-system
10NAME                                      READY     STATUS      RESTARTS   AGE
11istio-citadel-7f6f77cd7b-nxfbf            1/1       Running     0          3m
12istio-cleanup-secrets-h454m               0/1       Completed   0          3m
13istio-egressgateway-7c56db84cc-nlrwq      1/1       Running     0          3m
14istio-galley-6c747bdb4f-45jrp             1/1       Running     0          3m
15istio-ingressgateway-6ff68cf95d-tlkq4     1/1       Running     0          3m
16istio-pilot-8ff66f8c4-q9chz               2/2       Running     0          3m
17istio-policy-69b78b7d6-c8pld              2/2       Running     0          3m
18istio-sidecar-injector-558996c897-hr6q4   1/1       Running     0          3m
19istio-telemetry-f96459fb-5cbpg            2/2       Running     0          3m
20promsd-ff878d44b-hv8nh                    2/2       Running     1          3m

Deploy app

1kubectl label namespace default istio-injection=enabled

Bookinfo Application

1kubectl apply -f https://raw.githubusercontent.com/istio/istio/release-1.1/samples/bookinfo/platform/kube/bookinfo.yaml
2
3kubectl get pods
4kubectl get services

Gateway

1kubectl apply -f https://raw.githubusercontent.com/istio/istio/release-1.1/samples/bookinfo/networking/bookinfo-gateway.yaml
2
3kubectl get gateways
4
5kubectl get svc istio-ingressgateway -n istio-system

Go to ingress public ip

1export INGRESS_HOST=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
2export INGRESS_PORT=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.spec.ports[?(@.name=="http2")].port}')
3export SECURE_INGRESS_PORT=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.spec.ports[?(@.name=="https")].port}')
4
5curl -v ${INGRESS_HOST}:{$INGRESS_PORT}/productpage
6
7404 Not Found

Apply destination rules

1kubectl apply -f https://raw.githubusercontent.com/istio/istio/release-1.1/samples/bookinfo/networking/destination-rule-all.yaml
2
3curl -v ${INGRESS_HOST}:{$INGRESS_PORT}/productpage

Brief review

1kubectl get virtualservices
2kubectl get destinationrules
3kubectl get gateways

Istio Tasks

https://istio.io/docs/tasks/traffic-management/