当前位置:网站首页>通过 Ingress 进行灰度发布
通过 Ingress 进行灰度发布
2022-06-11 06:49:00 【[email protected]】
1、部署 Deployment V1 应用
创建如下 YAML 文件(app-v1.yaml)
apiVersion: v1
kind: Service
metadata:
name: my-app-v1
labels:
app: my-app
spec:
ports:
- name: http
port: 80
targetPort: http
selector:
app: my-app
version: v1.0.0
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-app-v1
labels:
app: my-app
spec:
replicas: 1
selector:
matchLabels:
app: my-app
version: v1.0.0
template:
metadata:
labels:
app: my-app
version: v1.0.0
annotations:
prometheus.io/scrape: "true"
prometheus.io/port: "9101"
spec:
containers:
- name: my-app
image: registry.cn-hangzhou.aliyuncs.com/containerdemo/containersol-k8s-deployment-strategies
ports:
- name: http
containerPort: 8080
- name: probe
containerPort: 8086
env:
- name: VERSION
value: v1.0.0
livenessProbe:
httpGet:
path: /live
port: probe
initialDelaySeconds: 5
periodSeconds: 5
readinessProbe:
httpGet:
path: /ready
port: probe
periodSeconds: 5
执行如下命令部署 Deployement V1 应用:
kubectl apply -f app-v1.yaml
创建如下 Ingress YAML文件(ingress-v1.yaml)
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: my-app
labels:
app: my-app
spec:
rules:
- host: my-app-22e6541b324bd1dfe04a48beb40046ea.ca2ef983cc3a64042a32c1a423d32021e.cn-shanghai.alicontainer.com
http:
paths:
- backend:
serviceName: my-app-v1
servicePort: 80
path: /
执行如下命令部署 Ingress 资源
kubectl apply -f ingress-v1.yaml
部署完成后通过 curl 命令进行测试:
curl my-app-22e6541b324bd1dfe04a48beb40046ea.ca2ef983cc3a64042a32c1a423d32021e.cn-shanghai.alicontainer.com
会看到如下返回:
Host: my-app-v1-68bfcbb7cf-w4rpg, Version: v1.0.0
2、部署 Deployment V2 应用
创建如下 YAML 文件(app-v2.yaml)
apiVersion: v1
kind: Service
metadata:
name: my-app-v2
labels:
app: my-app
spec:
ports:
- name: http
port: 80
targetPort: http
selector:
app: my-app
version: v2.0.0
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-app-v2
labels:
app: my-app
spec:
replicas: 1
selector:
matchLabels:
app: my-app
version: v2.0.0
template:
metadata:
labels:
app: my-app
version: v2.0.0
annotations:
prometheus.io/scrape: "true"
prometheus.io/port: "9101"
spec:
containers:
- name: my-app
image: registry.cn-hangzhou.aliyuncs.com/containerdemo/containersol-k8s-deployment-strategies
ports:
- name: http
containerPort: 8080
- name: probe
containerPort: 8086
env:
- name: VERSION
value: v2.0.0
livenessProbe:
httpGet:
path: /live
port: probe
initialDelaySeconds: 5
periodSeconds: 5
readinessProbe:
httpGet:
path: /ready
port: probe
periodSeconds: 5
执行如下命令部署 Deployement V2 应用:
kubectl apply -f app-v2.yaml
3、按照权重策略灰度到 Deployment V2 应用
创建如下 Ingress YAML文件(ingress-v2-canary-weigth.yaml)
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: my-app-canary
labels:
app: my-app
annotations:
# Enable canary and send 10% of traffic to version 2
nginx.ingress.kubernetes.io/canary: "true"
nginx.ingress.kubernetes.io/canary-weight: "10"
spec:
rules:
- host: my-app-22e6541b324bd1dfe04a48beb40046ea.ca2ef983cc3a64042a32c1a423d32021e.cn-shanghai.alicontainer.com
http:
paths:
- backend:
serviceName: my-app-v2
servicePort: 80
path: /
执行如下命令部署 Ingress 资源
kubectl apply -f ingress-v2-canary-weigth.yaml
执行如下命令进行测试:
while sleep 0.1;do curl my-app-22e6541b324bd1dfe04a48beb40046ea.ca2ef983cc3a64042a32c1a423d32021e.cn-shanghai.alicontainer.com; done
测试结果如下:
Host: my-app-v1-68bfcbb7cf-w4rpg, Version: v1.0.0
Host: my-app-v1-68bfcbb7cf-w4rpg, Version: v1.0.0
Host: my-app-v1-68bfcbb7cf-w4rpg, Version: v1.0.0
Host: my-app-v1-68bfcbb7cf-w4rpg, Version: v1.0.0
Host: my-app-v1-68bfcbb7cf-w4rpg, Version: v1.0.0
Host: my-app-v1-68bfcbb7cf-w4rpg, Version: v1.0.0
Host: my-app-v1-68bfcbb7cf-w4rpg, Version: v1.0.0
Host: my-app-v1-68bfcbb7cf-w4rpg, Version: v1.0.0
Host: my-app-v1-68bfcbb7cf-w4rpg, Version: v1.0.0
Host: my-app-v2-67c69b8857-g82gr, Version: v2.0.0
Host: my-app-v1-68bfcbb7cf-w4rpg, Version: v1.0.0
4、按照 Header 策略灰度到 Deployment V2 应用
创建如下 Ingress YAML文件(ingress-v2-canary-header.yaml)
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: my-app-canary
labels:
app: my-app
annotations:
# Enable canary and send traffic with headder x-app-canary to version 2
nginx.ingress.kubernetes.io/canary: "true"
nginx.ingress.kubernetes.io/canary-by-header: "x-app-canary"
nginx.ingress.kubernetes.io/canary-by-header-value: "true"
spec:
rules:
- host: my-app-22e6541b324bd1dfe04a48beb40046ea.ca2ef983cc3a64042a32c1a423d32021e.cn-shanghai.alicontainer.com
http:
paths:
- backend:
serviceName: my-app-v2
servicePort: 80
执行如下命令部署 Ingress 资源
kubectl apply -f ingress-v2-canary-header.yaml
通过 curl 命令对应用进行测试:
curl my-app-22e6541b324bd1dfe04a48beb40046ea.ca2ef983cc3a64042a32c1a423d32021e.cn-shanghai.alicontainer.com
结果如下:
目前还是环境在v1
Host: my-app-v1-68bfcbb7cf-w4rpg, Version: v1.0.0
执行如下命令环境全部灰度发布到v2
curl my-app-22e6541b324bd1dfe04a48beb40046ea.ca2ef983cc3a64042a32c1a423d32021e.cn-shanghai.alicontainer.com -H "x-app-canary: true"
结果如下
Host: my-app-v2-67c69b8857-g82gr, Version: v2.0.0
版权声明
本文为[[email protected]微胖子]所创,转载请带上原文链接,感谢
https://blog.csdn.net/zouyang920/article/details/125197466
边栏推荐
- VTK-vtkPlane和vtkCutter使用
- June training (day 11) - matrix
- [matlab printed character recognition] OCR printed letter + number recognition [including source code 1861]
- fatal: refusing to merge unrelated histories
- 021 mongodb database from getting started to giving up
- 347. top k high frequency elements
- 【Matlab WSN通信】A_Star改进LEACH多跳传输协议【含源码 487期】
- AppClips&Tips(持续更新)
- Pytest自动化测试-简易入门教程(01)
- Redux learning (I) -- the process of using Redux
猜你喜欢

