From the course: Certified Kubernetes Application Developer (CKAD) Cert Prep

Unlock this course with a free trial

Join today to access over 24,700 courses taught by industry experts.

Creating services

Creating services

- So let's talk about the way to create Services. The most important command is kubectl expose. It's a convenient command that you can use to create Services that provide access to either Deployments, ReplicaSets, Pods, or even other Services. In most cases, you will be exposing Deployments, but it's good to know that you can also expose Pods directly, for instance, and that's something that we will be doing in this course. There's also the kubectl create service command, and you can use it as an alternative solution to create Services. Personally, I think kubectl expose is a bit easier to use. Now when you create a Service, the --port argument must be specified to indicate the port on which the Service will be listening for incoming traffic. That port is normally equivalent to the application port in which your application itself is listening. So if you create a Service that accesses an nginx web server, you would use --port=80, typically. Let's talk about ports because when you work…

Contents