title: How does kubernetes select nodes to add to the load balancers on AWS?
body: <p>Some info:</p>
  
  <ul>
  <li>Kubernetes (1.5.1)</li>
  <li>AWS</li>
  <li>1 master and 1 node (both ubuntu 16.04)</li>
  <li>k8s installed via kubeadm</li>
  <li>Terraform made by me</li>
  </ul>
  
  <p>Please don't reply use kube-up, kops or similar. This is about understanding how k8s works under the hood. There is by far too much unexplained magic in the system and I want to understand it.</p>
  
  <p>== Question:</p>
  
  <p>When creating a Service of type load balancer on k8s[aws] (for example):</p>
  
  <pre><code>apiVersion: v1
  kind: Service
  metadata:
    name: kubernetes-dashboard
    namespace: kube-system
    labels:
      k8s-addon: kubernetes-dashboard.addons.k8s.io
      k8s-app: kubernetes-dashboard
      kubernetes.io/cluster-service: "true"
      facing: external
  spec:
    type: LoadBalancer
    selector:
      k8s-app: kubernetes-dashboard
    ports:
    - port: 80
  </code></pre>
  
  <p>I successfully create an internal or external facing ELB but none of the machines are added to the ELB (I can taint the master too but nothing changes). My problem is basically this:</p>
  
  <p><a href="https://github.com/kubernetes/kubernetes/issues/29298#issuecomment-260659722" rel="noreferrer">https://github.com/kubernetes/kubernetes/issues/29298#issuecomment-260659722</a></p>
  
  <p>The subnets and nodes (but not the VPC) are all tagged with "KubernetesCluster" (again... elb are created in the right place). However no nodes is added.</p>
  
  <p>In the logs </p>
  
  <pre><code>kubectl logs kube-controller-manager-ip-x-x-x-x -n kube-system
  </code></pre>
  
  <p>after:</p>
  
  <pre><code>aws_loadbalancer.go:63] Creating load balancer for 
  kube-system/kubernetes-dashboard with name:
  acd8acca0c7a111e69ca306f22de69ae
  </code></pre>
  
  <p>There is no other output (it should print the nodes added or removed). I tried to understand the code at: </p>
  
  <p><a href="https://github.com/kubernetes/kubernetes/blob/master/pkg/cloudprovider/providers/aws/aws_loadbalancer.go" rel="noreferrer">https://github.com/kubernetes/kubernetes/blob/master/pkg/cloudprovider/providers/aws/aws_loadbalancer.go</a>
  But whatever is the reason, this function to not add nodes.</p>
  
  <p>The documentation doesn't go at length trying to explain the "process" behind k8s decisions. To try to understand k8s I tried/used kops, kube up, kubeadm, kubernetes the hard way repo and reading damn code, but still I am unable to understand how k8s on aws SELECTS the node to add to the elb.</p>
  
  <p>As a consequence, also no security group is changed anywhere.</p>
  
  <p>Is it a tag on the ec2?
  Kublet setting?
  Anything else?</p>
  
  <p>Any help is greatly appreciated.</p>
  
  <p>Thanks,
  F.</p>