<p>So I got a running cluster on my server. The server is running <code>ubuntu 18.06</code>. <strong>I set up the cluster using <code>kubeadm</code>, <code>kubectl</code> and <code>kubelet</code>.</strong></p>

<p><strong>My goal in a nutshell: I want to reach the services with executing <code>http://myserver.com/service</code>.</strong></p>

<p>I am kinda lost with exposing the services to port 8080. The current structure is like this:</p>

<blockquote>
  <p>31001:SERVICE:8080 -> 8080:POD</p>
</blockquote>

<p>So I need to redirect the requests incoming using <code>http://myserver.com/service</code> to the <code>kubernetes service</code> with port 31001.</p>

<p>Current situation: I can only access the cluster via server IP:6443. All pods, services and so forth are up and running.</p>

<p><strong>So my question: how can I make the services more or less public available on port 8080?</strong></p>

<p>As requested below:</p>

<blockquote>
  <p>Output of <code>kubectl get all --all-namespaces -o wide</code></p>
</blockquote>

<pre><code>NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE     IP              NODE                         NOMINATED NODE   READINESS GATES
default       pod/articleservice-deployment-6d48989664-jbzs6           1/1     Running   0          5h56m   192.168.0.4     server.address.com           &lt;none&gt;           &lt;none&gt;
default       pod/cartservice-deployment-6b844f45b8-jz45h              1/1     Running   0          5h56m   192.168.0.5     server.address.com           &lt;none&gt;           &lt;none&gt;
default       pod/catalogservice-deployment-d4bd6984c-6qlqg            1/1     Running   0          5h56m   192.168.0.6     server.address.com           &lt;none&gt;           &lt;none&gt;
default       pod/customerservice-deployment-7d6f77fdbb-p42xj          1/1     Running   0          5h56m   192.168.0.7     server.address.com           &lt;none&gt;           &lt;none&gt;
kube-system   pod/calico-node-5rl9m                                    2/2     Running   0          5h58m   999.999.99.99   server.address.com           &lt;none&gt;           &lt;none&gt;
kube-system   pod/coredns-86c58d9df4-h64fg                             1/1     Running   0          6h10m   192.168.0.2     server.address.com           &lt;none&gt;           &lt;none&gt;
kube-system   pod/coredns-86c58d9df4-pwfj4                             1/1     Running   0          6h10m   192.168.0.3     server.address.com           &lt;none&gt;           &lt;none&gt;
kube-system   pod/etcd-server.address.net                              1/1     Running   0          6h9m    999.999.99.99   server.address.com           &lt;none&gt;           &lt;none&gt;
kube-system   pod/kube-apiserver-server.address.net                    1/1     Running   0          6h10m   999.999.99.99   server.address.com           &lt;none&gt;           &lt;none&gt;
kube-system   pod/kube-controller-manager-server.address.net           1/1     Running   0          6h9m    999.999.99.99   server.address.com           &lt;none&gt;           &lt;none&gt;
kube-system   pod/kube-proxy-xb2qc                                     1/1     Running   0          6h10m   999.999.99.99   server.address.com           &lt;none&gt;           &lt;none&gt;
kube-system   pod/kube-scheduler-server.address.net                    1/1     Running   0          6h9m    999.999.99.99   server.address.com           &lt;none&gt;           &lt;none&gt;

NAMESPACE     NAME                      TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)                          AGE     SELECTOR
default       service/articleservice    NodePort    10.97.125.155   &lt;none&gt;        31001:31001/TCP,5005:32001/TCP   5h57m   app=articleservice
default       service/cartservice       NodePort    10.99.42.169    &lt;none&gt;        31002:31002/TCP,5005:32002/TCP   5h57m   app=cartservice
default       service/catalogservice    NodePort    10.106.101.93   &lt;none&gt;        31003:31003/TCP,5005:32003/TCP   5h57m   app=catalogservice
default       service/customerservice   NodePort    10.106.2.159    &lt;none&gt;        31004:31004/TCP,5005:32004/TCP   5h57m   app=customerservice
default       service/kubernetes        ClusterIP   10.96.0.1       &lt;none&gt;        443/TCP                          6h11m   &lt;none&gt;
kube-system   service/calico-typha      ClusterIP   10.96.242.31    &lt;none&gt;        5473/TCP                         5h58m   k8s-app=calico-typha
kube-system   service/kube-dns          ClusterIP   10.96.0.10      &lt;none&gt;        53/UDP,53/TCP                    6h11m   k8s-app=kube-dns

