Is there a way to apply IP masquerade only for a stateful set on GKE

I only want a stateful set pods to NAT , Is there a way to apply IP masquerade only for a stateful set and how to do it?

Hi @ishanC ,

Your best option here is to configure an Internal TCP/UDP load balancer. You can follow the Kubernetes Service annotation as described here on this documentation.

apiVersion: v1
kind: Service
metadata:
  name: ilb-svc
  annotations:
    networking.gke.io/load-balancer-type: "Internal"
spec:
  type: LoadBalancer
  externalTrafficPolicy: Cluster
  selector:
    app: ilb-deployment
  ports:
  - name: tcp-port
    protocol: TCP
    port: 8080
    targetPort: 8080

This is the exact excerpt from the documentation. You can rely on the Kubernetes config to get the Internal Load balancer up.

1 Like