编写Yaml
[root@k8smaster1 ingress]# cat ingress-v2-weight.yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: nginx-v2
annotations:
nginx.ingress.kubernetes.io/canary: "true"
nginx.ingress.kubernetes.io/canary-weight: "10"
spec:
ingressClassName: nginx
rules:
- host: canary.example.com
http:
paths:
- backend:
service:
name: nginx-v2
port:
number: 80
pathType: Prefix
path: /
测试结果
[root@k8smaster1 ingress]# for i in {1..10}; do curl -H "Host: canary.example.com" http://192.168.1.199; done;
nginx-v1
nginx-v1
nginx-v1
nginx-v1
nginx-v1
nginx-v1
nginx-v1
nginx-v1
nginx-v1
nginx-v2