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

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

Chapter 1 ■ Kubernetes on AWSSimilarly, for each of the kubernetes-minion nodes, add the default security group and click AssignSecurity Groups as shown in Figure 1-23.Figure 1-23. Assigning security groups for kubernetes-minionAlternatively, if the default security group was modified not to allow all traffic, the security groupassigned to the kubernetes-master and each of the kubernetes-minion security groups should include aninbound rule to all traffic, as shown in Figure 1-24.Figure 1-24. The security group with inbound rules to allow all traffic16

Testing the ClusterChapter 1 ■ Kubernetes on AWSNext, we will test the Kubernetes cluster. First, we need to add the directory path in which the Kubernetesbinaries are installed to the environment variable PATH.export PATH=/home/ec2-user/kubernetes/platforms/linux/amd64:$PATHSubsequently echo the PATH environment variable as shown in Figure 1-25.Figure 1-25. Setting the PATH environment variableTo test the cluster, run a Docker image such as the nginx image to create three pod replicas:kubectl run nginx --image=nginx --replicas=3 --port=80List the pods:kubectl get podsList the deployments:kubectl get deploymentsCreate a service of type LoadBalancer for the deployment:kubectl expose deployment nginx --port=80 --type=LoadBalancerList the services:kubectl get servicesList the pods across the clusterkubectl get pods –o wideIf Kubernetes has installed correctly, all the previous commands should run correctly and generate theoutput to indicate that a pod cluster has been created, as shown in Figure 1-26.17

Testing the Cluster

Chapter 1 ■ Kubernetes on AWS

Next, we will test the Kubernetes cluster. First, we need to add the directory path in which the Kubernetes

binaries are installed to the environment variable PATH.

export PATH=/home/ec2-user/kubernetes/platforms/linux/amd64:$PATH

Subsequently echo the PATH environment variable as shown in Figure 1-25.

Figure 1-25. Setting the PATH environment variable

To test the cluster, run a Docker image such as the nginx image to create three pod replicas:

kubectl run nginx --image=nginx --replicas=3 --port=80

List the pods:

kubectl get pods

List the deployments:

kubectl get deployments

Create a service of type LoadBalancer for the deployment:

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

List the services:

kubectl get services

List the pods across the cluster

kubectl get pods –o wide

If Kubernetes has installed correctly, all the previous commands should run correctly and generate the

output to indicate that a pod cluster has been created, as shown in Figure 1-26.

17

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

Saved successfully!

Ooh no, something went wrong!