<p>I have a minikube cluster with two pods (with ubuntu containers). What I need to do is route test traffic from one port to another through this minikube cluster. This traffic should be sent through these two pods like in the picture. I am a beginner in this Kubernetes stuff so I really don't know how to do this and which way to go... Please, help me or give me some hints.</p>
<p>I am working on ubuntu server ver. <strong>18.04.</strong></p>
<p><a href="https://i.stack.imgur.com/AwRfs.png" rel="nofollow noreferrer">enter image description here</a></p>

Skyeee
<p>I agree with an answer provided by @Harsh Manvar and I would also like to expand a little bit on this topic.</p>
<p>There already is an answer with a similar setup. I encourage you to check it out:</p>
<ul>
<li><em><a href="https://stackoverflow.com/questions/64350158/how-to-access-a-service-from-other-machine-in-lan/64422184#64422184">Stackoverflow.com: Questions: How to access a service from other machine in LAN</a></em></li>
</ul>
<p>There are different <a href="https://minikube.sigs.k8s.io/docs/drivers/" rel="nofollow noreferrer">drivers</a> that could be used to run your <code>minikube</code>. <strong>They will have differences when it comes to dealing with inbound traffic.</strong> I missed the part that was telling about the driver used in the setup (comment). If it's the <code>Docker</code> shown in the tags, you could follow below example.</p>
<hr />
<h1>Example</h1>
<p>Steps:</p>
<ul>
<li>Spawn <code>nginx-one</code> and <code>nginx-two</code> <code>Deployments</code> to imitate <code>Pods</code> from the image</li>
<li>Create a service that will be used to send traffic from <code>nginx-one</code> to <code>nginx-two</code></li>
<li>Create a service that will allow you to connect to <code>nginx-one</code> from LAN</li>
<li>Test the setup</li>
</ul>
<h3>Spawn <code>nginx-one</code> and <code>nginx-two</code> <code>Deployments</code> to imitate <code>Pods</code> from the image</h3>
<p>You can use following definitions to spawn two <code>Deployments</code> where each one will have a single <code>Pod</code>:</p>
<ul>
<li><code>nginx-one.yaml</code></li>
</ul>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-one
spec:
  selector:
    matchLabels:
      app: nginx-one
  replicas: 1
  template:
    metadata:
      labels:
        app: nginx-one
    spec:
      containers:
      - name: nginx
        image: nginx
        ports:
        - containerPort: 80
</code></pre>
<ul>
<li><code>nginx-two.yaml</code></li>
</ul>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-two
spec:
  selector:
    matchLabels:
      app: nginx-two
  replicas: 1
  template:
    metadata:
      labels:
        app: nginx-two
    spec:
      containers:
      - name: nginx
        image: nginx
        ports:
        - containerPort: 80
</code></pre>
<h3>Create a service that will be used to send traffic from <code>nginx-one</code> to <code>nginx-two</code></h3>
<p>You will need to use a <a href="https://kubernetes.io/docs/concepts/services-networking/service/" rel="nofollow noreferrer">Service</a> to send the traffic from <code>nginx-one</code> to <code>nginx-two</code>. Example of such <code>Service</code> could be following:</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: v1
kind: Service
metadata:
  name: nginx-two-service
spec:
  type: ClusterIP # could be changed to NodePort
  selector:
    app: nginx-two # IMPORTANT
  ports:
  - name: http
    protocol: TCP
    port: 80
    targetPort: 80
</code></pre>
<p>After applying this definition you will be able to send the traffic to <code>nginx-two</code> by using the service name (<code>nginx-two-service</code>)</p>
<blockquote>
<p>A side note!</p>
<p>You can use the IP of the <code>Pod</code> without the <code>Service</code> but this is not a recommended way.</p>
</blockquote>
<h3>Create a service that will allow you to connect to <code>nginx-one</code> from LAN</h3>
<p>Assuming that you want to expose your <code>minikube</code> instance to LAN with <code>Docker</code> driver you will need to create a service and expose it. Example of such setup could be the following:</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: v1
kind: Service
metadata:
  name: nginx-one-service
spec:
  type: ClusterIP # could be changed to NodePort
  selector:
    app: nginx-one # IMPORTANT
  ports:
  - name: http
    protocol: TCP
    port: 80
    targetPort: 80
</code></pre>
<p>You will also need to run:</p>
<ul>
<li><code>$ kubectl port-forward --address 0.0.0.0 service/nginx-one-service 8000:80</code></li>
</ul>
<p>Above command (ran on your <code>minikube</code> host!) will expose your <code>nginx-one-service</code> to be available on LAN. It will map port 8000 on the machine that ran this command to the port 80 of this service. You can check it by executing from another machine at LAN:</p>
<ul>
<li><code>curl IP_ADDRESS_OF_MINIKUBE_HOST:8000</code></li>
</ul>
<blockquote>
<p>A side note!</p>
<p>You will need root access to have your inbound traffic enter on ports lesser than 1024.</p>
</blockquote>
<h3>Test the setup</h3>
<p>You will need to check if there is a communication between the objects as shown in below &quot;connection diagram&quot;.</p>
<p><code>PC</code> -&gt; <code>nginx-one</code> -&gt; <code>nginx-two</code> -&gt; <code>example.com</code></p>
<p>The testing methodology could be following:</p>
<p><code>PC</code> -&gt; <code>nginx-one</code>:</p>
<ul>
<li>Run on a machine in your LAN:
<ul>
<li><code>curl MINIKUBE_IP_ADDRESS:8000</code></li>
</ul>
</li>
</ul>
<p><code>nginx-one</code> -&gt; <code>nginx-two</code>:</p>
<ul>
<li>Exec into your <code>nginx-one</code> <code>Pod</code> and run command:
<ul>
<li><code>$ kubectl exec -it NGINX_POD_ONE_NAME -- /bin/bash</code></li>
<li><code>$ curl nginx-two-service</code></li>
</ul>
</li>
</ul>
<p><code>nginx-two</code> -&gt; <code>example.com</code>:</p>
<ul>
<li>Exec into your <code>nginx-two</code> <code>Pod</code> and run command:
<ul>
<li><code>$ kubectl exec -it NGINX_POD_TWO_NAME -- /bin/bash</code></li>
<li><code>$ curl example.com</code></li>
</ul>
</li>
</ul>
<p>If you completed above steps you can swap <code>nginx</code> <code>Pods</code> for your own software.</p>
<hr />
<p>Additional notes and resources:</p>
<p>I encourage you to check <code>kubeadm</code> as it's the tool to create your own Kubernetes clusters:</p>
<ul>
<li><em><a href="https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/create-cluster-kubeadm/" rel="nofollow noreferrer">Kubernetes.io: Docs: Setup: Production environment: Tools: Kubeadm: Create cluster kubeadm</a></em></li>
</ul>
<p>As you said:</p>
<blockquote>
<p>I am a beginner in this Kubernetes stuff so I really don't know how to do this and which way to go... Please, help me or give me some hints.</p>
</blockquote>
<p>You could check following links for more resources:</p>
<ul>
<li><em><a href="https://kubernetes.io/" rel="nofollow noreferrer">Kubernetes.io</a></em></li>
<li><em><a href="https://kubernetes.io/docs/concepts/workloads/controllers/deployment/" rel="nofollow noreferrer">Kubernetes: Docs: Concepts: Workloads: Controllers: Deployment</a></em></li>
<li><em><a href="https://kubernetes.io/docs/concepts/services-networking/service/" rel="nofollow noreferrer">Kubernetes.io: Docs: Concepts: Services networking: Service</a></em></li>
</ul>
