Logo
OpenScaler

Configuring Load Balancer

In order to expose your kubernetes ingress to the public internet, you need to create a load balancer service for your cluster.

Add a Load Balancer to your Cluster

Create Load Balancer

Head over to your cluster dashboard, and navigate to the "Networking" tab.

Cluster Dashboard

From here, click on "Create Load Balancer" button

Configure kubectl context

Download kubeconfig file and set kubectl context

export KUBECONFIG='/path/to/your/kubeconfig'

Install Ingress Controller

Install your favorite ingress controller. For this example, we will use the NGINX ingress controller.

kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/main/deploy/static/provider/cloud/deploy.yaml

Change node ports for HTTP and HTTPS

You need to change the node ports for HTTP and HTTPS to 32080 and 32443 respectively. Simply run the following command:

kubectl patch svc ingress-nginx-controller -n ingress-nginx --patch '{
  "spec": {
    "ports": [
      {
        "name": "http",
        "port": 80,
        "targetPort": "http",
        "nodePort": 32080
      },
      {
        "name": "https",
        "port": 443,
        "targetPort": "https",
        "nodePort": 32443
      }
    ],
    "type": "NodePort"
  }
}'

Note that you'll be able to access your domain names with forwarded ports. For example: 80 → 9009 and 443 → 9003. For example, if your domain is my.domain.com, you should use http://my.domain.com:9009 for HTTP access, and https://my.domain.com:9003 for HTTPS access.

See Also

Kubernetes Sample App

Try out a sample app to test your load balancer.

On this page