Skip to content

NimTechnology

Trình bày các công nghệ CLOUD một cách dễ hiểu.

  • Kubernetes & Container
    • Docker
    • Kubernetes
      • Ingress
    • Helm Chart
    • Isito-EnvoyFilter
    • Apache Kafka
      • Kafka
      • Kafka Connect
      • Lenses
    • Vault
    • Longhorn – Storage
    • VictoriaMetrics
    • MetalLB
    • Kong Gateway
  • CI/CD
    • ArgoCD
    • ArgoWorkflows
    • Spinnaker
    • Jenkins
    • Harbor
    • TeamCity
    • Git
      • Bitbucket
  • Coding
    • Terraform
      • GCP – Google Cloud
      • AWS – Amazon Web Service
    • Golang
    • Laravel
    • Python
    • Jquery & JavaScript
    • Selenium
  • Log & Monitor
    • DataDog
    • Prometheus
    • Grafana
    • ELK
      • Kibana
      • Logstash
  • BareMetal
    • NextCloud
  • Toggle search form

[Ingress-nginx/Istio] How do ingress-nginx work with istio smoothly. Reducing status 503 or 5xx.

Posted on December 11, 2021December 11, 2021 By nim No Comments on [Ingress-nginx/Istio] How do ingress-nginx work with istio smoothly. Reducing status 503 or 5xx.

Mình chắc hẳn nhiều công ty đang chạy k8s thì các applications or workload được public ra thông qua:
– ingress-nginx.
– Kong-gateway.
– NodePort luôn.

Chúng ta sẽ migrate từ từ các workload sang istio.

Phase 1: inject Istio for all workload.
vậy lúc này ingress-nginx workload với istio-proxy. Lúc này bạn cảm thấy có 1 số workload sẽ phát sinh tình trạng 503 or 5xx.

Contents

  • 1) Prepare basic.
  • 2) For Inbound calls: ingress-nginx to istio-proxy
  • 2.1) inject istio for ingress-nginx.
  • 2.2) Discovering traffic from ingress-nginx to istio
      • 2.2.1) Appear 503, 5xx when redeploy workload or deploy new workload.
      • 2.2.2) Avoid 503, 5xx

1) Prepare basic.

Những cái này mình cũng đã nhắc trong các bài viết trước và bạn có thể click link bên dưới.

1.4 Test với Service GRPC (update thu 30 Sep 2021)

Istio có thể automatically detect có 2 cách

This can be configured in two ways:

  • By the name of the port: name: <protocol>[-<suffix>].
  • In Kubernetes 1.18+, by the appProtocol field: appProtocol: <protocol>.


Mình chia thành 2 phần inbound và outbound

2) For Inbound calls: ingress-nginx to istio-proxy

The materials to refer to:
https://www.tetrate.io/blog/using-istio-with-other-ingress-proxies/
https://www.giffgaff.io/tech/using-istio-with-nginx-ingress

Mode mình test là:
– ingress-nginx to istio-proxy
– mTLS mode Strict
– Inject Istio for ingress-nginx

2.1) inject istio for ingress-nginx.

Mình cũng đã hướng dẫn các bạn cài ingress-nginx:

[Ingress Nginx/MetalLB] Install Ingress Nginx trên K8s bằng helm

Nhưng nếu bạn cấu hình value helm như mình sẽ ko inject istio cho ingress-nginx được.
https://github.com/istio/istio/issues/11973#issuecomment-466442370

A little digging later, and it turns out you can’t do injection on host-network installs of nginx

Bạn sét là false nhé

Bạn config value of helm là:

controller:
  name: controller
  podAnnotations:
    sidecar.istio.io/inject: true

Và thưc hiện redeploy mà thưởng thức

Như này là inject istio ok
Chart kiali của ingress-nginx nhìn khá đẹp

2.2) Discovering traffic from ingress-nginx to istio

