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

Exposing Kubernetes services

When we run a pod using the kubectl run command, this pod is accessible only inside Kubernetes. In most of cases, we would want this pod to be accessible from the outside as well. This is where the kubectl expose command comes in handy. Let's create the httpd pod one more time and then expose it to the outside world:

$ kubectl run httpd --image=httpd$ kubectl get podsNAME READY STATUS RESTARTS AGEhttpd-66c6df655-8h5f4 1/1 Running 0 27m

Now let's use the kubectl expose command and expose the httpd web server to the outside of Kubernetes:

$ kubectl expose pod httpd-66c6df655-8h5f4 --port=80 --name=httpd-exposed --type=NodePort

While using the kubectl expose command, we specify several options:

  • port: Pod (Docker ...
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