备考ICA----Istio实验5---流量转移 TCP Traffic Shifting 实验

2024-03-23 06:20

本文主要是介绍备考ICA----Istio实验5---流量转移 TCP Traffic Shifting 实验,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

备考ICA----Istio实验5—流量转移 TCP Traffic Shifting 实验

1. 应用部署

1.1 测试服务部署

该服务通过标签app: tcp-echo选择服务,服务tcp-echo存在2个版本,分别是v1和v2
istio/samples/tcp-echo/tcp-echo-services.yaml

# Copyright 2018 Istio Authors
#
#   Licensed under the Apache License, Version 2.0 (the "License");
#   you may not use this file except in compliance with the License.
#   You may obtain a copy of the License at
#
#       http://www.apache.org/licenses/LICENSE-2.0
#
#   Unless required by applicable law or agreed to in writing, software
#   distributed under the License is distributed on an "AS IS" BASIS,
#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#   See the License for the specific language governing permissions and
#   limitations under the License.apiVersion: v1
kind: Service
metadata:name: tcp-echolabels:app: tcp-echoservice: tcp-echo
spec:ports:- name: tcpport: 9000- name: tcp-otherport: 9001# Port 9002 is omitted intentionally for testing the pass through filter chain.selector:app: tcp-echo
---
apiVersion: apps/v1
kind: Deployment
metadata:name: tcp-echo-v1labels:app: tcp-echoversion: v1
spec:replicas: 1selector:matchLabels:app: tcp-echoversion: v1template:metadata:labels:app: tcp-echoversion: v1spec:containers:- name: tcp-echoimage: docker.io/istio/tcp-echo-server:1.2imagePullPolicy: IfNotPresentargs: [ "9000,9001,9002", "one" ]ports:- containerPort: 9000- containerPort: 9001
---
apiVersion: apps/v1
kind: Deployment
metadata:name: tcp-echo-v2labels:app: tcp-echoversion: v2
spec:replicas: 1selector:matchLabels:app: tcp-echoversion: v2template:metadata:labels:app: tcp-echoversion: v2spec:containers:- name: tcp-echoimage: docker.io/istio/tcp-echo-server:1.2imagePullPolicy: IfNotPresentargs: [ "9000,9001,9002", "two" ]ports:- containerPort: 9000- containerPort: 9001

部署服务

kubectl apply -f istio/samples/tcp-echo/tcp-echo-services.yaml

1.2 部署测试容器

这个sleep容器是为了通过它执行测试命令
istio/samples/sleep/sleep.yaml

# Copyright Istio Authors
#
#   Licensed under the Apache License, Version 2.0 (the "License");
#   you may not use this file except in compliance with the License.
#   You may obtain a copy of the License at
#
#       http://www.apache.org/licenses/LICENSE-2.0
#
#   Unless required by applicable law or agreed to in writing, software
#   distributed under the License is distributed on an "AS IS" BASIS,
#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#   See the License for the specific language governing permissions and
#   limitations under the License.##################################################################################################
# Sleep service
##################################################################################################
apiVersion: v1
kind: ServiceAccount
metadata:name: sleep
---
apiVersion: v1
kind: Service
metadata:name: sleeplabels:app: sleepservice: sleep
spec:ports:- port: 80name: httpselector:app: sleep
---
apiVersion: apps/v1
kind: Deployment
metadata:name: sleep
spec:replicas: 1selector:matchLabels:app: sleeptemplate:metadata:labels:app: sleepspec:terminationGracePeriodSeconds: 0serviceAccountName: sleepcontainers:- name: sleepimage: curlimages/curlcommand: ["/bin/sleep", "infinity"]imagePullPolicy: IfNotPresentvolumeMounts:- mountPath: /etc/sleep/tlsname: secret-volumevolumes:- name: secret-volumesecret:secretName: sleep-secretoptional: true

部署测试容器

kubectl apply -f istio/samples/sleep/sleep.yaml

2. 流量转移

2.1 100%流量到V1

2.1.1 部署Gw,Dr,Vs资源

istio/samples/tcp-echo/tcp-echo-all-v1.yaml

apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:name: tcp-echo-gateway
spec:selector:istio: ingressgatewayservers:- port:number: 31400name: tcpprotocol: TCPhosts:- "*"
---
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:name: tcp-echo-destination
spec:host: tcp-echosubsets:- name: v1labels:version: v1- name: v2labels:version: v2
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:name: tcp-echo
spec:hosts:- "*"gateways:- tcp-echo-gatewaytcp:- match:- port: 31400route:- destination:host: tcp-echoport:number: 9000subset: v1

部署gw,dr,vs

kubectl apply -f istio/samples/tcp-echo/tcp-echo-all-v1.yaml

2.1.2 访问测试

可以看到所有流量都被转发到v1上

export GATEWAY_URL=`kubectl get svc -n istio-system istio-ingressgateway | awk 'IF NR!=1{print $4}'`
for i in {1..20};do kubectl exec deploy/sleep -- sh -c "(date; sleep 1) | nc $GATEWAY_URL 31400";done

在这里插入图片描述

2.2 80%流量v1,20%流量v2

2.2.1 部署vs

istio/samples/tcp-echo/tcp-echo-20-v2.yaml

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:name: tcp-echo
spec:hosts:- "*"gateways:- tcp-echo-gatewaytcp:- match:- port: 31400route:- destination:host: tcp-echoport:number: 9000subset: v1weight: 80- destination:host: tcp-echoport:number: 9000subset: v2weight: 20

部署

kubectl apply -f istio/samples/tcp-echo/tcp-echo-20-v2.yaml

2.2.2 访问测试

可以看到20个包里有4个被分配到了v2上

