<p>I have created a deployment for jenkins in Kubernetes.
The pod is running fine, I've created a service to access jenkins on service-ip:8080 but it seems not to work.
When I create an <code>ingress</code> above the service I can access it using the public ip.</p>

<pre><code>kind: Service
apiVersion: v1
metadata:
  name: jenkins-ui
  namespace: jenkins
spec:
  type: NodePort
  selector:
    app: jenkins
  ports:
    - protocol: TCP
      port: 8080
      targetPort: 8080
      name: ui
</code></pre>

<p>I created my service as described above:</p>

<pre><code>$ kubectl get svc --namespace=jenkins

NAME               TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)          AGE
jenkins-ui         NodePort    10.47.xx.xx     &lt;none&gt;        8080:30960/TCP   1d
</code></pre>

<p>I tried to access: <code>10.47.xx.xx:8080</code> but I was not able to access the jenkins UI. What am I doing wrong? I also tried <code>10.47.xx.xx:30960</code></p>

<p>I want to access my jenkins UI using a service but I want to keep it private in my cluster. (ingress makes it public).</p>

<p>UPDATE:</p>

<pre><code>$ kubectl describe svc jenkins-ui --namespace jenkins
Name:                     jenkins-ui
Namespace:                jenkins
Labels:                   &lt;none&gt;
Annotations:              &lt;none&gt;
Selector:                 app=jenkins
Type:                     NodePort
IP:                       10.47.xx.xx    Port:                     ui  8080/TCP
TargetPort:               8080/TCP
NodePort:                 ui  30960/TCP
Endpoints:                10.44.10.xx:8080
Session Affinity:         None
External Traffic Policy:  Cluster
Events:                   &lt;none&gt;
</code></pre>

<p>accessing the pod on 10.44.10.xx:8080 does not work too.</p>

<p>If I understand correctly, you want any container running in your cluster to be able to access your jenkins service, but you don't want your jenkins service to be accessible outside your cluster to something like your browser?</p>

<p>In this case:</p>

<pre><code>curl http://jenkins-ui.default:8080
curl http://10.47.10.xx:8080
</code></pre>

<p>will work perfectly fine from <strong><em>inside any container in your kubernetes cluster</em></strong>.</p>

<p>Also, you cannot access it <code>10.47.10.xx:8080</code> from outside your cluster because that IP is only valid/available inside your kubernetes cluster.</p>

<p>If you want to access it from outside the cluster an ingress controller or to connect on <code>http://&lt;node-ip&gt;: 30960</code> is the only way to connect to the <code>jenkins-ui</code> k8s service and thus the pod behind it.</p>

<p><strong>EDIT:</strong> Use kubectl port-forward</p>

<p>In development mode, if you want to access a container running internally, you can use <code>kubectl port-forward</code>:</p>

<pre><code>kubectl port-forward &lt;jenkins-ui-pod&gt; 9090:8080
</code></pre>

<p>This way, <code>http://localhost:9090</code> will show you the jenkins-ui screen because you have kubectl access.</p>

<p><code>kubectl port-forward</code> doesn't work for services yet: <a href="https://github.com/kubernetes/kubernetes/issues/15180" rel="noreferrer">https://github.com/kubernetes/kubernetes/issues/15180</a></p>
