AWS용 GKE는 서비스 기본 부하 분산기를 AWS 기본 Elastic Load Balancer(기본 ELB) 또는 NLB로 만듭니다. 기본적으로 AWS용 GKE는 클래식 ELB를 만듭니다. NLB를 만들려면 service.beta.kubernetes.io/aws-load-balancer-type 주석을 nlb로 설정합니다.
부하 분산기 유형 간의 차이점에 대한 자세한 내용은 AWS 문서의 부하 분산기 유형을 참조하세요.
인터넷 연결 또는 내부 부하 분산기 선택
서비스 부하 분산기는 인터넷 연결(공개적으로 확인 가능한 DNS 이름 사용) 또는 내부(VPC 내에서만 액세스 가능) 중 하나일 수 있습니다.
기본적으로 새 부하 분산기는 인터넷 연결 방식입니다. 내부 부하 분산기를 만들려면 매니페스트에서 service.beta.kubernetes.io/aws-load-balancer-internal 주석을 "true"로 설정합니다.
aws-load-balancer-internal 주석은 기존 서비스에 적용할 수 없습니다. 인터넷 연결 및 내부 구성을 서로 변경하려면 기존 LoadBalancer를 삭제하고 다시 만들어야 합니다.
서브넷 선택
부하 분산기를 만들려면 이를 배치할 서브넷을 AWS에 지정해야 합니다.
기본적으로 이러한 서브넷은 VPC의 서브넷 중에서 자동으로 검색됩니다. 이를 위해 서브넷에 특정 태그가 있어야 합니다. 서브넷 자동 검색 및 태그 지정에 대한 자세한 내용은 부하 분산기 서브넷을 참조하세요.
또는 서비스에 service.beta.kubernetes.io/aws-load-balancer-subnets 주석을 추가하여 주석으로 부하 분산기 서브넷을 지정할 수 있습니다. 이 주석의 값은 subnet-012345678abcdef,subnet-abcdef123456789,subnet-123456789abcdef와 같이 서브넷 ID 또는 서브넷 이름이 쉼표로 구분된 목록입니다.
예시 부하 분산기 만들기
배포를 만들고 서비스를 사용해서 이 배포를 노출하는 방식으로 LoadBalancer 유형의 서비스를 만듭니다. 다음 예시에서는 부하 분산기 셈플을 만듭니다.
배포를 만듭니다. 이 배포의 컨테이너는 포트 50001에서 리슨합니다.
다음 YAML을 my-deployment-50001.yaml 파일에 저장합니다.
[[["이해하기 쉬움","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-07-14(UTC)"],[],[],null,["# Create a network load balancer\n\nThis page describes how to set up an\n[L4 load balancer](https://en.wikipedia.org/wiki/Transport_layer)\nwith an AWS Elastic Load Balancer (ELB) or a Network Load Balancer (NLB)\nendpoint.\n\nFor more information on the other types of load balancers that you can use with\nGKE on AWS, see\n[Load balancer overview](/kubernetes-engine/multi-cloud/docs/aws/how-to/load-balancers).\n\nThis page is for Networking specialists who want to install, configure, and\nsupport network equipment. To learn more about common roles and example tasks\nthat we reference in Google Cloud content, see\n[Common GKE user roles and tasks](/kubernetes-engine/enterprise/docs/concepts/roles-tasks).\n\nBefore you begin\n----------------\n\n- [Create a cluster](/kubernetes-engine/multi-cloud/docs/aws/how-to/create-cluster) and configure `kubectl` to connect to it.\n- [Tag your service load balancer subnets](/kubernetes-engine/multi-cloud/docs/aws/how-to/load-balancer-subnets#tag_your_subnets_for_their_intended_use). This is required for subnet auto-discovery.\n- Decide whether you need a [Classic](https://aws.amazon.com/elasticloadbalancing/features/) or a [Network](https://docs.aws.amazon.com/elasticloadbalancing/latest/network/introduction.html) ELB.\n- Decide whether you need an internet-facing or internal load balancer.\n\n### Choose a load balancer type\n\nGKE on AWS creates a Service load balancer as either an AWS Classic\nElastic Load Balancer (Classic ELB) or NLB. By default,\nGKE on AWS creates a Classic ELB. To create an NLB, set the\n`service.beta.kubernetes.io/aws-load-balancer-type` annotation to `nlb`.\nFor more information on the differences between load balancer types, see\n[Load balancer types](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/load-balancer-types.html)\nin the AWS documentation.\n| **Note:** You cannot apply the NLB annotation to an existing Service. To change type, you must delete and recreate the existing LoadBalancer.\n\n### Choose an internet-facing or internal load balancer\n\nService load balancers can be either internet-facing (with a publicly\nresolvable DNS name) or internal (only accessible within your VPC).\n\nBy default, new load balancers are internet-facing. To create an internal\nload balancer, set the `service.beta.kubernetes.io/aws-load-balancer-internal`\nannotation to `\"true\"` in your manifest.\n\nYou cannot apply the `aws-load-balancer-internal` annotation to an existing\nService. To change between internet-facing and internal configurations, you must\ndelete and recreate the existing LoadBalancer.\n\n### Choose your subnets\n\nWhen creating load balancers, AWS needs to know what subnets to place them in.\nBy default, these subnets are automatically discovered from among the subnets in\nthe VPC. This requires that subnets have specific tags. For details of subnet\nauto-discovery and tagging, see\n[Load Balancer Subnets](/kubernetes-engine/multi-cloud/docs/aws/how-to/load-balancer-subnets).\n\nAlternately, you can specify load balancer subnets with an annotation, by adding\nthe `service.beta.kubernetes.io/aws-load-balancer-subnets` annotation to the\nService. The value for this annotation is a comma-separated list of subnet IDs\nor subnet names--- for example\n`subnet-012345678abcdef,subnet-abcdef123456789,subnet-123456789abcdef`.\n\nCreate an example load balancer\n-------------------------------\n\nYou create a Service of type LoadBalancer by creating a deployment and exposing\nthat deployment with a Service. In the following example, you create a sample\nload balancer.\n\n1. Create your deployment. Containers in this Deployment listen on port 50001.\n Save the following YAML to a file named `my-deployment-50001.yaml`:\n\n apiVersion: apps/v1\n kind: Deployment\n metadata:\n name: my-deployment-50001\n spec:\n selector:\n matchLabels:\n app: products\n department: sales\n replicas: 3\n template:\n metadata:\n labels:\n app: products\n department: sales\n spec:\n containers:\n - name: hello\n image: \"gcr.io/google-samples/hello-app:2.0\"\n env:\n - name: \"PORT\"\n value: \"50001\"\n\n2. Create the Deployment with `kubectl apply`:\n\n kubectl apply -f my-deployment-50001.yaml\n\n3. Verify that three Pods are running:\n\n kubectl get pods --selector=app=products\n\n4. Create a Service of type `LoadBalancer` for your deployment.\n\n5. Decide what type of load balancer you need:\n\n - An internet-facing Classic ELB\n - An internet-facing NLB\n - An internal Classic ELB\n - An internal NLB\n\n Choose the tab that matches your requirements and copy the manifest\n within it to a file named `my-lb-service.yaml`. \n\n ### Internet-facing Classic\n\n apiVersion: v1\n kind: Service\n metadata:\n name: my-lb-service\n spec:\n type: LoadBalancer\n selector:\n app: products\n department: sales\n ports:\n - protocol: TCP\n port: 60000\n targetPort: 50001\n\n ### Internet-facing NLB\n\n You create an NLB by setting the annotation\n `service.beta.kubernetes.io/aws-load-balancer-type`\n to `nlb`. The following YAML includes this annotation. \n\n apiVersion: v1\n kind: Service\n metadata:\n name: my-lb-service\n annotations:\n service.beta.kubernetes.io/aws-load-balancer-type: nlb\n spec:\n type: LoadBalancer\n selector:\n app: products\n department: sales\n ports:\n - protocol: TCP\n port: 60000\n targetPort: 50001\n\n ### Internal Classic\n\n You create an internal LoadBalancer by setting the annotation\n `service.beta.kubernetes.io/aws-load-balancer-internal`\n to `\"true\"`. The following YAML includes this annotation. \n\n apiVersion: v1\n kind: Service\n metadata:\n name: my-lb-service\n annotations:\n service.beta.kubernetes.io/aws-load-balancer-internal: \"true\"\n spec:\n type: LoadBalancer\n selector:\n app: products\n department: sales\n ports:\n - protocol: TCP\n port: 60000\n targetPort: 50001\n\n ### Internal NLB\n\n You create an internal NLB by setting the annotations:\n - `service.beta.kubernetes.io/aws-load-balancer-internal` to `\"true\"`\n - `service.beta.kubernetes.io/aws-load-balancer-type` to `nlb`\n\n The following YAML includes both annotations. \n\n apiVersion: v1\n kind: Service\n metadata:\n name: my-lb-service\n annotations:\n service.beta.kubernetes.io/aws-load-balancer-internal: \"true\"\n service.beta.kubernetes.io/aws-load-balancer-type: nlb\n spec:\n type: LoadBalancer\n selector:\n app: products\n department: sales\n ports:\n - protocol: TCP\n port: 60000\n targetPort: 50001\n\n6. Create the Service with `kubectl apply`:\n\n kubectl apply -f my-lb-service.yaml\n\n | **Note:** Configuring the load balancer and IP address takes several minutes.\n7. View the Service's address with `kubectl get service`.\n\n kubectl get service my-lb-service\n\n The output will include a column `EXTERNAL-IP` with an address of the\n load balancer (either public or private depending how the load balancer was\n created).\n8. If you have created an internet-facing load balancer you can connect to the\n load balancer with `curl` using the following command:\n\n curl http://\u003cvar translate=\"no\"\u003eEXTERNAL_IP\u003c/var\u003e:60000\n\n Replace \u003cvar translate=\"no\"\u003eEXTERNAL_IP\u003c/var\u003e with the address\n from the EXTERNAL-IP column in the previous step.\n\nThe output resembles the following: \n\n ```none\n Hello, world!\n Version: 2.0.0\n Hostname: my-deployment-50001-84b6dc5555-zmk7q\n ```\n\n### Cleaning up\n\nTo remove the Service and Deployment, use the `kubectl delete` command: \n\n kubectl delete -f my-lb-service.yaml\n kubectl delete -f my-deployment-50001.yaml\n\nNext steps\n----------\n\n- [Set up an HTTP Load Balancer](/kubernetes-engine/multi-cloud/docs/aws/how-to/http-load-balancing).\n\n- Learn more about GKE on Google Cloud documentation on\n [Exposing applications using services](/kubernetes-engine/docs/how-to/exposing-apps).\n\n- See the complete list of\n [supported annotations](https://github.com/kubernetes/cloud-provider-aws/blob/a43d818415c2fbd62a61c2ee613ae4d770426ea5/pkg/providers/v1/aws.go#L101-L243)."]]