Exposing Services

Exposing services in MicroShift.

Services deployed in MicroShift can be exposed in multiple ways.

Routes and Ingresses

By default an OpenShift router is created and exposed on host network ports 80/443. Routesor Ingresses can be used to expose HTTP or HTTPS services through the router.

Example

oc create deployment nginx --image=nginxinc/nginx-unprivileged:stable-alpine
oc expose deployment nginx --port=8080
oc expose service/nginx --hostname=my-hostname.com

# assuming my-hostname.com being mapped to the MicroShift node IP
curl http://my-hostname.com

Route with mDNS host example

The hostname of a route can be a mDNS (.local) hostname, which would be then announced via mDNS, see the mDNS section for more details.

oc expose service/nginx --hostname=my-hostname.local
curl http://my-hostname.local

Service of type NodePort

NodePort type of services expose services over a dedicated port on all the cluster nodes, such port is routed internally to the active pods backing the service.

Example

oc create deployment nginx --image=nginxinc/nginx-unprivileged:stable-alpine
oc expose deployment nginx --type=NodePort --name=nodeport-nginx --port 8080
NODEPORT=$(oc get service nodeport-nginx -o jsonpath='{.spec.ports[0].nodePort}')
IP=$(oc get node -A -o jsonpath='{.items[0].status.addresses[0].address}')
curl http://$IP:$NODEPORT/

For using NodePort services open the 30000-32767 port range , see the firewall section.

Service of type LoadBalancer

Services of type LoadBalancer are not supported yet, this kind of service is normally backed by a load balancer in the underlying cloud.

Multiple alternatives are being explored to provide LoadBalancer VIPs on the LAN.

Last modified October 24, 2023 at 8:51 AM PST : build(deps): bump actions/setup-node from 3 to 4 (#212) (333d7a1)
Last modified October 24, 2023 at 8:51 AM PST : build(deps): bump actions/setup-node from 3 to 4 (#212) (333d7a1)