19.06.2021 Views

148422597X Kubernetes Management Design Patterns [Vohra 2017-01-29] {E559F6BB}

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 7 ■ Using Services

Creating a ClusterIP Service

In this section we shall create a service of type ClusterIP, which is the default service type. First, create a

deployment using the Docker image tutum/hello-world with three replicas:

./kubectl run hello-world --image=tutum/hello-world --replicas=3 --port=80

Next, list the deployments:

./kubectl get deployments

A hello-world deployment is created and listed as shown in Figure 7-4.

Figure 7-4. Creating and listing the deployments

List the pods:

./kubectl get pods

The three pod replicas are listed. Expose the deployment as a service of type ClusterIP, which is the

default, but may also be specified explicitly.

./kubectl expose deployment hello-world --port=80 --type=ClusterIP

List the services:

./kubectl get services

The hello-world service should be listed in addition to the kubernetes service and any other services,

as shown in Figure 7-5.

Figure 7-5. Creating and listing a service

156

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!