19.06.2021 Views

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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 16 ■ Developing a Highly Available Website

Creating a Kubernetes Service

In this section we shall create a hello-world application and expose the application as a service of type

LoadBalancer on each of the three Kubernetes clusters. As a result, three elastic load balancers each

exposing the hello-world service should be available.

SSH log in to each of the controller instances and after verifying that the cluster nodes are being listed

create an application with the tutum/hello-world Docker image.

kubectl -s http://localhost:8080 run hello-world --image=tutum/hello-world --replicas=2

--port=8

List the cluster-wide pods:

kubectl get pods –o wide

List the deployments:

kubectl get deployments

Subsequently, expose the deployment as a service of type LoadBalancer:

kubectl expose deployment hello-world--port=80 --type=LoadBalancer

List the services:

kubectl get services

The output from the preceding commands is shown in Figure 16-10.

Figure 16-10. Creating a hello-world deployment and service

362

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

Saved successfully!

Ooh no, something went wrong!