<p>I created <code>nodeport</code> service for httpd pods and <code>cluster IP</code> service for tomcat pods and they're in same namespace behind nginx LB. There is a weird issue with the app when http and tomcat services are not the same type. When I change both to be <code>cluster IP</code> or both to be <code>NodePort</code> then everything works fine...</p>
<p>Traffic flow is like this:</p>
<p><code>HTTP and HTTPS traffic -&gt; LB -&gt; Ingress -&gt; Httpd -&gt; Tomcat</code></p>
<p><code>HTTPS virtual host custom port traffic -&gt; LB -&gt; Tomcat</code></p>
<p><code>TCP traffic -&gt; LB -&gt; Tomcat</code></p>
<p>Is there anything that can cause issues between HTTPD and Tomcat? Even though I can telnet to httpd and tomcat pods from outside but for some reason the app functionality breaks (some static and jsp pages gets processed though).</p>
<p>httpd-service:</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: httpd
  labels:
    app: httpd-service
  namespace: test-web-dev
spec:
type: NodePort
  selector:
    app: httpd
  ports:
    - name: port-80
      port: 80
      protocol: TCP
      targetPort: 80
    - name: port-443
      port: 443
      protocol: TCP
      targetPort: 443
  sessionAffinity: &quot;ClientIP&quot;
  sessionAffinityConfig:
    clientIP:
      timeoutSeconds: 10800
  externalTrafficPolicy: Local
</code></pre>
<p>tocmat-service:</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: tomcat7
  namespace: test-web-dev
  annotations:
spec:
  selector:
    app: tomcat7 # Metadata label of the deployemnt pod template or pod metadata label
  ports:
    - name: port-8080 # Optional when its just only one port
      protocol: TCP
      port: 8080
      targetPort: 8080
    - name: port-8262
      protocol: TCP
      port: 8262
      targetPort: 8262
  sessionAffinity: &quot;ClientIP&quot;
  sessionAffinityConfig:
    clientIP:
      timeoutSeconds: 10800
</code></pre>
<p>ingress lb:</p>
<pre><code>apiVersion: v1
kind: ConfigMap
metadata:
  name: tcp-services
  namespace: ingress-nginx
data:
  1234: &quot;test-web-dev/httpd:1234&quot;
  8262: &quot;test-web-dev/tomcat7:8262&quot;
---
apiVersion: v1
kind: Service
metadata:
  name: ingress-nginx
  namespace: ingress-nginx
  labels:
    app.kubernetes.io/name: ingress-nginx
    app.kubernetes.io/part-of: ingress-nginx
spec:
  externalTrafficPolicy: Local
  type: LoadBalancer
  selector:
    app.kubernetes.io/name: ingress-nginx
    app.kubernetes.io/part-of: ingress-nginx
  ports:
    - name: http
      port: 80
      protocol: TCP
      targetPort: http
    - name: https
      port: 443
      protocol: TCP
      targetPort: https
    - name: port-1234
      port: 1234
      protocol: TCP
      targetPort: 1234
    - name: port-8262
      port: 8262
      protocol: TCP
      targetPort: 8262
</code></pre>

user630702
<p>Answering my own question.</p>
<p>NodePort services are required when the service needs be exposed outside of the cluster like internet.</p>
<p>ClusterIP services are used when services needs to communicate internally like frontend to backend.</p>
<p>In my case, user needs to connect to both httpd and tomcat (specific app port) from outside as a result both tomcat and httpd has to be nodeport type service. Configuring tomcat has cluster IP will break the app since tomcat app port isn't reachable from internet.</p>