Các bạn có để ý là ingress-nginx đi vào workload webapp bằng 2 đường
– passthroughCluster
– service of webapp

Mình show cho các bạn coi config ingress

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    field.cattle.io/creatorId: user-2hcxk
    field.cattle.io/ingressState: '{"ZmxlZXRtYW4td2ViYXBwLWluZy9kZWZhdWx0L2ZsZWV0bWFuLXdlYmFwcC1pbmcubmltdGVjaG5vbG9neS5jb20vLy84MA==":""}'
    field.cattle.io/publicEndpoints: '[{"addresses":["192.168.101.220"],"port":80,"protocol":"HTTP","serviceName":"default:fleetman-webapp","ingressName":"default:fleetman-webapp-ing","hostname":"fleetman-webapp-ing.nimtechnology.com","path":"/","allNodes":false}]'
    kubernetes.io/ingress.class: nginx
  creationTimestamp: "2021-11-25T08:48:38Z"
  generation: 1
  labels:
    cattle.io/creator: norman
  managedFields:
  - apiVersion: extensions/v1beta1
    fieldsType: FieldsV1
    fieldsV1:
      f:metadata:
        f:annotations:
          f:field.cattle.io/publicEndpoints: {}
    manager: rancher
    operation: Update
    time: "2021-11-25T08:49:18Z"
  - apiVersion: networking.k8s.io/v1beta1
    fieldsType: FieldsV1
    fieldsV1:
      f:status:
        f:loadBalancer:
          f:ingress: {}
    manager: nginx-ingress-controller
    operation: Update
    time: "2021-11-26T12:08:27Z"
  - apiVersion: extensions/v1beta1
    fieldsType: FieldsV1
    fieldsV1:
      f:metadata:
        f:annotations:
          .: {}
          f:field.cattle.io/creatorId: {}
          f:field.cattle.io/ingressState: {}
          f:kubernetes.io/ingress.class: {}
        f:labels:
          .: {}
          f:cattle.io/creator: {}
      f:spec:
        f:rules: {}
    manager: Go-http-client
    operation: Update
    time: "2021-12-10T15:31:34Z"
  name: fleetman-webapp-ing
  namespace: default
  resourceVersion: "64087793"
  uid: f4686483-4b9c-48c5-959e-c7e5bbb40f1e
spec:
  rules:
  - host: fleetman-webapp-ing.nimtechnology.com
    http:
      paths:
      - backend:
          serviceName: fleetman-webapp
          servicePort: 80
        path: /
        pathType: ImplementationSpecific
status:
  loadBalancer:
    ingress:
    - ip: 192.168.101.220

Cấu hình là ingress đi vào service name.

What’s exactly happening

It’s important to understand some concepts about how NGINX ingress works. The NGINX ingress controller does not use Services to route traffic to the pods. Instead it uses a list of all endpoints (Pod IP/port) in the NGINX upstream configuration in order to bypass kube-proxy to allow NGINX features like session affinity and custom load balancing algorithms.

Câu trên gần như là giải thích tại có traffic ingress-nginx sang passthroughCluster rồi đi thằng workload

Giờ mình sẽ thực hiện bài test: 100 request/s trong vòng 5phut và trong lúc đó có redeploy workload
và mình sài vegeta he.

echo "GET http://fleetman-webapp-ing.nimtechnology.com/api/vehicles/driver/City%20Truck" | vegeta attack -duration=300s -rate=100 | vegeta report --type=text
Traffic trên kiali trước khi redeploy
HÌnh ảnh grafana trước khi redeploy

2.2.1) Appear 503, 5xx when redeploy workload or deploy new workload.

Mình thực hiên redeploy he
Trong quá trình redeploy

Ta thấy traffic ingress-nginx đi qua passthroughCluster có chút vàng vàng

Mình soi tất cả các chart thì chỉ co chart inbound của ingress-nginx là có chút status 503

inbound status 503 in ingress-nginx

report của vegeta