NAMESPACE     NAME                         DESIRED   CURRENT   READY   UP-TO-DATE   AVAILABLE   NODE SELECTOR                 AGE     CONTAINERS                IMAGES                                                 SELECTOR
kube-system   daemonset.apps/calico-node   1         1         1       1            1           beta.kubernetes.io/os=linux   5h58m   calico-node,install-cni   quay.io/calico/node:v3.3.2,quay.io/calico/cni:v3.3.2   k8s-app=calico-node
kube-system   daemonset.apps/kube-proxy    1         1         1       1            1           &lt;none&gt;                        6h11m   kube-proxy                k8s.gcr.io/kube-proxy:v1.13.1                          k8s-app=kube-proxy

NAMESPACE     NAME                                         READY   UP-TO-DATE   AVAILABLE   AGE     CONTAINERS        IMAGES                        SELECTOR
default       deployment.apps/articleservice-deployment    1/1     1            1           5h56m   articleservice    elps/articleservice:1.0.7     app=articleservice
default       deployment.apps/cartservice-deployment       1/1     1            1           5h56m   cartservice       elps/cartservice:1.0.7        app=cartservice
default       deployment.apps/catalogservice-deployment    1/1     1            1           5h56m   catalogservice    elps/catalogservice:1.0.7     app=catalogservice
default       deployment.apps/customerservice-deployment   1/1     1            1           5h56m   customerservice   elps/customerservice:1.0.7    app=customerservice
kube-system   deployment.apps/calico-typha                 0/0     0            0           5h58m   calico-typha      quay.io/calico/typha:v3.3.2   k8s-app=calico-typha
kube-system   deployment.apps/coredns                      2/2     2            2           6h11m   coredns           k8s.gcr.io/coredns:1.2.6      k8s-app=kube-dns

NAMESPACE     NAME                                                    DESIRED   CURRENT   READY   AGE     CONTAINERS        IMAGES                        SELECTOR
default       replicaset.apps/articleservice-deployment-6d48989664    1         1         1       5h56m   articleservice    elps/articleservice:1.0.7     app=articleservice,pod-template-hash=6d48989664
default       replicaset.apps/cartservice-deployment-6b844f45b8       1         1         1       5h56m   cartservice       elps/cartservice:1.0.7        app=cartservice,pod-template-hash=6b844f45b8
default       replicaset.apps/catalogservice-deployment-d4bd6984c     1         1         1       5h56m   catalogservice    elps/catalogservice:1.0.7     app=catalogservice,pod-template-hash=d4bd6984c
default       replicaset.apps/customerservice-deployment-7d6f77fdbb   1         1         1       5h56m   customerservice   elps/customerservice:1.0.7    app=customerservice,pod-template-hash=7d6f77fdbb
kube-system   replicaset.apps/calico-typha-5fc4874c76                 0         0         0       5h58m   calico-typha      quay.io/calico/typha:v3.3.2   k8s-app=calico-typha,pod-template-hash=5fc4874c76
kube-system   replicaset.apps/coredns-86c58d9df4                      2         2         2       6h10m   coredns           k8s.gcr.io/coredns:1.2.6      k8s-app=kube-dns,pod-template-hash=86c58d9df4
</code></pre>

<p><code>Ingress</code> is that you need. This is how it works:</p>

<pre><code>   internet
        |
   [ Ingress ]
   --|-----|--
   [ Services ]
</code></pre>

<p>Let's say you have any k8s Deployment with the label: <code>app: deployment-01</code> with <code>containerPort: 8888</code></p>

<p>So, you need to create:</p>

<ol>
<li>Service (say service-01)</li>
<li>Ingress (say ingress-01)</li>
</ol>

<p>If you want to reach service-01 by link <a href="http://myserver.com/service" rel="nofollow noreferrer">http://myserver.com/service</a> then your Service YAML should look like this:</p>

<pre><code>apiVersion: v1
kind: Service
metadata:
  name: service-01
spec:
  selector:
    app: deployment-01
  ports:
  - name: web
    protocol: TCP
    port: 8080
    targetPort: 8888
</code></pre>

<p>and Ingress:</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: ingress-01
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /
spec:
  rules:
  - host: myserver.com
    http:
      paths:
      - path: /service
        backend:
          serviceName: service-01
          servicePort: 8080
</code></pre>

<p>that's it!</p>

<blockquote>
  <p>Note: This assumes that you have already deployed the Ingress
  controller and it is working.</p>
</blockquote>
