
쿠버네티스 환경에서 배포된 gRPC 통신을 하고있는데
CancellationToken 으로 Timeout 을 60초 넘게 주었음에도 60초가 넘어가면 무조건 Timeout 이 발생되었습니다.
알고 보니 이 문제는 Ingress Nginx 기본 설정 때문에 발생하는 것이었습니다.
Ingress Nginx는 gRPC 통신을 지원하지만,
기본적으로 grpc_read_timeout과 같은 값들이 60초 정도로 제한되어 있습니다.
따라서 gRPC Stream처럼 장시간 연결을 유지해야 하는 경우에는 이 설정이 반드시 필요합니다.
공식 문서에서도 gRPC 지원을 위해 Nginx에서 적절한 timeout 설정을 해줄 것을 권장하고 있습니다.
ingress-nginx 컨트롤러에 아래와 같이 grpc_read_timeout, grpc_send_timeout, proxy-body-timeout 설정을 추가하면 됩니다.
1. 전역 설정 (ConfigMap 수정)
apiVersion: v1
kind: ConfigMap
metadata:
name: nginx-configuration
namespace: ingress-nginx
data:
grpc-read-timeout: "300s"
grpc-send-timeout: "300s"
client-body-timeout: "300s"
2. 특정 Ingress에만 설정 (Annotations 추가)
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: grpc-app-ingress
namespace: default
annotations:
nginx.ingress.kubernetes.io/grpc-read-timeout: "300"
nginx.ingress.kubernetes.io/grpc-send-timeout: "300"
nginx.ingress.kubernetes.io/proxy-body-timeout: "300"
spec:
ingressClassName: nginx
rules:
- host: grpc.example.com
http:
paths:
- path: /
pathType: ImplementationSpecific
backend:
service:
name: grpc-service
port:
number: 50051
응답 스트리밍만 사용하는 경우 → grpc-read-timeout만 변경
요청 스트리밍만 사용하는 경우 → grpc-send-timeout, client-body-timeout 변경
양방향 스트리밍을 사용하는 경우 → 세 가지 모두 변경
아래 공식문서 링크로 들어가면 자세한 설명이 있습니다.
https://kubernetes.github.io/ingress-nginx/examples/grpc/
gRPC - Ingress-Nginx Controller
gRPC This example demonstrates how to route traffic to a gRPC service through the Ingress-NGINX controller. Prerequisites You have a kubernetes cluster running. You have a domain name such as example.com that is configured to route traffic to the Ingress-N
kubernetes.github.io
https://github.com/apache/apisix/issues/12357
help request: How to set grpc_read_timeout and grpc_send_timeout · Issue #12357 · apache/apisix
Description I want to modify grpc_read_timeout and grpc_send_timeout,but i can't find any document. Environment APISIX version (run apisix version): 3.12.0
github.com
https://github.com/kubernetes/ingress-nginx/issues/12434
gRPC stream is closed after 60 seconds of idle even with timeout annotations set · Issue #12434 · kubernetes/ingress-nginx
What happened: The gRPC bi-directional stream is interrupted after 60 of idle even after necessary annotations are set. Annotations: apiVersion: networking.k8s.io/v1 kind: Ingress metadata: annotat...
github.com
| 쿠버네티스 환경에서 gRPC Stream 60초 Timeout 문제 해결하기 - 2 (0) | 2025.09.11 |
|---|---|
| Linux 프로세스 별 메모리 사용량 확인하기 (0) | 2024.11.03 |
| Docker Desktop 에서 Kubernetes 설정하기 (0) | 2024.10.10 |
| Docker logs 명령 (0) | 2024.06.10 |
| 쿠버네티스 서비스메시 와 이스티오 (0) | 2024.06.01 |