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

marco.cirilli
from marco.cirilli More from this publisher
19.06.2021 Views

Chapter 3 ■ Kubernetes on Google Cloud PlatformThe VM Instances also lists the controller and minion instances started for the Kubernetes cluster, asshown in Figure 3-41.Figure 3-41. Listing the Kubernetes controller and minion instancesSelect the External IP Addresses tab to list all the external IP addresses, including those for thecontroller and minion instances, as shown in Figure 3-42.Figure 3-42. Listing the external IP addressesCreating a Kubernetes Application and ServiceIn this section we’ll create a sample Kubernetes application using the Docker image nginx. The followingcommand creates a deployment for the nginx Docker image.kubectl.sh --namespace=default run nginx --image=nginx –replicas=3 –port=80Deployment "nginx" is created as shown in Figure 3-43.Figure 3-43. Creating a deployment nginx71

Chapter 3 ■ Kubernetes on Google Cloud PlatformList the pods, including the nodes the pods run on:kubectl.sh get pods -o wideThe three pod replicas including the node are listed as shown in Figure 3-44.Figure 3-44. Listing the node replicasList the deployments:kubectl.sh get deploymentsCreate a service for type LoadBalancer:kubectl.sh expose deployment nginx --port=80 --type=LoadBalancerList the services:kubectl.sh get servicesThe output from the preceding commands is shown in Figure 3-45.Figure 3-45. Listing the deployments and servicesDescribe the nginx service:kubectl.sh describe svc nginxThe service description, including the service endpoints and any error messages, is listed as shown inFigure 3-46.72

Chapter 3 ■ Kubernetes on Google Cloud Platform

List the pods, including the nodes the pods run on:

kubectl.sh get pods -o wide

The three pod replicas including the node are listed as shown in Figure 3-44.

Figure 3-44. Listing the node replicas

List the deployments:

kubectl.sh get deployments

Create a service for type LoadBalancer:

kubectl.sh expose deployment nginx --port=80 --type=LoadBalancer

List the services:

kubectl.sh get services

The output from the preceding commands is shown in Figure 3-45.

Figure 3-45. Listing the deployments and services

Describe the nginx service:

kubectl.sh describe svc nginx

The service description, including the service endpoints and any error messages, is listed as shown in

Figure 3-46.

72

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

Saved successfully!

Ooh no, something went wrong!