503 từ đầu của client nhần về hơn 1% tổng số request cũng hơi nhiều òi ý ha.

2.2.2) Avoid 503, 5xx

Vậy giờ có cách nào ko nhỉ?

Bạn sẽ thêm các annotation dưới đây vào từng ingress của workload nhé

  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/service-upstream: "true"
    nginx.ingress.kubernetes.io/upstream-vhost: fleetman-webapp.default.svc.cluster.local

Mục đích để làm gì:

Instead of routing the outbound traffic to the list of endpoints in the NGINX upstream configuration, you should configure NGINX ingress to route to a single upstream service, so that the outbound traffic is intercepted by the istio sidecar.

add annotation trên rancher.
Có vẻ là ăn annotation mới.

Giờ thực hiện test lại

echo “GET http://fleetman-webapp-ing.nimtechnology.com/api/vehicles/driver/City%20Truck” | vegeta attack -duration=300s -rate=100 | vegeta report –type=text

Thực hiện redeploy workload
giờ chỉ còn workload là đỏ thôi ha.
tín hiệu tốt
chart ingress-nginx cũng ko thấy 503 nữa.

Giờ chờ report vegeta thôi.

Isito-EnvoyFilter

Post navigation

Previous Post: [Laravel] Handle datetime easily with Carbon in Laravel.
Next Post: [Prometheus/Kiali] Setting Prometheus or Kiali for multi-cluster Istio mode.

More Related Articles

[istio] Discover route TCP in Cluster Istio Isito-EnvoyFilter
[Istio/multi cluster] Install multi-cluster Istio with mode “Primary-Remote” for Kubernetes on Google Cloud Platform. Isito-EnvoyFilter
[Istio] Analyzing Istio Performance by pprof Isito-EnvoyFilter
[Istio] Authenticator KubeJWTAuthenticator at index 1 got error: failed to validate the JWT from cluster – When you update K8s version 1.20 to 1.21 Isito-EnvoyFilter
[Istio/Recheck] Hướng dẫn kiểm tra các feature của cụm istio mới cài lên đã work ngon lành chưa? Isito-EnvoyFilter
[kiali] Config authentication on Kiali. Isito-EnvoyFilter

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Tham Gia Group DevOps nhé!
Để Nim có nhiều động lực ra nhiều bài viết.
Để nhận được những thông báo mới nhất.

Recent Posts

  • [Prometheus/Grafana] Install Prometheus and Grafana on ubuntu. March 27, 2023
  • [Kong Gateway] WebSocket connection failed March 26, 2023
  • [Nextcloud] Can’t download files to have a size bigger than 2Gi on NextCloud – RaspBerry March 24, 2023
  • [Datadog] Using DataDog to monitor all services on kubernetes March 19, 2023
  • [Metrics Server] Failed to make webhook authorizer request: the server could not find the requested resource March 17, 2023

Archives

  • March 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022
  • August 2022
  • July 2022
  • June 2022
  • May 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021

Categories

  • BareMetal
    • NextCloud
  • CI/CD
    • ArgoCD
    • ArgoWorkflows
    • Git
      • Bitbucket
    • Harbor
    • Jenkins
    • Spinnaker
    • TeamCity
  • Coding
    • Golang
    • Jquery & JavaScript
    • Laravel
    • Python
    • Selenium
    • Terraform
      • AWS – Amazon Web Service
      • GCP – Google Cloud
  • Kubernetes & Container
    • Apache Kafka
      • Kafka
      • Kafka Connect
      • Lenses
    • Docker
    • Helm Chart
    • Isito-EnvoyFilter
    • Kong Gateway
    • Kubernetes
      • Ingress
    • Longhorn – Storage
    • MetalLB
    • Vault
    • VictoriaMetrics
  • Log & Monitor
    • DataDog
    • ELK
      • Kibana
      • Logstash
    • Grafana
    • Prometheus
  • Uncategorized
  • Admin

Copyright © 2023 NimTechnology.