<p>When I build a Kubernetes service in two steps (1. replication controller; 2. expose the replication controller) my exposed service gets an external IP address:</p>

<pre><code>initially:
    NAME         CLUSTER_IP     EXTERNAL_IP     PORT(S)   SELECTOR    AGE
    app-1        10.67.241.95                   80/TCP    app=app-1    7s
</code></pre>

<p>and after about 30s:</p>

<pre><code>NAME         CLUSTER_IP     EXTERNAL_IP     PORT(S)   SELECTOR    AGE
app-1        10.67.241.95   104.155.93.79   80/TCP    app=app-1   35s
</code></pre>

<p>But when I do it in one step providing the <code>Service</code> and the <code>ReplicationController</code> to the <code>kubectl create -f dir_with_2_files</code> the service gets created but it does not get and External IP:</p>

<pre><code>NAME         CLUSTER_IP      EXTERNAL_IP   PORT(S)   SELECTOR    AGE
app-1        10.67.251.171   &lt;none&gt;        80/TCP    app=app-1   2m
</code></pre>

<p>The <code>&lt;none&gt;</code> under External IP worries me.</p>

<p>For the Service I use the JSON file:</p>

<pre><code>{                                                                                                                 
    "apiVersion": "v1",                                                                                           
    "kind": "Service",                                                                                            
    "metadata": {                                                                                                 
        "name": "app-1"                                                                                           
    },                                                                                                            
    "spec": {                                                                                                     
        "selector": {
            "app": "app-1"
        },
        "ports": [                                                                                                
            {                                                                                                     
                "port": 80,                                                                                       
                "targetPort": 8000                                                                                
            }                                                                                                     
        ]
    }                                                                                                             
}
</code></pre>

<p>and for the ReplicationController:</p>

<pre><code>{
    "apiVersion": "v1",
    "kind": "ReplicationController",
    "metadata": {
        "name": "app-1"
    },
    "spec": {
        "replicas": 1,
        "template": {
            "metadata": {
                "labels": {
                    "app": "app-1"
                }
            },
            "spec": {
                "containers": [
                    {
                        "name": "service",
                        "image": "gcr.io/sigma-cairn-99810/service:latest",
                        "ports": [
                            {
                                "containerPort": 8000
                            }
                        ]
                    }
                ]
            }
        }
    }
}
</code></pre>

<p>and to expose the Service manually I use the command:</p>

<pre><code>kubectl expose rc app-1 --port 80 --target-port=8000 --type="LoadBalancer"
</code></pre>

<p>If you don't specify the type of a Service it defaults to ClusterIP. If you want the equivalent of <code>expose</code> you must:</p>

<ol>
<li>Make sure your Service selects pods from the RC via matching label selectors</li>
<li>Make the Service <code>type=LoadBalancer</code></li>
</ol>
