<p>How can I expose service of type <code>NodePort</code> to internet <strong>without</strong> using type <code>LoadBalancer</code>? Every resource I have found was doing it by using load balancer. But I don't want load balancing its expensive and unnecessary for my use case because I am running one instance of <code>postgres</code> image which is mounting to persistent disk and I would like to be able to connect to my database from my PC using pgAdmin. If it is possible could you please provide bit more detailed answer as I am new to Kubernetes, GCE and networking.</p>

<p>Just for the record and bit more context I have deployment running 3 replicas of my API server to which I am connecting through load balancer with set loadBalancerIP and another deployment which is running one instance of postgres with NodePort service through which my API servers are communicating with my db. And my problem is that maintaining the db without public access is hard.</p>

<p>using <code>NodePort</code> as Service type works straight away e.g. like this:</p>

<pre><code>apiVersion: v1
kind: Service
metadata:
  name: nginx
spec:
  type: NodePort
  ports:
    - port: 80
      nodePort: 30080
      name: http
    - port: 443
      nodePort: 30443
      name: https
  selector:
    name: nginx
</code></pre>

<p>More details can be found in the <a href="https://kubernetes.io/docs/user-guide/services/#type-nodeport" rel="noreferrer">documentation</a>.
The drawback of using <code>NodePort</code> is that you've to take care of integrating with your providers firewall by yourself. A starting port for that can also be found in the <a href="https://kubernetes.io/docs/user-guide/services-firewalls/#google-compute-engine" rel="noreferrer">Configuring Your Cloud Provider's Firewalls</a> section of the official documentation.</p>

<p>For GCE opening up the above for publicly on all nodes could look like:</p>

<pre><code>gcloud compute firewall-rules create myservice --allow tcp:30080,tcp:30443
</code></pre>

<p>Once this is in place your services should be accessable through any of the public IPs of your nodes. You'll find them with:</p>

<pre><code>gcloud compute instances list
</code></pre>
