
引言
Istio作为service mesh控制面的实施标准,先部署起来。然而会有一个坑要注意,否则无法访问到页面。这个坑是个示例的bug,已被人提了issue,我也被坑了一把。
一、准备工作
1.安装Docker
通过命令行或者直接下载,由于网络原因我直接下载安装 ,下载地址:
- https://hub.docker.com/editions/community/docker-ce-desktop-mac
2.驱动安装
- curl-LOhttps://storage.googleapis.com/minikube/releases/latest/docker-machine-driver-hyperkit
- chmod+xdocker-machine-driver-hyperkit
- sudomvdocker-machine-driver-hyperkit/usr/local/bin/
- sudochownroot:wheel/usr/local/bin/docker-machine-driver-hyperkit
- sudochmodu+s/usr/local/bin/docker-machine-driver-hyperkit
3.安装minikube
- curl-Lominikubehttps://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64&&chmod+xminikube&&sudomvminikube/usr/local/bin/
验证版本
- $minikubeversion
- minikubeversion:v1.22.0
4.启动minikube
- $minikubestart Darwin10.15.7上的minikubev1.22.0 根据现有的配置文件使用docker驱动程序 Startingcontrolplanenodeminikubeinclusterminikube Pullingbaseimage... Updatingtherunningdocker"minikube"container... Thiscontainerishavingtroubleaccessinghttps://k8s.gcr.ioTopullnewexternalimages,youmayneedtoconfigureaproxy:https://minikube.sigs.k8s.io/docs/reference/networking/proxy/ 正在Docker20.10.7中准备Kubernetesv1.21.2… VerifyingKubernetescomponents...Usingimagegcr.io/k8s-minikube/storage-provisioner:v5 Enabledaddons:storage-provisioner,default-storageclass Done!kubectlisnowconfiguredtouse"minikube"clusterand"default"namespacebydefault
二、安装与部署
1.下载istio
还是直接下载安装包,当前最新版本为1.11.0
- https://github.com/istio/istio/releases/tag/1.11.0
2.设置环境变量
- vim~/.bash_profileexportPATH=$PATH:/Users/yongliang/istio/istio-1.11.0/binsource~/.bash_profile
3.安装istio
- $istioctlinstall--setprofile=demo-yIstiocoreinstalledIstiodinstalledEgressgatewaysinstalledIngressgatewaysinstalledInstallationcomplete
4.创建istio命名空间
- kubectlcreatenamespaceistio-system
5.设置自动注入envoy
- $kubectllabelnamespacedefaultistio-injection=enablednamespace/defaultlabeled
6.验证istio版本
- $istioctlversionclientversion:1.11.0controlplaneversion:1.11.0dataplaneversion:1.11.0(8proxies)
小结:输出可以看出安装的istio客户端版本、控制面板版本和数据面版本。
三、部署示例程序
1.部署示例
示例在安装目录sample目录下
- -rw-r--r--@1yongliangstaff1134881300:17LICENSE-rw-r--r--@1yongliangstaff586681300:17README.mddrwxr-x---@3yongliangstaff9681300:17bin-rw-r-----@1yongliangstaff85481300:17manifest.yamldrwxr-xr-x@5yongliangstaff16081300:17manifestsdrwxr-xr-x@21yongliangstaff67281300:17samplesdrwxr-xr-x@5yongliangstaff16081300:17tools
- $kubectlapply-fsamples/bookinfo/platform/kube/bookinfo.yamlservice/detailscreatedserviceaccount/bookinfo-detailscreateddeployment.apps/details-v1createdservice/ratingscreatedserviceaccount/bookinfo-ratingscreateddeployment.apps/ratings-v1createdservice/reviewscreatedserviceaccount/bookinfo-reviewscreateddeployment.apps/reviews-v1createddeployment.apps/reviews-v2createddeployment.apps/reviews-v3createdservice/productpagecreatedserviceaccount/bookinfo-productpagecreateddeployment.apps/productpage-v1created
2.服务启动情况
- $kubectlgetservicesNAMETYPECLUSTER-IPEXTERNAL-IPPORT(S)AGEdetailsClusterIP10.100.65.41<none>9080/TCP4d2hkubernetesClusterIP10.96.0.1<none>443/TCP4d4hproductpageClusterIP10.107.21.144<none>9080/TCP4d2hratingsClusterIP10.110.139.187<none>9080/TCP4d2hreviewsClusterIP10.106.238.130<none>9080/TCP4d2h
pods为Running状态
- $kubectlgetpodsNAMEREADYSTATUSRESTARTSAGEdetails-v1-79f774bdb9-bkrbp2/2Running44d2hproductpage-v1-6b746f74dc-2c55l2/2Running44d2hratings-v1-b6994bb9-7nvs22/2Running44d2hreviews-v1-545db77b95-mffvg2/2Running44d2hreviews-v2-7bf8c9648f-pmqw82/2Running44d2hreviews-v3-84779c7bbc-sztp82/2Running44d2h
3.把应用关联到istio网关
- $kubectlapply-fsamples/bookinfo/networking/bookinfo-gateway.yamlgateway.networking.istio.io/bookinfo-gatewaycreatedvirtualservice.networking.istio.io/bookinfocreated
4.分析istio配置信息
- $istioctlanalyze?Novalidationissuesfoundwhenanalyzingnamespace:default.
5.设置入站IP和端口
端口设置
- $exportINGRESS_PORT=$(kubectl-nistio-systemgetserviceistio-ingressgateway-ojsonpath='{.spec.ports[?(@.name=="http2")].nodePort}')$exportSECURE_INGRESS_PORT=$(kubectl-nistio-systemgetserviceistio-ingressgateway-ojsonpath='{.spec.ports[?(@.name=="https")].nodePort}')
打印出来看看
- $echo"$INGRESS_PORT"31688$echo"$SECURE_INGRESS_PORT"31908
设置入站IP
在官方提供的命令中是下面一段:
- $exportINGRESS_HOST=$(minikubeip)
- $minikubeip192.168.49.2
注意:照着执行后发现最后无法访问,下面有修正。
启动minikube隧道
- $minikubetunnel Theserviceistio-ingressgatewayrequiresprivilegedportstobeexposed:[80443] sudopermissionwillbeaskedforit. Startingtunnelforserviceistio-ingressgateway.
修正网关地址
官方为命令:
- $exportGATEWAY_URL=$INGRESS_HOST:$INGRESS_PORT
需要修正为:
- $exportGATEWAY_URL=127.0.0.1
- $echo"$GATEWAY_URL"127.0.0.1
备注:修正原因参见issue地址 https://github.com/istio/istio.io/issues/9340
6.浏览器访问页面

7.安装Kiali仪表盘
- $kubectlapply-fsamples/addons$kubectlrolloutstatusdeployment/kiali-nistio-systemdeployment"kiali"successfullyrolledout
启动仪表盘
- $istioctldashboardkialihttp://localhost:20001/kiali

备注:当访问http://127.0.0.1/productpage时可以在仪表盘中观察到流量的流向和服务之间的关系。
【编辑推荐】https://mp.weixin.qq.com/s/rOWx_W2fzCvIDvN1u_7jLA








发表评论
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。