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

Table 7-1. Types of Services

ServiceType External IP Description

ClusterIP No The default; exposes a service from within a cluster only.

NodePort Yes In addition to exposing the service within a cluster, exposes

the service at each node in the cluster at a specific port at URL

<NodeIP>:NodePort.

LoadBalancer Yes In addition to exposing a service within the cluster and at each node

in the cluster exposes the service at an external LoadBalancer IP.

In this chapter we shall discuss each of the ServiceTypes with an example. This chapter has the

following sections:

Setting the Environment

Creating a ClusterIP Service

Creating a NodePort Service

Creating a LoadBalancer Service

Setting the Environment

Create an AWS EC2 instance from Amazon Linux AMI. SSH log in to the EC2 instance using the public IP

address:

ssh -i "docker.pem" ec2-user@107.23.131.161

Create a CoreOS AWS CloudFormation for a Kubernetes cluster. Add an A record for the cluster

controller instance to the public DNS name for the CloudFormation and SSH log in to the controller

instance:

ssh -i "kubernetes-coreos.pem" core@52.203.239.87

Install kubectl binaries and list the nodes:

./kubectl get nodes

The nodes in the cluster should be listed, as shown in Figure 7-3.

Figure 7-3. Listing nodes in a Kubernetes cluster

155

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

Saved successfully!

Ooh no, something went wrong!