Kubernetes 实战教学,手把手教您在 K8s 集群上部署 Istio Mesh(二)
出品丨Docker公司(ID:docker-cn)
编译丨小东每周一、三、五晚6点10分 与您不见不散!
说在前面
在上一篇文章《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
您应该能够看到屏幕充斥着如下图所示的输出。
如上所示,它将默认启用 Prometheus、ServiceGraph、Jaeger、Grafana 和 Zipkin。
请注意:在执行此脚本时,可能会出现以下错误消息“unable to recognize “install/kubernetes/istio-demo.yaml”: no matches for admissionregistration.k8s.io/, Kind=MutatingWebhookConfiguration”
错误消息是可预期的
一旦命令完全执行,您应该能够看到在页面顶部中心显示的一长串端口。
验证服务
公开的服务
要公开 Prometheus、Grafana 和 Servicegraph 服务,您需要删除现有服务,然后使用 NodePort 而不是 ClusterIP,以便使用实例页面顶部显示的端口访问服务,如下所示:
您应该能够通过单击“30004”端口访问Grafana页面,通过单击“30003”端口访问Prometheus 页面。
您可以通过选择必要的选项来检查 Prometheus 指标,如下所示:
在 Grafana 页面下,您可以为 Prometheus 添加“数据源”,并确保仪表板已经启动并运行:
恭喜!您已经在 Kubernetes 群集上完成了 Istio 的安装。K8s playground 已安装了下列服务
Istio 控制器及相关 RBAC 规则;
Istio 定制资源定义;
用于监控的 Prometheus 和 Grafana;
用于分布式跟踪的 Jeager;
Istio Sidecar Injector(我们将在下一节介绍);
安装 Istioctl
Istioctl 是 Istio 的配置命令行实用程序。它有助于在 Istio 系统中创建、列出、修改和删除配置资源。
部署 BookInfo 示例应用程序
现在安装并验证了 Istio,您可以部署安装附带的 BookInfo 示例应用程序。这是一个简单的模拟书店应用程序,由四个服务组成,提供 Web 产品页面、书籍详细信息、评论(具有多个版本的评论服务)和评级,所有这些都要使用 Istio 进行管理。
部署 BookInfo 服务[node1 istio-1.0.0]$ kubectl apply -f samples/bookinfo/platform/kube/bookinfo.yamlservice “details” createddeployment “details-v1” createdservice “ratings” createddeployment “ratings-v1” createdservice “reviews” createddeployment “reviews-v1” createddeployment “reviews-v2” createddeployment “reviews-v3” createdservice “productpage” createddeployment “productpage-v1” created[node1 istio-1.0.0]$ istioctl create -f samples/bookinfo/networking/bookinfo-gateway.yamlCreated config gateway/default/bookinfo-gateway at revision 13436Created config virtual-service/default/bookinfo at revision 13438
验证 BookInfo 应用程序[node1 istio-1.0.0]$ kubectl get servicesNAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGEdetails ClusterIP 10.97.29.111 9080/TCP 1mkubernetes ClusterIP 10.96.0.1 443/TCP 1hproductpage ClusterIP 10.106.144.171 9080/TCP 1mratings ClusterIP 10.111.164.221 9080/TCP 1mreviews 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 servicesNAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGEdetails ClusterIP 10.97.29.111 9080/TCP 2mkubernetes ClusterIP 10.96.0.1 443/TCP 1hproductpage ClusterIP 10.106.144.171 9080/TCP 2mratings ClusterIP 10.111.164.221 9080/TCP 2mreviews ClusterIP 10.99.195.21 9080/TCP 2m[node1 istio-1.0.0]$ kubectl delete svc productpageservice “productpage” deleted[node1 istio-1.0.0]$ kubectl create service nodeport productpage –tcp=9080 –node-port=30010service “productpage” created
您现在应该可以使用 BookInfo 示例了,如下所示:
在下一篇 Kubernetes 实战教学系列文章中,我将展示如何在 Play with Kubernetes 平台上调出 Kubernetes Dashboard。
点击下列标题,阅读更多干货
如果本文对你有帮助,欢迎分享到朋友圈!获取更多Docker实用技巧,扫描下图二维码!
- Kubernetes 实战教学,手把手教您用 Helm 在 K8s 平台上部署 Prometheus
- Kubernetes 实战教学,手把手教您设置拥有5个节点的 K8S 群集(无需搭建任何基础设施)...
- Kubernetes(二) - 使用Rancher部署K8S集群(搭建Rancher)
- kubernetes k8s 之入门实战-redis集群
- kubernetes实战(九):k8s集群动态存储管理GlusterFS及使用Heketi扩容GlusterFS集群
- Kubernetes(k8s)集群部署(k8s企业级Docker容器集群管理)系列之部署master/node节点组件(四)
- kubernetes实战(十三):k8s使用helm持久化部署harbor集成openLDAP登录
- k8s集群之kubernetes-dashboard和kube-dns组件部署安装
- kubernetes实战(十五):k8s使用helm持久化部署jenkins集成openLDAP登录
- Kubernetes(k8s)集群部署(k8s企业级Docker容器集群管理)系列之集群部署环境规划(一)
- Kubernetes(k8s)集群部署(k8s企业级Docker容器集群管理)系列目录
- Kubernetes(三) - 使用Rancher部署K8S集群(搭建Kubernetes)
- K8S实战——SIG PIPE问题造成kubernetes集群工作不正常的分析
- Kubernetes(K8S)集群管理Docker容器(部署篇) 推荐
- Kubernetes(K8S)集群管理Docker容器(部署篇)
- China Azure中部署Kubernetes(K8S)集群
- Docker集群管理工具-Kubernetes1.10.6(k8s)四节点集群使用kubeadm部署流程(一)
- kubernetes实战(十二):k8s使用helm持久化部署redmine集成openLDAP
- China Azure中部署Kubernetes(K8S)集群
- kubernetes实战(二十):k8s一键部署高可用Prometheus并实现邮件告警