按照官网的步骤已经装好了k8s集群,一个主节点,两个node节点
然后在网络好的情况下安装了istio
[root@istio-master istio-1.6.8]# istioctl version client version: 1.6.8 control plane version: 1.6.8 data plane version: 1.6.8 (3 proxies)
命名空间已经创建完毕
[root@istio-master istio-1.6.8]# kubectl get ns NAME STATUS AGE default Active 46h istio-system Active 24h kube-node-lease Active 46h kube-public Active 46h kube-system Active 46h
istio的组件也已经安装好
[root@istio-master istio-1.6.8]# kubectl get po -n istio-system NAME READY STATUS RESTARTS AGE grafana-b54bb57b9-g5l22 1/1 Running 3 18h istio-egressgateway-7447bd847b-25f9q 1/1 Running 3 18h istio-ingressgateway-59c788fd4f-b584h 1/1 Running 3 18h istio-tracing-9dd6c4f7c-l7qg5 1/1 Running 3 18h istiod-54d84dc79c-46lnj 1/1 Running 3 18h kiali-d45468dc4-2nlbm 1/1 Running 3 18h prometheus-79fb649b4d-vxlvp 2/2 Running 6 18h
按照步骤下载demo
istioctl install --set profile=demo -y
对默认的default 命名空间允许自动注入
kubectl label namespace default istio-injection=enabled
安装bookinfo应用
kubectl apply -f samples/bookinfo/platform/kube/bookinfo.yaml
查看istio-system下面的服务
[root@istio-master istio-1.6.8]# kubectl get services
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
details ClusterIP 10.98.20.95 <none> 9080/TCP 12h
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 47h
productpage ClusterIP 10.101.178.151 <none> 9080/TCP 12h
ratings ClusterIP 10.111.150.158 <none> 9080/TCP 12h
reviews ClusterIP 10.103.216.244 <none> 9080/TCP 12h
也没有问题
但是默认命名空间下没有创建pod
[root@istio-master istio-1.6.8]# kubectl get po No resources found in default namespace.
肯定是自动注入sidecar失败了,甚至连pod 都创建失败了,探索原因
查看bookinfo 创建应用的pod报错原因
[root@istio-master istio-1.6.8]# kubectl describe deployment productpage
已经找到对应的pod
执行语句查看pod报错原因
[root@istio-master istio-1.6.8]# kubectl describe replicaset productpage-v1-6987489c74
Warning FailedCreate 124m (x3 over 12h) replicaset-controller Error creating: Internal error occurred: failed calling webhook "sidecar-injector.istio.io": Post https://istiod.istio-system.svc:443/inject?timeout=30s: context deadline exceeded (Client.Timeout exceeded while awaiting headers) Warning FailedCreate 107m (x15 over 12h) replicaset-controller Error creating: Internal error occurred: failed calling webhook "sidecar-injector.istio.io": Post https://istiod.istio-system.svc:443/inject?timeout=30s: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers) Warning FailedCreate 72m (x9 over 12h) replicaset-controller Error creating: Internal error occurred: failed calling webhook "sidecar-injector.istio.io": Post https://istiod.istio-system.svc:443/inject?timeout=30s: context deadline exceeded Warning FailedCreate 50m (x2 over 54m) replicaset-controller Error creating: Internal error occurred: failed calling webhook "sidecar-injector.istio.io": Post https://istiod.istio-system.svc:443/inject?timeout=30s: context deadline exceeded (Client.Timeout exceeded while awaiting headers) Warning FailedCreate 33m (x10 over 53m) replicaset-controller Error creating: Internal error occurred: failed calling webhook "sidecar-injector.istio.io": Post https://istiod.istio-system.svc:443/inject?timeout=30s: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers) Warning FailedCreate 5m1s (x8 over 53m) replicaset-controller Error creating: Internal error occurred: failed calling webhook "sidecar-injector.istio.io": Post https://istiod.istio-system.svc:443/inject?timeout=30s: context deadline exceeded
看报错信息提示
failed calling webhook "sidecar-injector.istio.io"
这个组件连接失败
几乎找遍了istio官网没找到答案, 也看到网络上好几个小伙伴出现了这个问题也没有解决。
上官网,Istio / Sidecar Injection Problems没有一个描述是符合的。github issue也没有提到要安装metrics-server
。
就去安装metics-server
[root@istio-master istio-1.6.8]# kubectl top pods Error from server (NotFound): the server could not find the requested resource (get services http:heapster:)
上面信息证明没有安装metics-server
按照 下面两个博客进行安装,
https://www.cnblogs.com/lfl17718347843/p/14283796.html
https://blog.51cto.com/u_14783669/2521159
但是k8s.gcr.io/metrics-server/metrics-server 这个镜像不可用,又重新在网上新找一个 v0.4.1 版本的镜像 部署到node2节点 这才成功
再次走上面的逻辑进行sidecar进行自动注入
首先删除之前的pod
samples/bookinfo/platform/kube/cleanup.sh
清理过后重新走
kubectl apply -f samples/bookinfo/platform/kube/bookinfo.yaml
结果完美解决自动注入问题
[root@istio-master istio-1.6.8]# kubectl get pods NAME READY STATUS RESTARTS AGE details-v1-558b8b4b76-2dh4d 2/2 Running 0 2m41s productpage-v1-6987489c74-9nnbc 2/2 Running 0 2m40s ratings-v1-7dc98c7588-vrszj 2/2 Running 0 2m40s reviews-v1-7f99cc4496-cd7w7 2/2 Running 0 2m40s reviews-v2-7d79d5bd5d-xzl4k 2/2 Running 0 2m41s reviews-v3-7dbcdcbc56-8ndvh 2/2 Running 0 2m41s