<p>I run a tiny (read: single-node) Docker Swarm cluster that I want to migrate to Kubernetes, and I can't figure out how to expose a Service on a specific port so that I can access it from the outside world.</p>

<p>In Docker Swarm, I could expose e.g. a MySQL server by specifying</p>

<pre><code>ports:
  - '3306:3306'
</code></pre>

<p>as part of the service block in my stack configuration file, which would let me access it on <code>127.0.0.1:3306</code>.</p>

<p>To replicate this in Kubernetes, my first instinct was to use the <code>NodePort</code> service type and specifying</p>

<pre><code>ports:
  - port: 3306
    targetPort: 3306
    nodePort: 3306
</code></pre>

<p>in the service spec. But this is not allowed: Kubernetes tells me <code>provided port is not in the valid range. The range of valid ports is 30000-32767</code>.</p>

<p>Then there is <code>Ingress</code>, which seems closely aligned with what I want to do, but <a href="https://kubernetes.io/docs/concepts/services-networking/ingress/#prerequisites" rel="nofollow noreferrer">it's in beta</a> and is apparently geared towards HTTP services (which does not cover all my use cases). There is also the <code>LoadBalancer</code> type, but I'm not using a cloud provider with support for it and so that isn't an option for me.</p>

<p>This has left me a bit confused. If I want to expose a service in my Kubernetes cluster so that I can access it from the outside (e.g. from the internet at large on <code>some-public-ip:3306</code>), what is a recommended (or alternatively, beginner-friendly) way to set it up? What am I missing?</p>

James
<p><code>NodePort</code> is probably the simplest approach, but you will need to pick a port in the range 30000 - 32767. That way you'd access say <code>some-public-ip:30306</code> which would map to your service's port 3306 internally.</p>
