本文針對於二進制部署的k8s安裝istio1.67版本
istio1.8.0
官網:https://istio.io/latest/docs/setup/getting-started/
沒有設置admin.conf的小伙伴請參考
https://www.cnblogs.com/Tempted/p/13469772.html
1、檢查k8s dns svc 啟動是否正常

istio pod 訪問不到svc錯誤,請檢查K8S 上dns服務是否正常
error citadelclient Failed to create certificate: rpc error: code = Unavailable desc = connection error: desc = "transport: Error while dialing dial tcp: lookup istiod.istio-system.svc on 10.254.0.2:53: read udp 172.30.1.57:52724->10.254.0.2:53: i/o timeout"
2、master 上需要部署一個node節點,並設置為不可調度
1,不可調度 kubectl cordon master kubectl uncordon master #取消 2,驅逐已經運行的業務容器 kubectl drain --ignore-daemonsets --delete-local-data master 3,如果想刪除node 節點,則進行這個步驟 kubectl delete node master

istio自動注入錯誤
Error creating: Internal error occurred: failed calling webhook "sidecar-injector.istio.io": Post https://istio-sidecar-injector.istio-system.svc:443/inject?timeout=30s: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
此錯誤是因為master節點訪問不了集群內部的Service(istio-sidecar-injector),導致自動注入失敗。
安裝istio
一、下載
官方地址:
https://preliminary.istio.io/latest/zh/docs/setup/getting-started/
github 下載地址
https://github.com/istio/istio/releases/
二、配置
[root@master ~]# tar -zxf istio-1.8.0-linux-amd64.tar.gz [root@master ~]# cd istio-1.8.0 添加istioctl 環境變量 [root@master ~]# vi ~/.bash_profile # .bash_profile # Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fi # User specific environment and startup programs PATH=$PATH:$HOME/bin PATH=$PATH:/root/istio-1.6.7/bin export PATH [root@master ~]# source ~/.bash_profile 添加istio自動補全工具 [root@master ~]# cp tools/istioctl.bash ~/.istioctl.bash [root@master ~]# source ~/.istioctl.bash
c-bash: _get_comp_words_by_ref: command not found 碰到這樣的錯誤解決方法:
yum install bash-completion -y source /usr/share/bash-completion/bash_completion source ~/.istioctl.bash
k8s 自動補全
source <(kubectl completion bash) echo "source <(kubectl completion bash)" >> ~/.bashrc #添加kubectl的k別名 vim ~/.bashrc alias k='kubectl' #tab命令只在使用完整的kubectl 命令起作用,使用別名k 時不起作用,修補: source <( kubectl completion bash | sed 's/kubectl/k/g' ) #寫入 .bashrc
三、安裝
以官方為主:https://preliminary.istio.io/latest/zh/docs/setup/getting-started/
1、安裝demo配置
istioctl install --set profile=demo 新
[root@master istio-1.8.0]# istioctl version client version: 1.8.0 control plane version: 1.8.0 data plane version: 1.8.0 (2 proxies)
[root@master istio-1.8.0]# kubectl get pods -n istio-system NAME READY STATUS RESTARTS AGE istio-egressgateway-75dbd877cb-fmk48 1/1 Running 0 10m istio-ingressgateway-756879c745-m5jzs 1/1 Running 0 5m4s istiod-6bf46fc8cc-shlcm 1/1 Running 0 5m10s
2、添加自動注入
kubectl create ns name
kubectl label namespace <namespace> istio-injection=enabled
kubectl apply -n <namespace> -f <your-app-spec>.yaml
一個自動注入yaml demo
apiVersion: apps/v1 kind: Deployment metadata: name: demo labels: app: demo spec: replicas: 1 selector: matchLabels: app: demo template: metadata: labels: app: demo spec: containers: - name: nginx image: nginx:1.14-alpine imagePullPolicy: IfNotPresent ports: - containerPort: 80
修改 istio ingress 為nodeport模式
kubectl patch service istio-ingressgateway -n istio-system -p '{"spec":{"type":"NodePort"}}'
3、插件安裝
istio 1.7版本后的插件都在 samples/addons/目錄下
安裝需要 kubectl apply -f samples/addons/
4、卸載
istioctl manifest generate --set profile=demo | kubectl delete --ignore-not-found=true -f -
