使用 helm 安裝 istio。最新版本:1.9.0html
curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash
echo "source <(helm completion bash)" >> ~/.bash_profilesource !$
若是提示 WARNING: Kubernetes configuration file is group-readable. This is insecure. Location: /root/.kube/config
,執行 chmod 600 /root/.kube/config
。git
helm version version.BuildInfo{Version:"v3.5.2", GitCommit:"167aac70832d3a384f65f9745335e9fb40169dc2", GitTreeState:"dirty", GoVersion:"go1.15.7"}
curl -L https://istio.io/downloadIstio | sh -cd istio-1.9.0export PATH=$PWD/bin:$PATH #將 istioctl 加入環境變量
若是 helm 部署入站或出站網關 charts 時報錯:Readiness probe failed: HTTP probe failed with statuscode: 503
,能夠註釋掉 readinessProbe
。github
vim manifests/charts/gateways/istio-ingress/templates/deployment.yaml #註釋掉 readinessProbe# readinessProbe:# failureThreshold: 30# httpGet:# path: /healthz/ready# port: 15021# scheme: HTTP# initialDelaySeconds: 1# periodSeconds: 2# successThreshold: 1# timeoutSeconds: 1
vim manifests/charts/gateways/istio-egress/templates/deployment.yaml #註釋掉 readinessProbe# readinessProbe:# failureThreshold: 30# httpGet:# path: /healthz/ready# port: 15021# scheme: HTTP# initialDelaySeconds: 1# periodSeconds: 2# successThreshold: 1# timeoutSeconds: 1
default chart 配置將安全的第三方令牌映射到服務帳戶令牌, 此令牌將被 istio 代理用於認證 istio 控制平面。繼續安裝下面 chart 以前,須要用下面 步驟 驗證:在集羣中,第三方令牌是否啓用。 若是還沒有啓用第三方令牌,應該將參數 --set global.jwtPolicy=first-party-jwt
添加到 helm 安裝命令中。 若是設置 jwtPolicy
時出了問題,各種 Pod,好比關聯到 istiod、網關的 Pod、 以及被注入 Envoy 代理的工做負載的 Pod 等,都會由於缺乏 istio-token 卷的緣由,而不能部署。docker
爲 istio 組件,建立命名空間 istio-system :vim
kubectl create namespace istio-system
安裝 istio base chart,它包含了 istio 控制平面用到的集羣範圍的資源:安全
helm install istio-base manifests/charts/base -n istio-system
安裝 istio discovery chart,它用於部署 istiod 服務:bash
helm install istiod manifests/charts/istio-control/istio-discovery \ --set global.hub="docker.io/istio" \ --set global.tag="1.9.0" \ --set global.jwtPolicy=first-party-jwt \ -n istio-system
安裝 istio 的入站網關 chart,它包含入站網關組件(可選項):app
helm install istio-ingress manifests/charts/gateways/istio-ingress \ --set global.hub="docker.io/istio" \ --set global.tag="1.9.0" \ --set global.jwtPolicy=first-party-jwt \ -n istio-system
安裝 Istio 的出站網關 chart,它包含了出站網關組件(可選項):curl
helm install istio-egress manifests/charts/gateways/istio-egress \ --set global.hub="docker.io/istio" \ --set global.tag="1.9.0" \ --set global.jwtPolicy=first-party-jwt \ -n istio-system
kubectl get pod -n istio-system NAME READY STATUS RESTARTS AGE istio-egressgateway-84d5f75579-7qxz8 1/1 Running 0 6s istio-ingressgateway-59fb598cc9-gb84h 1/1 Running 0 19s istiod-666444b865-77x5q 1/1 Running 0 16m
kubectl get crd | grep 'istio.io'authorizationpolicies.security.istio.io 2021-02-20T07:11:18Z destinationrules.networking.istio.io 2021-02-20T07:11:18Z envoyfilters.networking.istio.io 2021-02-20T07:11:18Z gateways.networking.istio.io 2021-02-20T07:11:18Z istiooperators.install.istio.io 2021-02-20T07:11:19Z peerauthentications.security.istio.io 2021-02-20T07:11:18Z requestauthentications.security.istio.io 2021-02-20T07:11:18Z serviceentries.networking.istio.io 2021-02-20T07:11:18Z sidecars.networking.istio.io 2021-02-20T07:11:18Z virtualservices.networking.istio.io 2021-02-20T07:11:18Z workloadentries.networking.istio.io 2021-02-20T07:11:18Z workloadgroups.networking.istio.io 2021-02-20T07:11:18Z
能夠用本身的安裝參數,覆蓋掉前面用到的 istio helm chart 的默認行爲, 而後按照 helm 升級流程來定製安裝你的 istio 網格系統。至於可用的配置項,能夠在 values.yaml
文件內找到, 此文件位於 istio 發行包的 manifests/charts
目錄中。ide
istio 不支持 跨版本升級。僅支持從 1.8 版本升級到 1.9 版本。若是使用的是舊版本,請先升級到 1.8 版本。
在集羣中升級 istio 以前,建議備份定製安裝配置文件,以備不時之需。
kubectl get crds | grep 'istio.io' | cut -f1-1 -d "." | \ xargs -n1 -I{} sh -c "kubectl get --all-namespaces -o yaml {}; echo ---" > $HOME/ISTIO_RESOURCE_BACKUP.yaml
恢復定製的配置文件:
kubectl apply -f $HOME/ISTIO_RESOURCE_BACKUP.yaml
使用 helm 的升級流程,在你的集羣中就地升級 istio:
此升級路徑僅支持 Istio 1.8+ 的版本。將用於覆蓋默認配置的值文件(values file)或自定義選項添加到下面的命令中, 以在 Helm 升級過程當中保留自定義配置。
升級 istio base chart:
helm upgrade istio-base manifests/charts/base -n istio-system
升級 istio discovery chart:
helm upgrade istiod manifests/charts/istio-control/istio-discovery \ --set global.hub="docker.io/istio" \ --set global.tag=<version_to_upgrade> \ -n istio-system
若是集羣中安裝了 istio 的入站或出站網關 charts,則升級它們(可選項):
helm upgrade istio-ingress manifests/charts/gateways/istio-ingress \ --set global.hub="docker.io/istio" \ --set global.tag=<version_to_upgrade>\ -n istio-system helm upgrade istio-egress manifests/charts/gateways/istio-egress \ --set global.hub="docker.io/istio" \ --set global.tag=<version_to_upgrade> \ -n istio-system
卸載前面安裝的 chart,以便卸載 istio 和它的各個組件。
helm ls -n istio-system
helm uninstall -n istio-system istio-ingress helm uninstall -n istio-system istio-egress
helm uninstall -n istio-system istiod
經過 helm 刪除 chart 並不會級聯刪除它安裝的定製資源定義(CRD)。
helm uninstall -n istio-system istio-base
kubectl delete namespace istio-system
永久刪除 CRD, 會刪除在集羣中建立的全部 istio 資源。用下面命令永久刪除集羣中安裝的 Istio CRD:
kubectl get crd | grep 'istio.io' | awk '{print $1}' | xargs -n1 kubectl delete crd