<p>I use <strong>kubeadm</strong> to launch cluster on <strong>AWS</strong>. I can successfully create a load balancer on <strong>AWS</strong> by using <strong>kubectl</strong>, but the load balancer is not registered with any EC2 instances. That causes problem that the service cannot be accessed from public. </p>

<p>From the observation, when the ELB is created, it cannot find any healthy instances under all subnets. I am pretty sure I tag all my instances correctly. </p>

<p><strong>Updated</strong>: I am reading the log from <strong>k8s-controller-manager</strong>, it shows my node does not have ProviderID set. And according to <a href="https://github.com/kubernetes/kubernetes/blob/82c986ecbcdf99a87cd12a7e2cf64f90057b9acd/pkg/cloudprovider/providers/aws/aws_loadbalancer.go#L1477" rel="noreferrer">Github</a> comment, ELB will ignore nodes where instance ID cannot be determined from provider. Could this cause the issue? How Should I set the providerID?  </p>

<h2>load balancer configuration</h2>

<pre><code>apiVersion: v1                                                                                                                                                                                                                                                                        
kind: Service                                                                                                                                                                                                                                                                         
metadata:                                                                                                                                                                                                                                                                             
  name: load-balancer                                                                                                                                                                                                                                                           
  annotations:                                                                                                                                                                                                                                                                        
    service.beta.kubernetes.io/aws-load-balancer-type: "elb"                                                                                                                                                                                                                          
spec:                                                                                                                                                                                                                                                                                 
  ports:                                                                                                                                                                                                                                                                              
  - name: http                                                                                                                                                                                                                                                                        
    port: 80                                                                                                                                                                                                                                                                          
    protocol: TCP                                                                                                                                                                                                                                                                     
    targetPort: 80                                                                                                                                                                                                                                                                    
  - name: https                                                                                                                                                                                                                                                                       
    port: 443                                                                                                                                                                                                                                                                         
    protocol: TCP                                                                                                                                                                                                                                                                     
    targetPort: 443                                                                                                                                                                                                                                                                   
  selector:                                                                                                                                                                                                                                                                           
    app: replica                                                                                                                                                                                                                                                                
  type: LoadBalancer
</code></pre>

<h2>deployment configuration</h2>

<pre><code>apiVersion: apps/v1                                                                                                                                                                                                                                                                   
kind: Deployment                                                                                                                                                                                                                                                                      
metadata:                                                                                                                                                                                                                                                                             
  name: replica-deployment                                                                                                                                                                                                                                                      
  labels:                                                                                                                                                                                                                                                                             
    app: replica                                                                                                                                                                                                                                                                
spec:                                                                                                                                                                                                                                                                                 
  replicas: 1                                                                                                                                                                                                                                                                         
  selector:                                                                                                                                                                                                                                                                           
    matchLabels:                                                                                                                                                                                                                                                                      
      app: replica                                                                                                                                                                                                                                                              
  template:                                                                                                                                                                                                                                                                           
    metadata:                                                                                                                                                                                                                                                                         
      labels:                                                                                                                                                                                                                                                                         
        app: replica                                                                                                                                                                                                                                                            
    spec:                                                                                                                                                                                                                                                                             
      containers:                                                                                                                                                                                                                                                                     
        - name: web                                                                                                                                                                                                                                                   
          image: web                                                                                                                                                                                                                                                                  
          imagePullPolicy: IfNotPresent                                                                                                                                                                                                                                         
          ports:                                                                                                                                                                                                                                                                      
          - containerPort: 80                                                                                                                                                                                                                                                         
          - containerPort: 443                                                                                                                                                                                                                                                        
          command: ["/bin/bash"]                                                                                                                                                                                                                                                      
          args: ["-c", "script_to_start_server.sh"]
</code></pre>

<h2>node output <code>status</code> section</h2>

<pre><code>status:                                                                                                                                                                                                                                                                               
  addresses:                                                                                                                                                                                                                                                                          
  - address: 172.31.35.209                                                                                                                                                                                                                                                            
    type: InternalIP                                                                                                                                                                                                                                                                  
  - address: k8s                                                                                                                                                                                                                                                                      
    type: Hostname                                                                                                                                                                                                                                                                    
  allocatable:                                                                                                                                                                                                                                                                        
    cpu: "4"                                                                                                                                                                                                                                                                          
    ephemeral-storage: "119850776788"                                                                                                                                                                                                                                                 
    hugepages-1Gi: "0"                                                                                                                                                                                                                                                                
    hugepages-2Mi: "0"                                                                                                                                                                                                                                                                
    memory: 16328856Ki                                                                                                                                                                                                                                                                
    pods: "110"                                                                                                                                                                                                                                                                       
  capacity:                                                                                                                                                                                                                                                                           
    cpu: "4"                                                                                                                                                                                                                                                                          
    ephemeral-storage: 130046416Ki                                                                                                                                                                                                                                                    
    hugepages-1Gi: "0"                                                                                                                                                                                                                                                                
    hugepages-2Mi: "0"                                                                                                                                                                                                                                                                
    memory: 16431256Ki                                                                                                                                                                                                                                                                
    pods: "110"                                                                                                                                                                                                                                                                       
  conditions:                                                                                                                                                                                                                                                                         
  - lastHeartbeatTime: 2018-07-12T04:01:54Z                                                                                                                                                                                                                                           
    lastTransitionTime: 2018-07-11T15:45:06Z                                                                                                                                                                                                                                          
    message: kubelet has sufficient disk space available                                                                                                                                                                                                                              
    reason: KubeletHasSufficientDisk                                                                                                                                                                                                                                                  
    status: "False"                                                                                                                                                                                                                                             
    type: OutOfDisk                                                                                                                                                                                                                                                                   
  - lastHeartbeatTime: 2018-07-12T04:01:54Z                                                                                                                                                                                                                                           
    lastTransitionTime: 2018-07-11T15:45:06Z                                                                                                                                                                                                                                          
    message: kubelet has sufficient memory available                                                                                                                                                                                                                                  
    reason: KubeletHasSufficientMemory                                                                                                                                                                                                                                                
    status: "False"                                                                                                                                                                                                                                                                   
    type: MemoryPressure
  - lastHeartbeatTime: 2018-07-12T04:01:54Z
    lastTransitionTime: 2018-07-11T15:45:06Z
    message: kubelet has no disk pressure
    reason: KubeletHasNoDiskPressure
    status: "False"
    type: DiskPressure
  - lastHeartbeatTime: 2018-07-12T04:01:54Z
    lastTransitionTime: 2018-07-11T15:45:06Z
    message: kubelet has sufficient PID available
    reason: KubeletHasSufficientPID
    status: "False"
    type: PIDPressure
  - lastHeartbeatTime: 2018-07-12T04:01:54Z
    lastTransitionTime: 2018-07-11T15:45:06Z
    message: kubelet is posting ready status. AppArmor enabled
    reason: KubeletReady
    status: "True"
    type: Ready
</code></pre>

<p>How can I fix the issue?</p>

<p>Thanks!</p>

jiashenC
<p>In My case the issue was with the worker nodes not getting the providerId assigned properly.</p>

<p>I managed to patch the node like - kubectl patch node ip-xxxxx.ap-southeast-2.compute.internal -p '{"spec":{"providerID":"aws:///ap-southeast-2a/i-0xxxxx"}}'</p>

<p>to add the ProviderID. And then when i deployed the service . The ELB got created. the node group got added and end to end it worked. This is not a straight forward answer . But until i find a better solution let remain here</p>
