<p>I'm deploying an IRC server where I need to expose port 6667 to external networks. The application pod itself works internally with port 6667.</p>
<p>I'm currently using <strong>minikube/kubectl</strong> in my host machine</p>
<p>This is my YAML configuration file</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: inspircd-x
spec:
  selector:
    matchLabels:
      app: inspircd
  replicas: 2
  template:
    metadata:
      labels:
        app: inspircd
    spec:
      containers:
      - name: inspircd-x
        image: inspircd/inspircd-docker
        ports:
        - containerPort: 6667
</code></pre>
<p>i'm creating a Service:</p>
<blockquote>
<p>kubectl expose deployment inspircd-x --type=LoadBalancer --name
inspircd-x</p>
</blockquote>
<p>and assigning an IP:</p>
<blockquote>
<p>minikube service inspircd-x</p>
</blockquote>
<p>I know that NodePort range is <strong>30000 - 32767</strong>, so (obviously) when i try to modify my service configuration it throws an error.</p>
<p>What i want to do is similar to this docker yaml:</p>
<pre><code>services:
  ircd-compose:
    image: inspircd/inspircd-docker
    ports:
      - 6667:6667
      - 7000:7000
</code></pre>
<p>I think there are concepts that I misunderstood when it comes to configuration so i got a couple of question:</p>
<ol>
<li><p>will the expose command and &quot;minikube service inspircd-x&quot; assign an external IP which can be accessed from outside? (I could do it with Docker, pointing my router to my host machine). Certainly, the ip that appears below is not within the IP range of my local network (192.168.0.x)</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>NAMESPACE</th>
<th>NAME</th>
<th>TARGET PORT</th>
<th>URL</th>
</tr>
</thead>
<tbody>
<tr>
<td>default</td>
<td>inspircd-x</td>
<td>6667</td>
<td><a href="http://192.168.64.2:30047" rel="nofollow noreferrer">http://192.168.64.2:30047</a></td>
</tr>
</tbody>
</table>
</div></li>
<li><p>is this the correct way to expose my pod externally?</p>
</li>
</ol>
<p>Thanks!</p>

emboole
<p>The equivalent of your docker-compose file would be using a host port on the node. As you are using minikube this is only a single node anyway.</p>
<pre><code>    spec:
      containers:
      - name: inspircd-x
        image: inspircd/inspircd-docker
        ports:
        - containerPort: 6667
          hostPort: 6667
</code></pre>
<p>A kubernetes service is for connectivity inside the cluster, it can be exposed externally using additional services, usually provided as part of the infrastructure, like a <code>LoadBalancer</code></p>
<p>Your next question, if that is the correct way to do it - it depends. Since the hostPort is only available to a single pod, you won't be able to do rolling deployments.</p>
