<p>I have a pod with two containers. An application and a database. I have two replicas for the pod.</p>

<p>I want to expose the application port to be accessed outside the cluster and I do not want to expose the database port.</p>

<p>But I want to access the database port using DNS to balance the traffic.</p>

<p>I can create two services one as NodePort and expose the applicatin port and other service as ClusterIP to expose the database port.</p>

<p>I could also connect to localhost from the application server as the traffic has been balance before. And only expose the app server as nodeport.</p>

<p>The questions is: Could I expose the database port as cluster ip and the app port as nodeport with only one service?</p>

<p>Thank you.</p>

<p>The answer is: No, you can not. </p>

<p>But you should still know that a Kubernetes Service of type <code>NodePort</code> will also allocate a Cluster IP to which the port will route. So if your wanted to publish both ports, a single Service would be sufficient to reach them internally via the name and externally via node ports.</p>
