Menu
Coddy logo textTech

Exposing A Deployment

Part of the Introduction to Kubernetes section of Coddy's Terminal journey. Lesson 17 of 45.

Every Pod gets its own IP address, but Pods come and go: scale, update or roll back and the addresses change. A Service gives a group of Pods one stable name and IP address, and spreads traffic across them.

The quickest way to create one is to expose a Deployment:

kubectl expose deployment web --port=80

Kubernetes answers service/web exposed. The Service is named after the Deployment and sends traffic on port 80 to its Pods.

List Services with kubectl get services (short form svc). Each has a TYPE, a CLUSTER-IP that never changes, and its PORT(S). Inside the cluster, other Pods reach it simply as http://web: the name is resolved by the cluster's DNS.

challenge icon

Challenge

Beginner

Create a Deployment named web from the nginx image, expose it on port 80, then list the Services.

Try it yourself

Terminal
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Introduction to Kubernetes

Practice on your own: Terminal playground