for i in {1..20};do kubectl exec deploy/sleep -- sh -c "(date; sleep 1) | nc $GATEWAY_URL 31400";done

在这里插入图片描述
总的来说TCP Traffice Shifting的实验和之前DestinationRule的实验异曲同工,一样也是通过DestinationRule定义了2个subnet,再通过vs的weight来配置转发的权重
至此流量转移 TCP Traffic Shifting 实验完成

这篇关于备考ICA----Istio实验5---流量转移 TCP Traffic Shifting 实验的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/837418

相关文章

说一说三大运营商的流量类型,看完就知道该怎么选运营商了!

说一说三大运营商的流量类型,看完就知道该怎么选运营商了?目前三大运营商的流量类型大致分为通用流量和定向流量,比如: 中国电信:通用流量+定向流量 电信推出的套餐通常由通用流量+定向流量所组成,通用流量比较多,一般都在100G以上,而且电信套餐长期套餐较多,大多无合约期,自主激活的卡也是最多的,适合没有通话需求的朋友办理。 中国移动:通用流量+定向流量 移动推出的套餐通常由通用流量+定向

【软考】信息系统项目管理师(高项)备考笔记——信息系统项目管理基础

信息系统项目管理基础 日常笔记 项目的特点:临时性(一次性)、独特的产品、服务或成果、逐步完善、资源约束、目的性。 临时性是指每一个项目都有确定的开始和结束日期独特性,创造独特的可交付成果,如产品、服务或成果逐步完善意味着分步、连续的积累。例如,在项目早期,项目范围的说明是粗略的,随着项目团队对目标和可交付成果的理解更完整和深入时,项目的范围也就更具体和详细。 战略管理包括以下三个过程

【软考】信息系统项目管理师(高项)备考笔记——信息化与信息系统

信息化与信息系统 最近在备考信息系统项目管理师软考证书,特记录笔记留念,也希望可以帮到有需求的人。 因为这是从notion里导出来的,格式上可能有点问题,懒的逐条修改了,还望见谅! 日常笔记 核心知识 信息的质量属性:1.精确性 2.完整性 3.可靠性 4.及时性 5.经济性 6.可验证下 7.安全性 信息的传输技术(通常指通信、网络)是信息技术的核心。另外,噪声影响的是信道

高性能并行计算华为云实验五:

目录 一、实验目的 二、实验说明 三、实验过程 3.1 创建PageRank源码 3.2 makefile的创建和编译 3.3 主机配置文件建立与运行监测 四、实验结果与分析 4.1 采用默认的节点数量及迭代次数进行测试 4.2 分析并行化下节点数量与耗时的变化规律 4.3 分析迭代次数与耗时的变化规律 五、实验思考与总结 5.1 实验思考 5.2 实验总结 E

物联网系统运维——移动电商应用发布,Tomcat应用服务器,实验CentOS 7安装JDK与Tomcat,配置Tomcat Web管理界面

一.Tomcat应用服务器 1.Tomcat介绍 Tomcat是- -个免费的开源的Ser Ivet容器,它是Apache基金会的Jakarta 项目中的一个核心项目,由Apache, Sun和其他一 些公司及个人共同开发而成。Tomcat是一一个小型的轻量级应用服务器,在中小型系统和并发访问用户不是很多的场合下被普遍使用,是开发和调试JSP程序的首选。 在Tomcat中,应用程序的成部署很简

STM32HAL库--SDRAM实验(速记版)

STM32F429IGT6 自带了 256K 字节的 SRAM,对一般应用来说,已经足够了,不过在一些对内存要求高的场合, STM32F429 自带的这些内存就不够用了。比如使用 LTDC 驱动RGB 屏、跑算法或者跑 GUI 等,就可能不太够用,所以阿波罗 STM32F429 开发板板载了一颗 32M 字节容量的 SDRAM 芯片:W9825G6KH,满足大内存使用的需求。 1

HCIA 19 结束 企业总部-分支综合实验(下)

3.6出口NAT配置可以访问互联网 配置NAT使内网可以访问公网8.8.8.8,当前总部PC1 PING不通公网地址8.8.8.8。 3.6.1总部配置NAT访问互联网 步骤1:配置NAT acl number 2000    rule 5 permit source 192.168.0.0 0.0.255.255 # interface GigabitEthernet0/0/2

TCP 可靠传输的工作原理

转载地址:https://my.oschina.net/xinxingegeya/blog/485233 感谢原作者 TCP 可靠传输的工作原理 ARQ(Automatic Repeat-reQuest)(自动重传请求) 停止等待ARQ协议 连续ARQ协议   停止等待ARQ协议 全双工通信的双发既是发送方也是接收方。下面为了讨论问题的方便,我们仅考虑A发送数据而B接受数据

ESP32使用MQTT_TCP连接阿里云

ESP32-IDF中MQTT函数的介绍 esp_mqtt_client_handle_t esp_mqtt_client_init(const esp_mqtt_client_config_t *config) 函数功能:mqtt 客户端初始化 函数形参: mqtt 客户端的配置 函数返回值:正确则返回根据配置创建的 mqtt 客户端句柄;异常则返回 NULL。 其中函数形参 esp_mqtt

STM32G030F6使用CubeMx配置PWM实验

1. 使用 CubeMx 创建 PWM 工程 打开 CubeMx 软件,选中我们此次使用的单片机型号 STM32G030F6P6 ,点击 StartProject. 配置定时器 配置定时器1的通道1和通道2 产生PWM; 设置定时器1的主频:设置了( 63 + 1) 分频即定时器主频为1M 设置PWM定时的周期计数为 1000 即 1000HZ 设置通道一 翻转的计数值为 500 即