Getting ready

For a later demonstration, we are going to update nginx Pods . Please make sure all Kubernetes nodes and components are working healthily:

// check components
$ kubectl get cs
// check nodes
$ kubectl get node

Furthermore, to well understand the relationship between ReplicaSet and Deployment, please check Deployment API section in Chapter 2, Walking through Kubernetes Concepts.

To illustrate the updating of the containers in Kubernetes system, we will create a Deployment, change its configurations of application, and then check how the updating mechanism handles it. Let's get all our resources ready:

// create a simple nginx Deployment with specified labels
$ kubectl run simple-nginx --image=nginx --port=80 --replicas=5 --labels="project=My-Happy-Web,role=frontend,env=test"
deployment.apps "simple-nginx" created

This Deployment is created with 5 replicas. It is good for us to discover the updating procedure with multiple numbers of Pods:

// expose the Deployment, and named the service "nginx-service"
$ kubectl expose deployment simple-nginx --port=8080 --target-port=80 --name="nginx-service"
service "nginx-service" exposed
// For minikube environment only, since Kubernetes is installed in a VM, add Service type as NodePort for accessing outside the VM.
$ kubectl expose deployment simple-nginx --port=8080 --target-port=80 --name="nginx-service" --type=NodePort
service "nginx-service" exposed

Attaching a Service on the Deployment will help to simulate the real experience of clients.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.220.237.24