KUBERNETES04_Service服务ClusterIP、NodePort方式、Ingress域名访问、路径重写、限流操作(六)

⑥. Ingress的限流操作


  • ①. 在master进行如下的命令操作


[root@k8smaster ~]# kubectl apply -f ingress-limit-rule.yaml 
ingress.networking.k8s.io/ingress-limit-rate created
[root@k8smaster ~]# kubectl get ingress
NAME                 CLASS   HOSTS                                ADDRESS          PORTS   AGE
ingress-host-bar     nginx   hello.xiaozhi.com,demo.xiaozhi.com   192.168.68.145   80      21m
ingress-limit-rate   nginx   haha.xiaozhi.com                                      80      8s
[root@k8smaster ~]# kubectl get svc -A |grep ingress
ingress-nginx          ingress-nginx-controller             NodePort    10.96.183.241   <none>        80:32128/TCP,443:31148/TCP   169m
ingress-nginx          ingress-nginx-controller-admission   ClusterIP   10.96.31.69     <none>        443/TCP                      169m


apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ingress-limit-rate
  annotations:
    nginx.ingress.kubernetes.io/limit-rps: "1"
spec:
  ingressClassName: nginx
  rules:
  - host: "haha.xiaozhi.com"
    http:
      paths:
      - pathType: Exact
        path: "/"
        backend:
          service:
            name: nginx-demo
            port:
              number: 8000


KUBERNETES04_Service服务ClusterIP、NodePort方式、Ingress域名访问、路径重写、限流操作(六)


②. 上面的yaml文件是精准匹配,流量限制1s一个请求进来,如果这个时候我们大量的刷新浏览器,就会出现503


KUBERNETES04_Service服务ClusterIP、NodePort方式、Ingress域名访问、路径重写、限流操作(六)


KUBERNETES04_Service服务ClusterIP、NodePort方式、Ingress域名访问、路径重写、限流操作(六)

上一篇:提高 SharePoint 页面访问速度之清理SharePoint Configuration Cache


下一篇:【Unity3D 灵巧小知识点】 ☀️ | Unity中 使用代码 激活/取消激活 某个游戏对象的方法