Exposing pod/service to VMs in another VPC

Cluster information:

Kubernetes version: v1.21.6-gke.1503
Cloud being used: gke

Hi, I have a private k8s cluster in GKE and would like to open few services to other VMs in another VPC. I tried the below, but that opens the service with a public IP. Instead I want to access the service by its internal/cluster IP and don’t want it to open on the public IP.

apiVersion: v1
kind: Service
metadata:
  name: sts-config-service
  namespace: sts
spec:
  type: LoadBalancer
  selector:
    app: sts-config
  ports:
  - protocol: TCP
    port: 9091
    targetPort: 9091
    nodePort: 30008

https://cloud.google.com/kubernetes-engine/docs/how-to/internal-load-balancing

https://cloud.google.com/kubernetes-engine/docs/how-to/internal-load-balance-ingress

1 Like