<p>In my openshift cluster, I noticed that all my pods have a port that's open without me specifying it.
Its the pott 443 which is apperantly used for the k8s api as mentiond in <a href="https://stackoverflow.com/questions/47523136/whats-the-purpose-of-the-default-kubernetes-service#:%7E:text=AFAIK%20the%20kubernetes%20service%20in,(%20Typically%20kubernetes%20API%20server).&amp;text=Please%20note%20that%20the%20kubernetes,the%20Endpoints%20IP%20of%20kubernetes.">this post</a>.</p>
<p>Even after reading, i still don't understand something.</p>
<p>I understand that the service exists and forwards to all pods.
But for the pods to receive and send requests using this service. The port must be open in the containers.
But somehow even without specifying a port on my pods container. That default 443 port is open.
Which allows me to do something like this:</p>
<ol>
<li>Create service with target port set to 443</li>
<li>Setup pod with no container port open.</li>
<li>Successfully use service to communicate with container.</li>
</ol>
<p>Is this safe?, What opens the container port without me specifying it?
Is there a way to prevent this from happening?</p>

<blockquote>
<p>I noticed that all my pods have a port that's open without me specifying it.</p>
</blockquote>
<p>Yes, the <code>contanerPort:</code> is just metadata, the container might listen to other ports as well.</p>
<blockquote>
<p>Is this safe?, What opens the container port without me specifying it? Is there a way to prevent this from happening?</p>
</blockquote>
<p>Yes, this is what <a href="https://kubernetes.io/docs/concepts/services-networking/network-policies/" rel="nofollow noreferrer">Kubernetes Network Policies</a> are for.</p>
