Facing issue on exposing service in openshift

12/23/2021

I am using openshift and I am unable to access service from outside. I have 2 yaml files service, and deployment. I am pulling nginx image. image is pulled successfully and service is created but i am unable to access nginx page from browser nor curl is working from cli.

below is the output of oc get all command

NAME                TYPE       CLUSTER-IP       EXTERNAL-IP   PORT(S)        AGE
service/nginx-svc   NodePort   17x.x.x.x  <none>        80:3000x/TCP   15h

deployment and everything is running.

-- majid asad
kubernetes
kubernetes-ingress
nginx-ingress
openshift

1 Answer

12/23/2021

A Service is only accessible within the cluster. To access your Service from outside the cluster, you'll need to add a Route / Ingress object.

You can also check my answer on the following question to understand the difference between Routes and Services: https://stackoverflow.com/questions/62354040/kubernetes-vs-openshift-routes-and-services/62361379#62361379

So the easiest way to create such a Route would be to use the oc expose command like so:

oc expose svc nginx-svc

Then you can use oc get routes to see the URL for that Route.

-- Simon
Source: StackOverflow