<p>I've created a Kubernetes cluster with AWS ec2 instances using kubeadm but when I try to create a service with type LoadBalancer I get an EXTERNAL-IP pending status</p>
<pre><code>NAME         TYPE           CLUSTER-IP      EXTERNAL-IP   PORT(S)         AGE
kubernetes   ClusterIP      10.96.0.1       &lt;none&gt;        443/TCP         123m
nginx        LoadBalancer   10.107.199.170  &lt;pending&gt;     8080:31579/TCP  45m52s
</code></pre>
<p>My create command is</p>
<pre><code>kubectl expose deployment nginx --port 8080 --target-port 80 --type=LoadBalancer
</code></pre>
<p>I'm not sure what I'm doing wrong.</p>
<p>What I expect to see is an EXTERNAL-IP address given for the load balancer.</p>
<p>Has anyone had this and successfully solved it, please?</p>
<p>Thanks.</p>

<p>You need to setup the <strong>interface</strong> between k8s and AWS which is a<a href="https://github.com/kubernetes/cloud-provider-aws#readme" rel="noreferrer">ws-cloud-provider-controller</a>.</p>
<pre><code>apiVersion: kubeadm.k8s.io/v1beta1
kind: InitConfiguration
nodeRegistration:
  kubeletExtraArgs:
    cloud-provider: aws
</code></pre>
<p>More details can be found:</p>
<ul>
<li><a href="https://kubernetes.io/docs/concepts/cluster-administration/cloud-providers/" rel="noreferrer">https://kubernetes.io/docs/concepts/cluster-administration/cloud-providers/</a></li>
<li><a href="https://blog.heptio.com/setting-up-the-kubernetes-aws-cloud-provider-6f0349b512bd" rel="noreferrer">https://blog.heptio.com/setting-up-the-kubernetes-aws-cloud-provider-6f0349b512bd</a></li>
<li><a href="https://blog.scottlowe.org/2019/02/18/kubernetes-kubeadm-and-the-aws-cloud-provider/" rel="noreferrer">https://blog.scottlowe.org/2019/02/18/kubernetes-kubeadm-and-the-aws-cloud-provider/</a></li>
<li><a href="https://itnext.io/kubernetes-part-2-a-cluster-set-up-on-aws-with-aws-cloud-provider-and-aws-loadbalancer-f02c3509f2c2" rel="noreferrer">https://itnext.io/kubernetes-part-2-a-cluster-set-up-on-aws-with-aws-cloud-provider-and-aws-loadbalancer-f02c3509f2c2</a></li>
</ul>
<p>Once you finish this setup, you will have the luxury to control not only the creation of AWS LB for each k8s service with type LoadBalancer.. But also , you will be able to control many things using <strong>annotations</strong>.</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: example
  namespace: kube-system
  labels:
    run: example
  annotations:
     service.beta.kubernetes.io/aws-load-balancer-ssl-cert: arn:aws:acm:xx-xxxx-x:xxxxxxxxx:xxxxxxx/xxxxx-xxxx-xxxx-xxxx-xxxxxxxxx #replace this value
     service.beta.kubernetes.io/aws-load-balancer-backend-protocol: http
spec:
  type: LoadBalancer
  ports:
  - port: 443
    targetPort: 5556
    protocol: TCP
  selector:
    app: example
</code></pre>
<p><a href="https://kubernetes.io/docs/concepts/cluster-administration/cloud-providers/#aws" rel="noreferrer">Different settings can be applied to a load balancer service in AWS using <strong>annotations</strong>.</a></p>