100. 相同的树

【迅为干货】龙芯2k1000开发板opencv 测试

Check whether the filing information of the medical representative is correct

JS judge whether the year is a leap year and the number of days in the month

538.把二叉搜索树转换成累加树

Implementation of customization function page of online Fox game server room configuration wizard service

搜狐员工遭遇工资补助诈骗 黑产与灰产有何区别 又要如何溯源?

Training and testing of super score model in mmediting

617. 合并二叉树

Communication between different VLANs
随机推荐
617. merge binary tree
ESP32学习笔记(49)——ESP-WIFI-MESH接口使用
Aircraft war from scratch (II) simple development
QT script document translation (I)
Practice: how to reasonably design functions to solve practical problems in software development (II) -- improving reusability
Quick sorting of graphic array [with source code]
538.把二叉搜索树转换成累加树
3.1 naming rules of test functions
How exactly does instanceof judge the reference data type!
Biweekly investment and financial report: capital rush yuan universe game
Multimedia框架解析之MediaExtractor源码分析(一)
Warning: Each child in a list should have a unique “key“ prop.
Starting from scratch (V) realize bullet positioning and animation
解决ffmpeg獲取AAC音頻文件duration不准
Handwritten promise [05] - exception capture of promise method and optional parameters of then method implementation
Teach everyone how to implement an electronic signature
022 basic introduction to redis database 0
100. same tree
Text overflow failure
Flutter 内外边距