当前位置:网站首页>通过 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
边栏推荐
- 搜狐员工遭遇工资补助诈骗 黑产与灰产有何区别 又要如何溯源?
- Stack -- one of two common linear structures of linear structure
- Redux learning (II) -- encapsulating the connect function
- Throttling and anti shake
- NPM upgrade: unable to load file c:\users\administrator\appdata\roaming\npm\npm-upgrade ps1
- Handwritten promise [01] - Implementation of promise class core logic
- 【Matlab印刷字符识别】OCR印刷字母+数字识别【含源码 1861期】
- Notice on organizing the application for the first edition of Ningbo key software in 2022
- 关于组织开展2022年宁波市重点首版次软件申报工作的通知
- 572. subtree of another tree
猜你喜欢

.NET C#基础(6):命名空间 - 有名字的作用域

Do you know what the quotation for it talent assignment service is? It is recommended that programmers also understand

572. subtree of another tree

Mongodb installation

QT script document translation (I)

byte和bit的区别

Solve the problem that ffmpeg obtains aac audio files with incorrect duration

Multimedia框架解析之MediaExtractor源码分析(一)

争议很大的问题

Detailed explanation of mutual call between C language and Lua
随机推荐
QT socket setting connection timeout
Jenkins user rights management
Zabbix 监控主机是否在线
563. slope of binary tree
Learn a trick to use MySQL functions to realize data desensitization
Throttling and anti shake
538. convert binary search tree to cumulative tree
节流和防抖
Do you know what the quotation for it talent assignment service is? It is recommended that programmers also understand
Check whether the filing information of the medical representative is correct
Count the time-consuming duration of an operation (function)
Pytest自动化测试-简易入门教程(01)
Required reading 1: the larger the pattern, the better they know how to speak
socket. IO cross domain stepping pit
Oracle prompt invalid number
About parseint()
fatal: refusing to merge unrelated histories
June training (day 11) - matrix
Illustration of JS implementation from insertion sort to binary insertion sort [with source code]
Aircraft war from scratch (II) simple development