1.安装
1.1下载安装包
helm repo add istio.io https://storage.googleapis.com/istio-release/releases/1.6.4/charts/
helm fetch ***/istio --version 1.6.3
自定义资源目录:
[root@k8s-ha-master01 home]# ls /home/istio/manifests/charts/
base global.yaml istio-control istiod-remote istio-policy README-helm3.md UPDATING-CHARTS.md
gateways istio-cni istiocoredns istio-operator istio-telemetry README.md
1.2安装
- 为 Istio 组件创建命名空间
istio-system
:
kubectl create namespace istio-system - 使用
kubectl apply
安装所有 Istio 的自定义资源 (CRDs) :(修改ingressgateway类型 loadbalancer该为NodePort)
helm template /home/istio/manifests/charts/base --set gateways.istio-ingressgateway.type=NodePort --name istio --namespace istio-system | kubectl apply -f -
或者
helm template /home/istio --set gateways.istio-ingressgateway.type=NodePort --name istio --namespace istio-system > istio.yaml
kubectl apply -f istio.yaml - 等待所有的 Istio CRD 创建完成:
cat istio.yaml | grep image //查看使用的镜像,导入
kubectl -n istio-system wait --for=condition=complete job --all
kubectl apply -f istio/templates/crds.yaml
1.3查看pod和service和deployment,确认安装完成
[k8s@k8s-ha-master01 samples]$ kubectl get pod -n istio-system
NAME READY STATUS RESTARTS AGE
istio-citadel-86c67595f6-lk22j 1/1 Running 0 6h37m
istio-cleanup-secrets-gc9bx 0/1 Completed 0 6h37m
istio-egressgateway-79b744756d-4sg7n 1/1 Running 0 6h37m
istio-galley-f79d5df65-mndjz 1/1 Running 1 6h37m
istio-ingressgateway-67bf85cc9-mp4rj 1/1 Running 0 6h37m
istio-pilot-5bb4687bd6-v8wbh 2/2 Running 0 6h37m
istio-policy-95d4b5cf4-4prlq 2/2 Running 0 6h37m
istio-sidecar-injector-66f4dd49bb-nf78n 1/1 Running 0 6h37m
istio-statsd-prom-bridge-f575fdb46-tl9rm 1/1 Running 0 6h37m
istio-telemetry-8595d7f88c-rlml7 2/2 Running 0 6h37m
prometheus-74f9669cd8-pf8kf 1/1 Running 1 6h37m
[k8s@k8s-ha-master01 samples]$ kubectl get svc -n istio-system
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
istio-citadel ClusterIP 10.110.8.187 <none> 8060/TCP,9093/TCP 6h37m
istio-egressgateway ClusterIP 10.97.84.132 <none> 80/TCP,443/TCP 6h37m
istio-galley ClusterIP 10.107.154.31 <none> 443/TCP,9093/TCP 6h37m
istio-ingressgateway NodePort 10.107.127.138 <none> 80:31380/TCP,443:31390/TCP,31400:31400/TCP,15011:30814/TCP,8060:32738/TCP,15030:30060/TCP,15031:31639/TCP 6h37m
istio-pilot ClusterIP 10.98.7.7 <none> 15010/TCP,15011/TCP,8080/TCP,9093/TCP 6h37m
istio-policy ClusterIP 10.107.89.86 <none> 9091/TCP,15004/TCP,9093/TCP 6h37m
istio-sidecar-injector ClusterIP 10.100.140.70 <none> 443/TCP 6h37m
istio-statsd-prom-bridge ClusterIP 10.106.118.233 <none> 9102/TCP,9125/UDP 6h37m
istio-telemetry ClusterIP 10.101.43.129 <none> 9091/TCP,15004/TCP,9093/TCP,42422/TCP 6h37m
prometheus ClusterIP 10.98.131.230 <none> 9090/TCP 6h37m
[k8s@k8s-ha-master01 samples]$ kubectl get deployment -n istio-system
NAME READY UP-TO-DATE AVAILABLE AGE
istio-citadel 1/1 1 1 6h41m
istio-egressgateway 1/1 1 1 6h41m
istio-galley 1/1 1 1 6h41m
istio-ingressgateway 1/1 1 1 6h41m
istio-pilot 1/1 1 1 6h41m
istio-policy 1/1 1 1 6h41m
istio-sidecar-injector 1/1 1 1 6h41m
istio-statsd-prom-bridge 1/1 1 1 6h41m
istio-telemetry 1/1 1 1 6h41m
prometheus 1/1 1 1 6h41m
2.Bookinfo测试
参考: https://istio.io/latest/zh/docs/setup/getting-started/
- 下载官方安装包(使用官方的测试用例)
curl -L https://istio.io/downloadIstio | sh - - 进入安装包
cd istio-1.6.3 - Istio 默认自动注入 Sidecar. 为 default 命名空间打上标签 istio-injection=enabled:
kubectl label namespace default istio-injection=enabled - 部署应用
cat samples/bookinfo/platform/kube/bookinfo.yaml | grep image //导入使用的镜像
kubectl apply -f samples/bookinfo/platform/kube/bookinfo.yaml[k8s@k8s-ha-master01 samples]$ kubectl get pod NAME READY STATUS RESTARTS AGE details-v1-7f6df6f54-v52kh 2/2 Running 0 6h44m productpage-v1-69886c8bcb-dffnk 2/2 Running 0 6h44m ratings-v1-6665bbd4db-c5qrq 2/2 Running 0 6h44m reviews-v1-7fd87d96bd-vgsl5 2/2 Running 0 6h44m reviews-v2-55d9bfb6d8-crws8 2/2 Running 0 6h44m reviews-v3-5776c54c64-svfvz 2/2 Running 0 6h44m [k8s@k8s-ha-master01 samples]$ kubectl get svc NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE details ClusterIP 10.107.79.184 <none> 9080/TCP 6h44m kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 50d productpage ClusterIP 10.105.47.93 <none> 9080/TCP 6h44m ratings ClusterIP 10.110.108.101 <none> 9080/TCP 6h44m reviews ClusterIP 10.98.161.24 <none> 9080/TCP 6h44m [k8s@k8s-ha-master01 samples]$ kubectl get deployment NAME READY UP-TO-DATE AVAILABLE AGE details-v1 1/1 1 1 6h44m productpage-v1 1/1 1 1 6h44m ratings-v1 1/1 1 1 6h44m reviews-v1 1/1 1 1 6h44m reviews-v2 1/1 1 1 6h44m reviews-v3 1/1 1 1 6h44m
-
确认 Bookinfo 应用是否正在运行,请在某个 Pod 中用
curl
命令对应用发送请求,例如ratings
:kubectl exec -it $(kubectl get pod -l app=ratings -o jsonpath='{.items[0].metadata.name}') -c ratings -- curl productpage:9080/productpage | grep -o "<title>.*</title>"
-
创建 Ingress 网关
kubectl apply -f samples/bookinfo/networking/bookinfo-gateway.yaml
kubectl get gateway -
查看效果,端口号查看 istio-ingressgateway
刷新
刷新