背景
服务网格小白
其实看官方文档写的特别清楚
1下载istio
官方是
curl -L https://istio.io/downloadIstio | sh -
但是我网络不行,所以直接去github下载
https://github.com/istio/istio/releases/tag/1.9.2
解压缩
目录结构很简单
添加环境变量
export PATH=/opt/istio-1.9.2/bin:$PATH
安装
istioctl install --set profile=demo -y
能看出来istio往k8s中加了pod和svc
部署bookinfo
kubectl apply -f <(istioctl kube-inject -f samples/bookinfo/platform/kube/bookinfo.yaml)
我尝试过使用
kubectl label namespace default istio-injection=enabled
kubectl apply -f samples/bookinfo/platform/kube/bookinfo.yaml
但是rc会报错
Warning FailedCreate 94s (x2 over 3m4s) 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 34s replicaset-controller Error creating: Internal error occurred: failed calling webhook "sidecar-injector.istio.io": Post https://istiod.istio-system.svc:443/inject?timeout=30s: dial tcp 10.109.17.99:443: i/o timeout
我也没找到解决办法,原谅我是个菜鸡,但核心肯定是自动注入没成功,所以我改成了上面的手动注入。
对外开放应用程序
kubectl apply -f samples/bookinfo/networking/bookinfo-gateway.yaml
确定入站 IP 和端口
这个地方我没有参考官网,官网那堆我现在还看不懂,慢慢后面学习吧,其实他的核心就是在网关做配置,我直接简单点先不配置网关规则,直接把ClusterIP改为nodeport
kubectl patch service istio-ingressgateway -n istio-system -p '{"spec":{"type":"NodePort"}}'
访问应用
http://ip:NodePort/productpage
查看仪表板
kubectl apply -f samples/addons
kubectl rollout status deployment/kiali -n istio-system
istioctl dashboard kiali
kubectl patch service kiali -n istio-system -p ‘{“spec”:{“type”:“NodePort”}}’
但是这里我报错了!
unable to recognize “kiali.yaml”: no matches for kind “MonitoringDashboard” in version “monitoring.kiali.io/v1alpha1”
最终解决方案是
https://blog.csdn.net/qq_41674452/article/details/113345163
添加一个crd,但是我看kiali.yaml里其实也有crd的配置了不知道为什么没成功!
反正自己执行了一次就ok了。
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: monitoringdashboards.monitoring.kiali.io
spec:
group: monitoring.kiali.io
names:
kind: MonitoringDashboard
listKind: MonitoringDashboardList
plural: monitoringdashboards
singular: monitoringdashboard
scope: Namespaced
versions:
- name: v1alpha1
served: true
storage: true
我个人理解crd!就好比k8s给你提供了张小姐(pod)、王小姐(deamonset)、李小姐(statefulset),但是你不满足你自己非要一个赵小姐(crd),k8s就给你一个接口你自己把赵小姐(crd)给造出来。但是你的赵小姐必须符合k8s的一些规则,你把赵小姐造出来了,赵小姐听你的k8s不帮你管着!你要单独雇了一个人小王(controller)专职在k8s那里帮你管着赵小姐,如果今晚你想让赵小姐干点什么,你就要给k8s的接口人(aipservice)打电话,“喂、今晚你让赵小姐在家等我!”,接口人(aipservice)“好的大爷”,他会把你的需求写到大屏幕上(etcd),小王(controller)是一条舔狗,天天盯着大屏幕生怕漏掉你的指令,突然看到了你的消息开开心心的告诉赵小姐,“小姐、姥爷让您今晚等着他!”,赵小姐听话的去。。。后面自己想。