kubernetes各版本离线安装包

安装

安装k8s 强势插播广告

三步安装,不多说

安装helm, 推荐生产环境用helm安装,可以调参

release地址

如我使用的2.9.1版本

yum install -y socat # 这个不装会报错
[root@istiohost ~]# wget https://storage.googleapis.com/kubernetes-helm/helm-v2.9.1-linux-amd64.tar.gz
[root@istiohost ~]# tar zxvf helm-v2.9.1-linux-amd64.tar.gz
[root@istiohost ~]# cp linux-amd64/helm /usr/bin

先创建一个service account 把管理员权限给helm:

[root@istiohost ~]# cat helmserviceaccount.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
  name: tiller
  namespace: kube-system
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1beta1
metadata:
  name: tiller-clusterrolebinding
subjects:
- kind: ServiceAccount
  name: tiller
  namespace: kube-system
roleRef:
  kind: ClusterRole
  name: cluster-admin
  apiGroup: ""
kubectl create -f  helmserviceaccount.yaml

安装helm 服务端 tiller :

helm init  --service-account tiller #  如果已安装更新加 --upgrade 参数
helm list #没任何返回表示成功

安装istio

curl -L https://git.io/getLatestIstio | sh -
cd istio-1.0.0/
export PATH=$PWD/bin:$PATH

helm 2.10.0以前的版本需要装一下CRD:

kubectl apply -f install/kubernetes/helm/istio/templates/crds.yaml
kubectl apply -f install/kubernetes/helm/istio/charts/certmanager/templates/crds.yaml

安装istio, 由于你没有LB所以用NodePort代替:

helm install install/kubernetes/helm/istio  --name istio --namespace istio-system --set gateways.istio-ingressgateway.type=NodePort --set gateways.istio-egressgateway.type=NodePort

安装成功:

[root@istiohost istio-1.0.0]# kubectl get pod -n istio-system
NAME                                        READY     STATUS    RESTARTS   AGE
istio-citadel-7d8f9748c5-ntqnp              1/1       Running   0          5m
istio-egressgateway-676c8546c5-2w4cq        1/1       Running   0          5m
istio-galley-5669f7c9b-mkxjg                1/1       Running   0          5m
istio-ingressgateway-5475685bbb-96mbr       1/1       Running   0          5m
istio-pilot-5795d6d695-gr4h4                2/2       Running   0          5m
istio-policy-7f945bf487-gkpxr               2/2       Running   0          5m
istio-sidecar-injector-d96cd9459-674pk      1/1       Running   0          5m
istio-statsd-prom-bridge-549d687fd9-6cbzs   1/1       Running   0          5m
istio-telemetry-6c587bdbc4-jndjn            2/2       Running   0          5m
prometheus-6ffc56584f-98mr9                 1/1       Running   0          5m
[root@istiohost istio-1.0.0]# kubectl get svc -n istio-system
NAME                       TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)                                                                                                     AGE
istio-citadel              ClusterIP   10.108.253.89    <none>        8060/TCP,9093/TCP                                                                                           5m
istio-egressgateway        NodePort    10.96.151.14     <none>        80:30830/TCP,443:30038/TCP                                                                                  5m
istio-galley               ClusterIP   10.102.83.130    <none>        443/TCP,9093/TCP                                                                                            5m
istio-ingressgateway       NodePort    10.99.194.13     <none>        80:31380/TCP,443:31390/TCP,31400:31400/TCP,15011:31577/TCP,8060:30037/TCP,15030:31855/TCP,15031:30775/TCP   5m
istio-pilot                ClusterIP   10.101.4.143     <none>        15010/TCP,15011/TCP,8080/TCP,9093/TCP                                                                       5m
istio-policy               ClusterIP   10.106.221.68    <none>        9091/TCP,15004/TCP,9093/TCP                                                                                 5m
istio-sidecar-injector     ClusterIP   10.100.5.170     <none>        443/TCP                                                                                                     5m
istio-statsd-prom-bridge   ClusterIP   10.107.28.242    <none>        9102/TCP,9125/UDP                                                                                           5m
istio-telemetry            ClusterIP   10.105.66.20     <none>        9091/TCP,15004/TCP,9093/TCP,42422/TCP                                                                       5m
prometheus                 ClusterIP   10.103.128.152   <none>        9090/TCP

使用教程

官网事例 Bookinfo Application

  • productpage 调用details和reviews渲染页面
  • details包含书本信息
  • reviews 书本反馈,调用ratings服务
  • ratings 书本租借信息

reviews服务有三个版本:

  • V1 不请求ratings
  • V2 请求ratings,返回1到5个黑星
  • V3 请求ratings,返回1到5个红星

数据平面:

安装应用:

kubectl apply -f <(istioctl kube-inject -f samples/bookinfo/platform/kube/bookinfo.yaml)

安装完成:

[root@istiohost istio-1.0.0]# kubectl get services
NAME          TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)    AGE
details       ClusterIP   10.104.66.31    <none>        9080/TCP   2m
kubernetes    ClusterIP   10.96.0.1       <none>        443/TCP    4h
productpage   ClusterIP   10.109.68.13    <none>        9080/TCP   2m
ratings       ClusterIP   10.99.55.110    <none>        9080/TCP   2m
reviews       ClusterIP   10.102.19.129   <none>        9080/TCP   2m
[root@istiohost istio-1.0.0]# kubectl get pods
NAME                              READY     STATUS    RESTARTS   AGE
details-v1-fc9649d9c-dpnlp        2/2       Running   0          2m
productpage-v1-58845c779c-7g8th   2/2       Running   0          2m
ratings-v1-6cc485c997-fb7nh       2/2       Running   0          2m
reviews-v1-76987687b7-x5n7z       2/2       Running   0          2m
reviews-v2-86749dcd5-xchzb        2/2       Running   0          2m
reviews-v3-7f4746b959-nthrq       2/2       Running   0          2m

创建一个gateway,这是为了集群外可以访问

kubectl apply -f samples/bookinfo/networking/bookinfo-gateway.yaml

浏览器访问url:
47.254.28.88是我的节点ip,使用nodeport模式

http://47.254.28.88:31380/productpage 

连续点击三次,你会发现右边没星星-> 黑星星-> 红星星切换,对应三个版本的review,默认策略是轮询

创建destination rules, 配置路由访问规则,现在还是轮询

kubectl apply -f samples/bookinfo/networking/destination-rule-all.yaml

智能路由

请求路由 request routing

根据版本路由

把所有路由切换到v1版本

kubectl apply -f samples/bookinfo/networking/virtual-service-all-v1.yaml

这样执行完后,不管怎么刷页面,我们都看不到星星,因为v1版本没星

可以看到destination是这样的:

  http:
  - route:
    - destination:
        host: details
        subset: v1

试想如此我们做版本切换将是何等简单

根据用户路由

kubectl apply -f samples/bookinfo/networking/virtual-service-reviews-test-v2.yaml

你会发现用jason用户登录就能看到黑星星,而其它方式看到的页面都是无星星

因为这个user走了v2版本,能不强大? 那当然还能根据header什么的做路由了,就不多说了

  http:
  - match:
    - headers:
        end-user:
          exact: jason
    route:
    - destination:
        host: reviews
        subset: v2
  - route:
    - destination:
        host: reviews
        subset: v1

故障注入 Fault injection

kubectl apply -f samples/bookinfo/networking/virtual-service-all-v1.yaml
kubectl apply -f samples/bookinfo/networking/virtual-service-reviews-test-v2.yaml

假设代码里有个bug,用户jason, reviews:v2 访问ratings时会卡10s, 我们任然希望端到端的测试能正常走完

kubectl apply -f samples/bookinfo/networking/virtual-service-ratings-test-delay.yaml

注入错误让jason用户有个7s的延迟

  hosts:
  - ratings
  http:
  - fault:
      delay:
        fixedDelay: 7s
        percent: 100
    match:
    - headers:
        end-user:
          exact: jason
    route:
    - destination:
        host: ratings
        subset: v1
  - route:
    - destination:
        host: ratings
        subset: v1

这时访问页面显然会出错,因为我们希望7s内能返回,这样我们就发现了一个延迟的bug

Error fetching product reviews!
Sorry, product reviews are currently unavailable for this book.

所以我们就可能通过故障注入去发现这些异常现象

链路切换 Traffic Shifting

我们先把50%流量发送给reviews:v1 50%流量发送给v3,然后再把100%的流量都切给v3

把100%流量切到v1

kubectl apply -f samples/bookinfo/networking/virtual-service-all-v1.yaml

此时不论刷几遍,都没有星星

v1 v3各50%流量

kubectl apply -f samples/bookinfo/networking/virtual-service-reviews-50-v3.yaml
  - route:
    - destination:
        host: reviews
        subset: v1
      weight: 50
    - destination:
        host: reviews
        subset: v3
      weight: 50

此时一会有星,一会没星,但是已经不是轮询算法了

全切v3

kubectl apply -f samples/bookinfo/networking/virtual-service-reviews-v3.yaml

这时不管怎么刷都是红心了

扫码关注sealyun

探讨可加QQ群:98488045

