title: Unable to access exposed port on kubernetes
body: <p>I have build a custom tcserver image exposing port 80 8080 and 8443. Basically you have an apache and inside the configuration you have a proxy pass to forward it to the tcserver tomcat.<br/></p>
  
  <pre><code>EXPOSE 80 8080 8443
  </code></pre>
  
  <p>After that I created a kubernetes yaml to build the pod exposing only port 80.</p>
  
  <pre><code>apiVersion: v1
  kind: Pod
  metadata:
    name: tcserver
    namespace: default
  spec:
    containers:
    - name: tcserver
      image: tcserver-test:v1
      imagePullPolicy: IfNotPresent
      ports:
      - containerPort: 80
  </code></pre>
  
  <p>And the service along with it.</p>
  
  <pre><code>apiVersion: v1
  kind: Service
  metadata:
    name: tcserver-svc
    labels:
      app: tcserver
  spec:
    type: NodePort
    ports:
    - port: 80
      nodePort: 30080
    selector:
      app: tcserver
  </code></pre>
  
  <p>But the problem is that I'm unable to access it.<br/>
  If I log to the pod (<code>kubectl exec -it tcserver -- /bin/bash</code>), I'm able to do a <code>curl -k -v http://localhost</code> and it will reply.<br/><br/></p>
  
  <p>I believe I'm doing something wrong with the service, but I don't know what.<br/>
  Any help will be appreciated. </p>
  
  <p><strong>SVC change</strong> <br/>
  As suggested by sfgroups, I added the <code>targetPort: 80</code> to the svc, but still not working.</p>
  
  <p>When I try to curl the IP, I get a <strong>No route to host</strong></p>
  
  <pre><code>[root@testmaster tcserver]# curl -k -v http://172.30.62.162:30080/
  * About to connect() to 172.30.62.162 port 30080 (#0)
  *   Trying 172.30.62.162...
  * No route to host
  * Failed connect to 172.30.62.162:30080; No route to host
  * Closing connection 0
  curl: (7) Failed connect to 172.30.62.162:30080; No route to host
  </code></pre>
  
  <p>This is the describe from the svc:</p>
  
  <pre><code>[root@testmaster tcserver]# kubectl describe svc tcserver-svc
  Name:                   tcserver-svc
  Namespace:              default
  Labels:                 app=tcserver
  Annotations:            &lt;none&gt;
  Selector:               app=tcserver
  Type:                   NodePort
  IP:                     172.30.62.162
  Port:                   &lt;unset&gt; 80/TCP
  NodePort:               &lt;unset&gt; 30080/TCP
  Endpoints:              &lt;none&gt;
  Session Affinity:       None
  Events:                 &lt;none&gt;
  </code></pre>