您现在的位置是:首页 > 文章详情

Kubernetes 实战教学,手把手教您在 K8s 集群上部署 Istio Mesh(二)

日期:2019-01-29点击:360

screenshot

出品丨Docker公司(ID:docker-cn)
编译丨小东
每周一、三、五,与您不见不散!


在上一篇文章《Kubernetes 实战教学,手把手教您在 K8s 集群上部署 Istio Mesh(一)》中,我们已经完成了安装 Istio 1.0.0 版本的所有准备。接下来,我将为大家带来 Istio 1.0.0 版本完整的安装过程,并在 Istio 1.0.0 中运行 BookInfo 演示示例。


安装 Istio 1.0.0

Istio 部署在单独的 Kubernetes 命名空间 istio-system 中。我们稍后会进行验证。到目前为止,您可以将以下内容复制到名为 install_istio.sh 的文件中并保存。 您可以使其可执行并运行它来安装 Istio 和相关工具。

#!/bin/bash curl -L https://git.io/getLatestIstio | sh – export PATH=$PWD/bin:$PATH cd istio-1.0.0 kubectl apply -f install/kubernetes/helm/istio/templates/crds.yaml kubectl apply -f install/kubernetes/istio-demo.yaml kubectl get svc -n istio-system kubectl get pods -n istio-system 

您应该能够看到屏幕充斥着如下图所示的输出。

screenshot

如上所示,它将默认启用 Prometheus、ServiceGraph、Jaeger、Grafana 和 Zipkin。

请注意:在执行此脚本时,可能会出现以下错误消息“unable to recognize “install/kubernetes/istio-demo.yaml”: no matches for admissionregistration.k8s.io/, Kind=MutatingWebhookConfiguration”


错误消息是可预期的

screenshot

一旦命令完全执行,您应该能够看到在页面顶部中心显示的一长串端口。


验证服务

screenshot


公开的服务

要公开 Prometheus、Grafana 和 Servicegraph 服务,您需要删除现有服务,然后使用 NodePort 而不是 ClusterIP,以便使用实例页面顶部显示的端口访问服务,如下所示:

screenshot

您应该能够通过单击“30004”端口访问Grafana页面,通过单击“30003”端口访问Prometheus 页面。

screenshot

screenshot

您可以通过选择必要的选项来检查 Prometheus 指标,如下所示:

screenshot

在 Grafana 页面下,您可以为 Prometheus 添加“数据源”,并确保仪表板已经启动并运行:

screenshot

恭喜!您已经在 Kubernetes 群集上完成了 Istio 的安装。K8s playground 已安装了下列服务

  • Istio 控制器及相关 RBAC 规则;
  • Istio 定制资源定义;
  • 用于监控的 Prometheus 和 Grafana;
  • 用于分布式跟踪的 Jeager;
  • Istio Sidecar Injector(我们将在下一节介绍);

安装 Istioctl

screenshot

Istioctl 是 Istio 的配置命令行实用程序。它有助于在 Istio 系统中创建、列出、修改和删除配置资源。


部署 BookInfo 示例应用程序

现在安装并验证了 Istio,您可以部署安装附带的 BookInfo 示例应用程序。这是一个简单的模拟书店应用程序,由四个服务组成,提供 Web 产品页面、书籍详细信息、评论(具有多个版本的评论服务)和评级,所有这些都要使用 Istio 进行管理。


部署 BookInfo 服务

[node1 istio-1.0.0]$ kubectl apply -f samples/bookinfo/platform/kube/bookinfo.yaml service “details” created deployment “details-v1” created service “ratings” created deployment “ratings-v1” created service “reviews” created deployment “reviews-v1” created deployment “reviews-v2” created deployment “reviews-v3” created service “productpage” created deployment “productpage-v1” created 
[node1 istio-1.0.0]$ istioctl create -f samples/bookinfo/networking/bookinfo-gateway.yaml Created config gateway/default/bookinfo-gateway at revision 13436 Created config virtual-service/default/bookinfo at revision 13438 

验证 BookInfo 应用程序

[node1 istio-1.0.0]$ kubectl get services NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE details ClusterIP 10.97.29.111 9080/TCP 1m kubernetes ClusterIP 10.96.0.1 443/TCP 1h productpage ClusterIP 10.106.144.171 9080/TCP 1m ratings ClusterIP 10.111.164.221 9080/TCP 1m reviews ClusterIP 10.99.195.21 9080/TCP 1m [node1 istio-1.0.0]$ curl 10.106.144.171:9080 <!DOCTYPE html> <html> <head> <title>Simple Bookstore App</title> <meta charset=”utf-8″> <meta http-equiv=”X-UA-Compatible” content=”IE=edge”> <meta name=”viewport” content=”width=device-width, initial-scale=1″> <!– Latest compiled and minified CSS –> <link rel=”stylesheet” href=”https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css”> <!– Optional theme –> <link rel=”stylesheet” href=”https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css”> </head> <body> <p><h3>Hello! This is a simple bookstore application consisting of three services as shown below</h3></p> <table class=”table table-condensed table-bordered table-hover”><tr><th>endpoint</th><td>details</td></tr><tr><th>name</th><td>http://details:9080</td></tr><tr><th>children</th><td><table class=”table table-condensed table-bordered table-hover”><tr><th>endpoint</th><th>name</th><th>children</th></tr><tr><td>details</td><td>http://details:9080</td><td></td></tr><tr><td>reviews</td><td>http://reviews:9080</td><td><table class=”table table-condensedtable-bordered table-hover”><tr><th>endpoint</th><th>name</th><th>children</th></tr><tr><td>ratings</td><td>http://ratings:9080</td><td></td></tr></table></td></tr></table></td></tr></table> <p><h4>Click on one of the links below to auto generate a request to the backend as a real user or a tester </h4></p> <p><a href=”/productpage?u=normal”>Normal user</a></p> <p><a href=”/productpage?u=test”>Test user</a></p> <!– Latest compiled and minified JavaScript –> <script src=”https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js”></script> <!– Latest compiled and minified JavaScript –> <script src=”https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js”></script> </body> </html> 

通过 Web URL 访问它

[node1 istio-1.0.0]$ kubectl get services NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE details ClusterIP 10.97.29.111 9080/TCP 2m kubernetes ClusterIP 10.96.0.1 443/TCP 1h productpage ClusterIP 10.106.144.171 9080/TCP 2m ratings ClusterIP 10.111.164.221 9080/TCP 2m reviews ClusterIP 10.99.195.21 9080/TCP 2m [node1 istio-1.0.0]$ kubectl delete svc productpage service “productpage” deleted [node1 istio-1.0.0]$ kubectl create service nodeport productpage –tcp=9080 –node-port=30010 service “productpage” created 

您现在应该可以使用 BookInfo 示例了,如下所示:

screenshot


在下一篇 Kubernetes 实战教学系列文章中,我将展示如何在 Play with Kubernetes 平台上调出 Kubernetes Dashboard。

原文链接:https://yq.aliyun.com/articles/689414
关注公众号

低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。

持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。

转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。

文章评论

共有0条评论来说两句吧...

文章二维码

扫描即可查看该文章

点击排行

推荐阅读

最新文章