2
votes

I have to create a Kubernetes cluster in MS Azure manually, not using AKS. So:

  1. I've created 2 VM's in one Availability set: one for k8s master and second for k8s node.
  2. I've created External Load Balancer and add 2 VM's to the backend pool.
  3. I've created k8s cluster using kubespray.
  4. I've created Deployment and LoadBalancer Service:

    apiVersion: apps/v1beta1
    kind: Deployment
    metadata:
      name: wrapper
    spec:
      replicas: 2
      template:
        metadata:
          labels:
            app: wrapper
        spec:
          containers:
          - name: wrapper
            image: wrapper:latest
            ports:
            - containerPort: 8080
              name: wrapper
    ---
    apiVersion: v1
    kind: Service
    metadata:
      name: wrapper
    spec:
      loadBalancerIP: <azure_loadbalancer_public_ip>
      type: LoadBalancer
      ports:
      - port: 8080
      selector:
        app: wrapper
    

But LoadBalancer service External-IP is always pending:

kubectl get services
NAME         TYPE           CLUSTER-IP    EXTERNAL-IP
wrapper      LoadBalancer   10.233.38.7   <pending>

Also, telnet azure_loadbalancer_public_ip doesn't work. I've tried to use NodePort instead of LoadBalancer, but in that case, I have two endpoints for my service on k8s master and on k8s node.

What I want is one entrypoint: azure_loadbalancer_public_ip, that is balances traffic between all nodes in the cluster.

Could you please help me to understand what I'm doing wrong and is it possible to "bind" Azure External Load Balancer with LoadBalancer service in Kubernetes?

2

2 Answers

0
votes

You dont have to do that, k8s (when its configured properly) handles that for you. All you have to do it give it proper rights to be able to create a load balancer in Azure.

0
votes

It basically can't talk to the Azure API to create a Load Balancer. You basically need to:

  1. Add this option: --cloud-provider=azure to your kube-apiserver, kube-controller-manager and all the kubelets running on your nodes.
  2. Make sure that your Azure VM has access to the Azure API
  3. Restart all the components from 1.

This is not needed if you have the Cloud Controller Manager installed which is Beta in K8s 1.12 as of this writing. Note that the --cloud-provider option will be deprecated at some point in favor of this.