There are several ways you can expose your service after you deploy it on OpenShift. The following sections describes the various methods and when to use them.


If you are deploying a Web application, the most common way to expose it is by a route. A route exposes the service as a host name. You can create a route using the Web console or the CLI:

oc expose svc/frontend --hostname=www.example.com

To see a full example of creating an application and exposing it with a route, see the Minishift Quickstart section.

NodePort Services

In case the service you want to expose is not HTTP based, you can create a NodePort service. In this case, each OpenShift node will proxy that port into your service. To access this port on your Minishift VM, you need to configure an Ingress IP Self-Service using oc expose with the parameter type=LoadBalancer.

A common use-case for Ingress IP Self-Service is the ability to expose a database service. The following example shows the complete workflow to create and expose a MariaDB instance using Minishift:

$ minishift start
$ eval $(minishift oc-env)
$ oc new-app -e MYSQL_ROOT_PASSWORD=admin https://raw.githubusercontent.com/openshift/origin/master/examples/db-templates/mariadb-persistent-template.json
$ oc rollout status -w dc/mariadb
$ oc expose dc mariadb --type=LoadBalancer --name=mariadb-ingress
$ oc export svc mariadb-ingress
    - nodePort: 30907

After the service is exposed, you can access MariaDB with the mysql CLI using the Minishift VM IP and the exposed NodePort service.

$ mysql --user=root --password=foo --host=$(minishift ip) --port=30907

Port Forwarding

If you want to quickly access a port of a specific pod of your cluster, you can also use the oc port-forward command of the OpenShift CLI.

$ oc port-forward POD [LOCAL_PORT:]REMOTE_PORT