【kubernetes】Minikube-Istio初探
Minikube-Istio初探
设置Minikube
删除Minikube
1 | $ minikube delete |
启动Minikube
1 | # 启动 指定国内仓库,由于istio官方建议加大内存和cpu,推荐driver设置为VM |
探索Istio
安装Istio
1 命令行CI安装
- 官方下载方式:https://istio.io/latest/docs/setup/getting-started/
- archlinux系统直接: pacman -S istio
2 初始化demo
,可选default,demo,minimal
,生产系统一般用default
1 | $ istioctl install --set profile=demo -y |
3 添加default
命名空间label标识istio,为了在部署应用的时候自动注入Envoy sidecar proxies
1 | $ kubectl label namespace default istio-injection=enabled |
官网 Bookinfo Demo演示
网站包括四个微服务:
productpage :本服务会调用 details 和 reviews 两个微服务,用来生成页面。
details :这个微服务包含了书籍的信息。
reviews :这个微服务包含了书籍相关的评论。它还会调用 ratings 微服务。
ratings :ratings 微服务中包含了由书籍评价组成的评级信息。
reviews 微服务有 3 个版本:
v1 版本不会调用 ratings 服务。
v2 版本会调用 ratings 服务,并使用 1 到 5 个黑色星形图标来显示评分信息。
v3 版本会调用 ratings 服务,并使用 1 到 5 个红色星形图标来显示评分信息。
1 Deploy the Bookinfo sample application:
1 | kubectl apply -f https://gitee.com/melodyfff/istio/raw/master/samples/bookinfo/platform/kube/bookinfo.yaml |
2 The application will start. As each pod becomes ready, the Istio sidecar will be deployed along with it.
1 | $ kubectl get svc |
and
1 | $ kubectl get pods |
3 Verify everything is working correctly up to this point. Run this command to see if the app is running inside the cluster and serving HTML pages by checking for the page title in the response:
1 | $ kubectl exec "$(kubectl get pod -l app=ratings -o jsonpath='{.items[0].metadata.name}')" -c ratings -- curl -sS productpage:9080/productpage | grep -o "<title>.*</title>" |
or
Minikube运行minikube tunnel
访问http://10.100.103.177:9080
向外部流量打开应用程序
Bookinfo
应用程序已部署,但无法从外部访问。 为了使其可访问,您需要创建一个 Istio Ingress Gateway
,它将路径映射到网格边缘的路由。
1 Associate this application with the Istio gateway:
1 | $ kubectl apply -f https://gitee.com/melodyfff/istio/raw/master/samples/bookinfo/networking/bookinfo-gateway.yaml |
2 Ensure that there are no issues with the configuration:
1 | $ istioctl analyze |
确定入口IP和端口
通过kubectl get svc istio-ingressgateway -n istio-system
查看
1 | NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE |
minikube
1 | # Set the ingress ports |
Other platforms
https://istio.io/latest/docs/setup/getting-started/#determining-the-ingress-ip-and-ports
查看仪表板
1 Use the following instructions to deploy the Kiali dashboard, along with Prometheus, Grafana, and Jaeger.
1 | # 部署 |
2 Access the Kiali dashboard
1 | $ istioctl dashboard kiali |
3 In the left navigation menu, select Graph and in the Namespace drop down, select default.
1 | # for i in $(seq 1 100);do curl -s -o /dev/null "http://192.168.59.101:31278/productpage" ;done |
4 Grafana
1 | $ istioctl dashboard grafana |
Visit http://localhost:3000/d/G8wLrJIZk/istio-mesh-dashboard in your web browser.
visit http://localhost:3000/d/LJ_uJAvmk/istio-service-dashboard in your web browser.
visit http://localhost:3000/d/UbsSZTDik/istio-workload-dashboard in your web browser.
5 Prometheus
1 | # key : istio_requests_total |
卸載
To delete the Bookinfo sample application and its configuration, see Bookinfo cleanup
Istio
卸载会分层删除 istio-system
命名空间下的 RBAC
权限和所有资源。 忽略不存在资源的错误是安全的,因为它们可能已被分层删除。
1 | $ kubectl delete -f samples/addons |
The istio-system
namespace is not removed by default. If no longer needed, use the following command to remove it:
1 | $ kubectl delete namespace istio-system |
The label to instruct Istio to automatically inject Envoy sidecar proxies is not removed by default. If no longer needed, use the following command to remove it:
1 | $ kubectl label namespace default istio-injection- |