istio 限流

#详细参数看官网,我参数就不解释https://istio.io/latest/docs/reference/config/networking/destination-rule/

cat << EOF > dr.yaml 
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
  name: my-test
  namespace: demon
spec:
  host: my-app.demon.svc.cluster.local
  trafficPolicy:
    connectionPool:
      http:
        http2MaxRequests: 10
        maxRequestsPerConnection: 15
    outlierDetection:
      baseEjectionTime: 10s
      consecutive5xxErrors: 10
      interval: 10s
EOF
cat << EOF > demon.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-app
spec:
  replicas: 1
  selector:
    matchLabels:
      app: my-app
  template:
    metadata:
      labels:
        app: my-app
    spec:
      containers:
      - name: my-app
        image: nginx:latest
        ports:
        - containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
  name: my-app
spec:
  type: NodePort
  selector:
    app: my-app
  ports:
  - name: http
    protocol: TCP
    port: 80
    targetPort: 80
EOF
cat << EOF >  ingress-dr.yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: vmmm
spec:
  ingressClassName: nginx
  rules:
  - host: my-app.xxx.top
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: my-app
            port:
              number: 80
EOF
并发工具测试
hey -n 1000 -c 100 -m GET http://my-app.xxxxchangs.top/
# 1000 个并发 GET 请求,总共发送 100 个请求

istio 限流_第1张图片

查看日志

istio 限流_第2张图片

istio 限流_第3张图片
istio 限流_第4张图片

你可能感兴趣的:(Kubernetes,Istio/Linkerd2,istio,云原生)