<p>I have the following service: </p>

<pre><code>NAME      TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)   AGE
rancher   ClusterIP   10.245.162.197   &lt;none&gt;        80/TCP    10h
</code></pre>

<p>that I would like to assign an <strong>EXTERNAL-IP</strong> to it. I tried:</p>

<pre><code>kubectl expose deployment rancher --type=LoadBalancer --name=rancher-access
</code></pre>

<p>but the <strong>EXTERNAL-IP</strong> does not still get assigned. I am using Digital Ocean Kubernetes.<br>
How to get an <strong>EXTERNAL-IP</strong> for <code>rancher</code> service.</p>

softshipper
<p>You have two options:</p>

<ol>
<li>The LoadBalancer type of service is implemented by adding code to the kubernetes master specific to each cloud provider. There isn't a cloud provider for Digital Ocean <a href="https://github.com/kubernetes/kubernetes/blob/master/pkg/cloudprovider/providers/providers.go" rel="nofollow noreferrer">supported cloud providers</a>, so the LoadBalancer type will not be able to take advantage of Digital Ocean's Floating IPs.</li>
</ol>

<p>Instead, you should consider using a <a href="https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport" rel="nofollow noreferrer">NodePort</a> service or attaching an <a href="https://kubernetes.io/docs/concepts/services-networking/service/#external-ips" rel="nofollow noreferrer">ExternalIP</a> to your service and mapping the exposed IP to a Digital Ocean's floating IP.</p>

<p>To get the actual IP you need to expose you need to ssh into your gateway droplet and find its anchor IP by hitting up the metadata service:</p>

<pre><code>curl -s http://169.254.169.254/metadata/v1/interfaces/public/0/anchor_ipv4/address
</code></pre>

<ol start="2">
<li><p>Use Digital Ocean created <a href="https://github.com/digitalocean/digitalocean-cloud-controller-manager#kubernetes-cloud-controller-manager-for-digitalocean" rel="nofollow noreferrer">cloud provider implementation</a></p></li>
<li><p>You could use an NGINX ingress controller and point a DigitalOcean LB to the host where the controller is deployed. With some more tinkering you could probably make this a highly available setup</p></li>
</ol>

<p><a href="https://github.com/hobby-kube/guide#bringing-traffic-to-the-cluster" rel="nofollow noreferrer">https://github.com/hobby-kube/guide#bringing-traffic-to-the-cluster</a></p>
