이 페이지에서는 비공개 노드가 사용 설정된 VPC 기반 Google Kubernetes Engine(GKE) 클러스터의 Cloud NAT 패킷 손실 문제를 해결하는 방법을 보여줍니다.
비공개 노드가 있는 VPC 기반 GKE 클러스터의 노드 VM에는 외부 IP 주소가 없습니다. 즉, 인터넷의 클라이언트가 노드의 IP 주소에 연결할 수 없습니다. 비공개 노드가 있는 클러스터가 공개 연결되도록 Cloud NAT를 사용하여 외부 IP 주소와 포트를 할당할 수 있습니다.
노드 VM에 Cloud NAT의 외부 포트 및 IP 주소 할당이 부족해지면 패킷이 삭제됩니다. 이를 방지하기 위해서는 아웃바운드 패킷 비율을 줄이거나 사용 가능한 Cloud NAT 소스 IP 주소 및 포트의 할당을 늘릴 수 있습니다. 다음 섹션에서는 비공개 노드가 있는 GKE 클러스터의 컨텍스트에서 Cloud NAT의 패킷 손실을 진단하고 문제 해결하는 방법을 설명합니다.
패킷 손실 진단
다음 섹션에서는 Cloud Logging을 사용하여 손실된 패킷을 로깅하고 Cloud Monitoring을 사용하여 패킷 손실 원인을 진단하는 방법을 설명합니다.
이전 쿼리에서 빈 결과를 반환하고 GKE 포드가 외부 IP 주소와 통신할 수 없으면 다음 표를 사용하여 구성 문제를 해결합니다.
구성
문제 해결
서브넷의 기본 IP 주소 범위에만 적용되도록 구성된 Cloud NAT
Cloud NAT가 서브넷의 기본 IP 주소 범위에 대해서만 구성된 경우 클러스터에서 외부 IP 주소로 전송된 패킷에 소스 노드 IP 주소가 있어야 합니다. 이 Cloud NAT 구성에 대한 설명은 다음과 같습니다.
이러한 외부 IP 주소 대상에 IP 마스커레이딩이 적용되는 경우 포드가 외부 IP 주소로 패킷을 전송할 수 있습니다.
ip-masq-agent를 배포할 때 nonMasqueradeCIDRs 목록에 대상 IP 주소 및 포트가 포함되지 않는지 확인합니다. 이러한 대상으로 전송되는 패킷은 먼저 소스 노드 IP 주소로 변환된 후 Cloud NAT에서 처리됩니다.
포드가 이 Cloud NAT 구성을 사용해서 모든 외부 IP 주소에 연결할 수 있게 하려면 ip-masq-agent가 배포되었고 nonMasqueradeCIDRs 목록에 클러스터의 노드 및 포드 IP 주소 범위만 포함되었는지 확인합니다. 클러스터 외부의 대상에 전송된 패킷은 먼저 소스 노드 IP 주소로 변환된 후 Cloud NAT에서 처리됩니다.
포드가 일부 외부 IP 주소로 패킷을 전송하지 못하도록 방지하려면 마스커레이딩되지 않도록 해당 주소를 명시적으로 차단해야 합니다.
ip-masq-agent가 배포되면 차단하려는 외부 IP 주소를 nonMasqueradeCIDRs 목록에 추가합니다.
이러한 대상에 전송된 패킷은 노드의 포드 IP 주소 소스를 원래 상태로 둡니다. 포드 IP 주소는 클러스터 서브넷의 보조 IP 주소 범위에서 시작됩니다. 이 구성에서 Cloud NAT는 이 보조 범위에서 작동하지 않습니다.
포드 IP에 사용된 서브넷의 보조 IP 주소 범위에만 적용되도록 구성된 Cloud NAT
Cloud NAT가 클러스터의 포드 IP에 사용되는 서브넷의 보조 IP 주소 범위에 대해서만 구성된 경우 클러스터에서 외부 IP 주소로 전송된 패킷에 소스 포드 IP 주소가 있어야 합니다. 이 Cloud NAT 구성에 대한 설명은 다음과 같습니다.
IP 마스커레이드 에이전트를 사용하면 Cloud NAT에서 처리할 때 패킷의 소스 포드 IP 주소가 손실됩니다. 소스 포드 IP 주소를 유지하려면 nonMasqueradeCIDRs 목록에 대상 IP 주소 범위를 지정합니다. ip-masq-agent가 배포된 상태로 nonMasqueradeCIDRs 목록의 대상에 전송된 패킷은 소스 포드 IP 주소를 보존한 후 Cloud NAT에서 처리됩니다.
포드가 이 Cloud NAT 구성을 사용해서 모든 외부 IP 주소에 연결할 수 있게 하려면 ip-masq-agent가 배포되었고 nonMasqueradeCIDRs 목록이 가능한 한 크게 설정되었는지 확인합니다(0.0.0.0/0은 모든 IP 주소 대상 지정).
모든 대상에 전송된 패킷은 소스 포드 IP 주소를 보존한 후 Cloud NAT에서 처리됩니다.
패킷 손실 줄이기
패킷 손실 원인을 진단했으면 다음 권장사항에 따라 향후 문제가 재발할 가능성을 줄여보세요.
애플리케이션의 아웃바운드 패킷 비율을 줄입니다. 애플리케이션이 같은 대상 IP 주소와 포트에 대한 아웃바운드 연결을 여러 번 수행하면 Cloud NAT가 할당된 NAT 소스 주소 및 소스 포트 튜플 수를 사용하여 대상에 수행할 수 있는 모든 연결을 빠르게 소비할 수 있습니다.
대상에 대한 동시 연결 수 제한을 포함하여 Cloud NAT에서 NAT 소스 주소와 소스 포트를 사용하여 연결을 수행하는 방법에 대한 자세한 내용은 포트 및 연결을 참조하세요.
애플리케이션에서 아웃바운드 연결 비율을 줄이려면 열린 연결을 재사용합니다. 연결을 재사용하는 일반적인 방법에는 연결 풀링, HTTP/2와 같은 프로토콜을 사용하는 연결 다중화 또는 여러 요청에 재사용되는 영구 연결 설정 등이 있습니다. 자세한 내용은 포트 및 연결을 참조하세요.
다음 단계
문서에서 문제 해결 방법을 찾을 수 없으면 지원 받기를 참조하여 다음 주제에 대한 조언을 포함한 추가 도움을 요청하세요.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-08-07(UTC)"],[],[],null,["# Troubleshoot Cloud NAT packet loss from a cluster\n\n[Standard](/kubernetes-engine/docs/concepts/choose-cluster-mode)\n\n*** ** * ** ***\n\nThis page shows you how to resolve issues with [Cloud NAT](/nat/docs/overview)\npacket loss from a [VPC-native](/kubernetes-engine/docs/concepts/alias-ips)\nGoogle Kubernetes Engine (GKE) cluster with private nodes enabled.\n\nNode VMs in VPC-native GKE clusters with private nodes\ndon't have external IP addresses. This means that clients on the internet cannot\nconnect to the IP addresses of the nodes. You can use Cloud NAT to allocate\nthe external IP addresses and ports that allow clusters with private nodes to make public\nconnections.\n\nIf a node VM runs out of its allocation of external ports and IP addresses from\nCloud NAT, packets will drop. To avoid this, you can reduce the\noutbound packet rate or increase the allocation of available\nCloud NAT source IP addresses and ports. The following\nsections describe how to diagnose and troubleshoot packet loss from\nCloud NAT in the context of GKE clusters with private nodes.\n\nDiagnose packet loss\n--------------------\n\nThe following sections explains how to log dropped packets using\nCloud Logging, and diagnose the cause of dropped packets using\nCloud Monitoring.\n\n### Log dropped packets\n\nYou can log dropped packets with the following query in Cloud Logging: \n\n```\nresource.type=\"nat_gateway\"\nresource.labels.region=REGION\nresource.labels.gateway_name=GATEWAY_NAME\njsonPayload.allocation_status=\"DROPPED\"\n```\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003eREGION\u003c/var\u003e: the name of the region that the cluster is in.\n- \u003cvar translate=\"no\"\u003eGATEWAY_NAME\u003c/var\u003e: the name of the Cloud NAT gateway.\n\nThis command returns a list of all packets dropped by a Cloud NAT gateway,\nbut does not identify the cause.\n\n### Monitor causes for packet loss\n\nTo identify causes for dropped packets, query the\n[Metrics observer](https://console.cloud.google.com/monitoring/metrics-explorer) in\nCloud Monitoring. Packets drop for one of three reasons:\n\n- `OUT_OF_RESOURCES`\n- `ENDPOINT_INDEPENDENT_CONFLICT`\n- `NAT_ALLOCATION_FAILED`\n\nTo identify packets dropped due to `OUT_OF_RESOURCES` or\n`ENDPOINT_ALLOCATION_FAILED` error codes, use the following query: \n\n```\nfetch nat_gateway\n metric 'router.googleapis.com/nat/dropped_sent_packets_count'\n filter (resource.gateway_name == GATEWAY_NAME)\n align rate(1m)\n every 1m\n group_by [metric.reason],\n [value_dropped_sent_packets_count_aggregate:\n aggregate(value.dropped_sent_packets_count)]\n```\n\nIf you identify packets that drop because of these reasons, see\n[Packets dropped with reason: out of resources](/nat/docs/troubleshooting#insufficient-ports) and\n[Packets dropped with reason: endpoint independent conflict](/nat/docs/troubleshooting#endpoint-independent-conflict)\nfor troubleshooting advice.\n\nTo identify packets dropped due to the `NAT_ALLOCATION_FAILED` error code, use\nthe following query: \n\n```\nfetch nat_gateway\n metric 'router.googleapis.com/nat/nat_allocation_failed'\n group_by 1m,\n [value_nat_allocation_failed_count_true:\n count_true(value.nat_allocation_failed)]\n every 1m\n```\n\nIf you identify packets that dropped for this reason, see\n[Need to allocate more IP addresses](/nat/docs/troubleshooting#allocate-more-IPs).\n\n### Investigate Cloud NAT configuration\n\nIf the previous queries return empty results, and GKE Pods are\nunable to communicate to external IP addresses, use the following table to\nhelp you troubleshoot your configuration:\n\nReduce packet loss\n------------------\n\nAfter you have diagnosed the cause of your packet loss, consider using the\nfollowing recommendations to reduce the likelihood of the issue from recurring\nin the future:\n\n- Configure the Cloud NAT gateway to use\n [dynamic port allocation](/nat/docs/ports-and-addresses#dynamic-port) and\n [increase the maximum number of ports per VM](/nat/docs/tune-nat-configuration#change-dynamic-port).\n\n- If you're using\n [static port allocation](/nat/docs/ports-and-addresses#static-port),\n [increase the number of minimum ports per VM](/nat/docs/tune-nat-configuration#change-min-port).\n\n- Reduce your application's outbound packet rate. When an application makes\n multiple outbound connections to the same destination IP address and port,\n it can quickly consume all connections Cloud NAT can make to that\n destination using the number of allocated NAT source addresses and source\n port tuples.\n\n For details about how Cloud NAT uses NAT source addresses and\n source ports to make connections, including limits on the number of\n simultaneous connections to a destination, refer to [Ports and\n connections](/nat/docs/ports-and-addresses#ports-and-connections).\n\n To reduce the rate of outbound connections from the application, reuse open\n connections. Common methods of reusing connections include connection\n pooling, multiplexing connections using protocols such as\n [HTTP/2](https://datatracker.ietf.org/doc/html/rfc7540), or establishing\n persistent connections reused for multiple requests. For more information,\n see [Ports and\n Connections](/nat/docs/ports-and-addresses#ports-and-connections).\n\nWhat's next\n-----------\n\n- If you can't find a solution to your problem in the documentation, see\n [Get support](/kubernetes-engine/docs/getting-support) for further help,\n including advice on the following topics:\n\n - Opening a support case by contacting [Cloud Customer Care](/support-hub).\n - Getting support from the community by [asking questions on StackOverflow](http://stackoverflow.com/questions/tagged/google-kubernetes-engine) and using the `google-kubernetes-engine` tag to search for similar issues. You can also join the [`#kubernetes-engine` Slack channel](https://googlecloud-community.slack.com/messages/C0B9GKTKJ/) for more community support.\n - Opening bugs or feature requests by using the [public issue tracker](/support/docs/issue-trackers)."]]