<p>I can do a deploy like this, but cannot do it via command line.</p>

<p><a href="https://i.stack.imgur.com/wYbrE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wYbrE.png" alt=""></a>
</p>

<p>I was looking at doing it like this</p>

<pre><code>kubectl create -f kubernetes-rc.json
</code></pre>

<hr>

<pre><code>{
  "kind": "ReplicationController",
  "apiVersion": "v1",
  "metadata": {
    "name": "foo-frontend-rc",
    "labels": {
      "www": true
    },
    "namespace": "foo"
  },
  "spec": {
    "replicas": 1,
    "template": {
      "metadata": {
        "labels": {
          "app": "foo-frontend"
        }
      },
      "spec": {
        "containers": [
          {
            "name": "foo-frontend",
            "image": "gcr.io/atomic-griffin-130023/foo-frontend:b3fc862",
            "ports": [
              {
                "containerPort": 3009,
                "protocol": "TCP"
              }
            ],
            "imagePullPolicy": "IfNotPresent"
          }
        ],
        "restartPolicy": "Always",
        "dnsPolicy": "ClusterFirst"
      }
    }
  }
}
</code></pre>

<hr>

<p>and</p>

<pre><code>kubectl create -f kubernetes-service.json
</code></pre>

<hr>

<pre><code>{
  "kind": "Service",
  "apiVersion": "v1",
  "metadata": {
    "name": "foo-frontend-service"
  },
  "spec": {
    "selector": {
      "app": "foo-frontend-rc"
    },
    "ports": [
      {
        "protocol": "TCP",
        "port": 80,
        "targetPort": 3009
      }
    ]
  }
}
</code></pre>

<p>to no avail. It creates the <code>rc</code>, but it won’t expose the service externally.</p>

<p>Your service's selector is wrong. It should be selecting a label from the pod template, not a label on the RC itself.</p>

<p>If you change the following in your service:</p>

<pre><code>"selector": {
  "app": "foo-frontend-rc"
},
</code></pre>

<p>to:</p>

<pre><code>"selector": {
  "app": "foo-frontend"
},
</code></pre>

<p>It should fix it.</p>

<hr>

<h2>Update</h2>

<p>Change your service definition to</p>

<pre><code>{
  "kind": "Service",
  "apiVersion": "v1",
  "metadata": {
    "name": "foo-frontend-service"
  },
  "spec": {
    "selector": {
      "app": "foo-frontend"
    },
    "ports": [
      {
        "protocol": "TCP",
        "port": 80,
        "targetPort": 3009,
        "nodePort": 30009
      }
    ],
    "type": "LoadBalancer"
  }
}
</code></pre>
