Skip to Content
Learn OpenShift
book

Learn OpenShift

by Denis Zuev, Artemii Kropachev, Aleksey Usov
July 2018
Intermediate to advanced
504 pages
11h 34m
English
Packt Publishing
Content preview from Learn OpenShift

Creating a service using oc expose

You can create a pod using oc expose in the following way:

$ oc get podNAME READY STATUS RESTARTS AGEhttpd 1/1 Running 0 13m$ oc expose pod httpd --name httpdservice "httpd" exposed$ oc get svcNAME CLUSTER-IP EXTERNAL-IP PORT(S) AGEhttpd 172.30.128.131 <none> 8080/TCP 3s

The preceding command creates a service by exposing the pod, using name=httpd as a selector. You may define a custom service name via the --name option.

The same httpd application will be available from the service IP address, which is 172.30.128.131 in our case, but your output from the previous command most likely will be different:

$ curl -s http://172.30.128.131:8080 | head -n4<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Operating OpenShift

Operating OpenShift

Rick Rackow, Manuel Dewald
OpenShift for Developers, 2nd Edition

OpenShift for Developers, 2nd Edition

Joshua Wood, Brian Tannous
Kubernetes: Up and Running, 2nd Edition

Kubernetes: Up and Running, 2nd Edition

Brendan Burns, Joe Beda, Kelsey Hightower

Publisher Resources

ISBN: 9781788992329Supplemental Content