I'm deploying a web app using Google Kubernetes Engine and I want to make it accessible via a load balancer on an existing static IP address that I control as part of the same project in Google Cloud Platform, because the domain name I want to use already points to this IP.
The yaml file I used for the pod is:
apiVersion: v1
kind: Pod
metadata:
name: my-pod
labels:
app: my-app
spec:
containers:
- name: my-container
image: gcr.io/my-project/my-app:latest
I can set up a load balancer using:
apiVersion: v1
kind: Service
metadata:
name: my-load-balancer
spec:
ports:
- port: 80
targetPort: 80
selector:
app: my-app
type: LoadBalancer
This provides an external IP on which the app is accessible, but I can't find any way to configure it to use the IP I want. The services documentation mentions a spec.clusterIP setting, but this doesn't seem to relate to the external IP. Likewise, once the load balancer is set up, the service's status.loadBalancer.ingress.ip field is set to its external IP address, but this doesn't seem to be a configurable setting.
As an alternative, I tried manually creating a forwarding rule in the Google Compute Engine console to direct traffic from my static IP address to the target pool set up by Kubernetes, but when I try to connect the connection is refused.
Is there any way to do what I want - to expose a Kubernetes pod (or replication controller) on Google Kubernetes engine on a chosen static IP address?