In this guide you explore how to expose the Gloo Gateway proxy with an AWS network load balancer (NLB). The following use cases are covered:

  • NLB HTTP: Create an HTTP listener on the NLB that exposes an HTTP endpoint on your gateway proxy. Traffic from the NLB to the proxy is not secured.
  • TLS passthrough: Expose an HTTPS endpoint of your gateway with an NLB. The NLB passes through HTTPS traffic to the gateway proxy where the traffic is terminated.

Before you begin

  1. Create or use an existing AWS account.
  2. Follow the Get started guide to install Gloo Gateway.
  3. Deploy the httpbin sample app. For more information, see the sample app guide.
    1. Create the httpbin app.

        kubectl apply -f https://raw.githubusercontent.com/kgateway-dev/kgateway/refs/heads//examples/httpbin.yaml
        

      Example output:

        namespace/httpbin created
      serviceaccount/httpbin created
      service/httpbin created
      deployment.apps/httpbin created
        
    2. Verify that the httpbin app is running.

        kubectl -n httpbin get pods
        

      Example output:

        NAME                      READY   STATUS    RESTARTS   AGE
      httpbin-d57c95548-nz98t   2/2     Running   0          18s
        

Step 1: Deploy the AWS Load Balancer controller

  1. Save the name and region of your AWS EKS cluster and your AWS account ID in environment variables.

      export CLUSTER_NAME="<cluster-name>"
    export REGION="<region>"
    export AWS_ACCOUNT_ID=<aws-account-ID>
    export IAM_POLICY_NAME=AWSLoadBalancerControllerIAMPolicyNew
    export IAM_SA=aws-load-balancer-controller
      
  2. Create an AWS IAM policy and bind it to a Kubernetes service account.

      # Set up an IAM OIDC provider for a cluster to enable IAM roles for pods
    eksctl utils associate-iam-oidc-provider \
     --region ${REGION} \
     --cluster ${CLUSTER_NAME} \
     --approve
    
    # Fetch the IAM policy that is required for the Kubernetes service account
    curl -o iam-policy.json https://raw.githubusercontent.com/kubernetes-sigs/aws-load-balancer-controller/v2.5.3/docs/install/iam_policy.json
    
    # Create the IAM policy
    aws iam create-policy \
     --policy-name ${IAM_POLICY_NAME} \
     --policy-document file://iam-policy.json
    
    # Create the Kubernetes service account
    eksctl create iamserviceaccount \
     --cluster=${CLUSTER_NAME} \
     --namespace=kube-system \
     --name=${IAM_SA} \
     --attach-policy-arn=arn:aws:iam::${AWS_ACCOUNT_ID}:policy/${IAM_POLICY_NAME} \
     --override-existing-serviceaccounts \
     --approve \
     --region ${REGION}
      
  3. Verify that the service account is created in your cluster.

      kubectl -n kube-system get sa aws-load-balancer-controller -o yaml
      
  4. Deploy the AWS Load Balancer Controller.

      kubectl apply -k "github.com/aws/eks-charts/stable/aws-load-balancer-controller/crds?ref=master"
    
    helm repo add eks https://aws.github.io/eks-charts
    helm repo update
    helm install aws-load-balancer-controller eks/aws-load-balancer-controller \
      -n kube-system \
      --set clusterName=${CLUSTER_NAME} \
      --set serviceAccount.create=false \
      --set serviceAccount.name=${IAM_SA}
      

Step 2: Deploy your gateway proxy

  1. Create a GlooGatewayParameters resource with custom AWS annotations. These annotations instruct the AWS load balancer controller to expose the gateway proxy with a public-facing AWS NLB.

      kubectl apply -f- <<EOF
    apiVersion: gloo.solo.io/v1alpha1
    kind: GlooGatewayParameters
    metadata:
      name: custom-gw-params
      namespace: gloo-system
    spec:
      kube: 
        service:
          extraAnnotations:
            service.beta.kubernetes.io/aws-load-balancer-type: "external" 
            service.beta.kubernetes.io/aws-load-balancer-scheme: internet-facing 
            service.beta.kubernetes.io/aws-load-balancer-nlb-target-type: "instance"
    EOF
      
    SettingDescription
    aws-load-balancer-type: "external"Instruct Kubernetes to pass the Gateway’s service configuration to the AWS load balancer controller that you created earlier instead of using the built-in capabilities in Kubernetes. For more information, see the AWS documentation.
    aws-load-balancer-scheme: internet-facingCreate the NLB with a public IP addresses that is accessible from the internet. For more information, see the AWS documentation.
    aws-load-balancer-nlb-target-type: "instance"Use the Gateway’s instance ID to register it as a target with the NLB. For more information, see the AWS documentation.
  2. Depending on the annotations that you use on your gateway proxy, you can configure the NLB in different ways.

  3. Verify that your gateway is created.

      kubectl get gateway aws-cloud -n gloo-system
      
  4. Verify that the gateway service is exposed with an AWS NLB and assigned an AWS hostname.

      kubectl get services aws-cloud -n gloo-system
      

    Example output:

      NAME        TYPE           CLUSTER-IP      EXTERNAL-IP                                                                     PORT(S)        AGE
    aws-cloud   LoadBalancer   172.20.39.233   k8s-gloosyst-awscloud-edaaecf0c5-2d48d93624e3a4bf.elb.us-east-2.amazonaws.com   80:30565/TCP   12s
      
  5. Review the NLB in the AWS EC2 dashboard.

    1. Go to the AWS EC2 dashboard.
    2. In the left navigation, go to Load Balancing > Load Balancers.
    3. Find and open the NLB that was created for you, with a name such as k8s-gloosyst-awscloud-<hash>.
    4. On the Resource map tab, verify that the load balancer points to EC2 targets in your cluster. For example, you can click on the target EC2 name to verify that the instance summary lists your cluster name.

Step 3: Test traffic to the NLB

Cleanup

You can remove the resources that you created in this guide.
  1. Delete the Ingress and Gateway resources.

      kubectl delete GlooGatewayParameters custom-gw-params -n gloo-system
    kubectl delete gateway aws-cloud -n gloo-system
    kubectl delete httproute httpbin-elb -n httpbin
    kubectl delete secret https -n gloo-system
      
  2. Delete the AWS IAM resources that you created.

      aws iam delete-policy --policy-arn=arn:aws:iam::${AWS_ACCOUNT_ID}:policy/${IAM_POLICY_NAME}
    eksctl delete iamserviceaccount --name=${IAM_SA} --cluster=${CLUSTER_NAME}
      
  3. Uninstall the Helm release for the aws-load-balancer-controller.

      helm uninstall aws-load-balancer-controller -n kube-system