<p>Can I create two pods where containers are running on same ports in one kubernetes cluster? considering that will create a separate service for both.</p>

<p>Something like this : </p>

<p>-- Deployment 1</p>

<pre><code>kind: Deployment
spec:
  containers:
  - name: &lt;name&gt;
    image: &lt;image&gt;
    imagePullPolicy: Always
    ports:
    - containerPort: 8080
</code></pre>

<p>-- Service 1</p>

<pre><code>kind: Service
spec:
    type: LoadBalancer
ports:
  - port: 8081
    targetPort: 8080
</code></pre>

<p>-- Deployment 2</p>

<pre><code>kind: Deployment
spec:
  containers:
  - name: &lt;name&gt;
    image: &lt;image&gt;
    imagePullPolicy: Always
    ports:
    - containerPort: 8080
</code></pre>

<p>-- Service 2</p>

<pre><code>kind: Service
spec:
    type: LoadBalancer
ports:
  - port: 8082
    targetPort: 8080
</code></pre>

<p>but this approach is not working.</p>

<p>Sure you can. Every <code>POD</code> (which is the basic workload unit in k8s) is isolated from the others in terms of networking (as long as you don't mess with advanced networking options) so you can have as many pods as you want that bind the same port. You can't have two <code>containers</code> inside the same <code>POD</code> that bind the same port, though.</p>