istio使用教程的更多相关文章

  1. istio入门教程

    广告 | kubernetes各版本离线安装包 安装 安装k8s 强势插播广告 三步安装,不多说 安装helm, 推荐生产环境用helm安装,可以调参 release地址 如我使用的2.9.1版本 y ...

  2. Istio Routing极简教程

    官网文档: https://istio.io/docs/reference/config/networking/#VirtualService 在学习像Istio这样的新技术时,看一下示例应用程序总是 ...

  3. istio添加Fluentd

    这个教程展示了istio如何自定义日志格式,并且将其发送给fluent.Fluentd 是一个开源的日志收集器,支持多种数据输出并且有一个可插拔架构.Elasticsearch是一个流行的后端日志记录 ...

  4. Istio入门实战与架构原理——使用Docker Compose搭建Service Mesh

    本文将介绍如何使用Docker Compose搭建Istio.Istio号称支持多种平台(不仅仅Kubernetes).然而,官网上非基于Kubernetes的教程仿佛不是亲儿子,写得非常随便,不仅缺 ...

  5. Istio 1.1尝鲜记

    近几天Istio1.1的发布引起了技术界巨大的反响,为了让更多技术爱好者能够亲自体验Istio1.1,公司的技术大佬赶出了这篇尝鲜教程,其中包括环境.安装.可能遇到的问题及解决方式等,希望对大家有所帮 ...

  6. 利用 istio 来对运行在 Kubernetes 上的微服务进行管理

    尝试在一个准生产环境下,利用 istio 来对运行在 Kubernetes 上的微服务进行管理. 这一篇是第一篇,将一些主要的坑和环境准备工作. 内容较多,因此无法写成手把手教程,希望读者有一定 Ku ...

  7. istio 简介

    最近接触到了 istio,感觉十分强大,写篇短文推荐给大家.本文所涉及的具体实验步骤可以参考官网教程. istio 相关文章列表: istio 简介 istio 性能测试 istio 是什么 Isti ...

  8. Istio 1.4 部署指南

    原文链接:Istio 1.4 部署指南 Istio 一直处于快速迭代更新的过程中,它的部署方法也在不断更新,之前我在 1.0 版本中介绍的安装方法,对于最新的 1.4 版本已经不适用了.以后主流的部署 ...

  9. 与IBM的Lin Sun关于Istio 1.0和微服务的问答

    北京时间 7 月 31 日,Istio 正式发布了 1.0 版本,并表示已经可用于生产环境.该版本的主要新特性包括跨集群 mesh 支持.细粒度流量控制以及在一个 mesh 中增量推出 mutual ...

随机推荐

  1. 修改linux(kali)和windows双系统下默认启动系统和启动延时

    我的公众号,正在建设中,欢迎关注: windows和kali双系统安装完成后kali是默认的启动系统,现将windows设置为默认启动系统并更改选择系统等待时间 1.开机时当运行到系统选择菜单时记下w ...

  2. Java Collection秋招复习

    抽象类和接口的区别 我们先来看一下抽象类 * @auther draymonder */ public abstract class AbstractClassTest { private int T ...

  3. putty秘钥转换成xhell支持的格式

    使用XShell导入KEY的时候报“Failed to import the user key!”错误 这个错误表明导入的private key文件不是XShell所支持的,有三种可能: 将Publi ...

  4. OSI参考模型---网络基础篇(1)

    什么是网络 网络就是将分布在不同地理位置,具有独立功能的终端(一切联网的设备都叫终端:例如电脑,手机,智能家电等等联网的设备),通过通信线路(双绞线.光纤.电话线等等)和通信设备(例如:交换机.路由器 ...

  5. 使用Jenkins部署.Net Core遇到的几个坑

    搞过CI/CD的同学一定吃过不少苦头,或者说遇到不少坑,但是对自动化的执着住挡不了前进的步伐,如果你缺少了运维这一块知识,那么你的流水线总是不那么完美,本文记录的是自己躺过的坑,希望对你有所帮助. 一 ...

  6. [Vue 牛刀小试]:第十五章 - 传统开发模式下的 axios 使用入门

    一.前言 在没有接触 React.Angular.Vue 这类 MVVM 的前端框架之前,无法抛弃 Jquery 的重要理由,除了优秀的前端 DOM 元素操作性以外,能够非常便捷的发起 http 请求 ...

  7. 获取当前时间的MySql时间函数

    mysql> select current_timestamp(); +---------------------+ | current_timestamp() | +------------- ...

  8. curl推送示例:熊掌号,百度站长的链接推送(系统环境变量配置)

    curl推送示例:熊掌号,百度站长的链接推送(需要用户系统环境变量配置)这篇文章主要讲解curl推送,熊掌号,百度站长的链接推送,我们很多seo朋友都搞不定curl的推送链接,而且还要配置系统的环境变 ...

  9. django ORM中的RelatedManager(关联管理器)

    关联管理器应用在 一对多的表 或者 多对多的表 多对多表中的用法: 在多对多的表中 正向查询 #基于对象的查询 #正查 # author_obj = Author.objects.get(id=1) ...

  10. Python中文件的读写操作

    文件操作基本流程: 1. 介绍 计算机系统是由计算机硬件,操作系统,和应用程序三部分组成. 内存 存放不持久 硬盘 可以使数据持久化 文件操作  数据持久化的一种 全栈开发  框架类 2. 文件的操作 ...