kubernetes expose nginx to static ip in gcp with ingress service configuration error

4/28/2018

I had a couple of questions regarding kubernetes ingress service [/controllers]

For example I have an nginx frontend image that I am trying to run with kubectl -

kubectl run <deployment> --image <repo> --port <internal-nginx-port>. 

Now I tried to expose this to the outer world with a service -

kubectl expose deployment <deployment> --target-port <port>. 

Then tried to create an ingress service with the following nignx-ing.yaml -

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: urtutorsv2ingress
  annotations:
    kubernetes.io/ingress.global-static-ip-name: "coreos"
spec:
  backend:
    serviceName: <service>
    servicePort: <port>

Where my ingress.global-static-ip-name is correctly created & available in Google cloud console. [I am assuming the service port here is the port I want on my "coreos" IP , so I set it to 80 initially which didn't work so I tried setting it same as the specified in the first step but it still didn't work.]

So, the issue is I am not able to access the frontend at both the urls http://COREOS_IP, http://COREOS_IPIP:

Which is why I tried to use -

kubectl expose deployment <deployment> --target-port <port>.  --type NodePort 

to see if it worked with a NodePort & I was able to access the frontend.

So, I am thinking there might be a configuration mistake here because of which I am not getting results with the ingress.

Can anyone here help debug / fix the issue ?

-- Harshit Laddha
google-cloud-platform
kubectl
kubernetes
kubernetes-ingress
nginx

1 Answer

5/7/2018

Yeah, the service is there. I tried to check the status with - kubectl get services, kubectl describe service k8urtutorsv2. It showed the service. I tried editing it & saved the nodeport value. the thing is it works with nodeport but not 80 or 443.

You cannot directly expose service on the port 80 or 443.

The available range of exposed services is predefined in the kube-api configuration by the service-node-port-range option with the default value 30000-32767.

-- Anton Kostenko
Source: StackOverflow