Getting ready

What are Daemon-like Pod and Stateful Pod? The regular Pods in Kubernetes will determine and dispatch to particular Kubernetes nodes based on current node resource usage and your configuration.

However, a Daemon-like Pod will be created in each node. For example, if you have three nodes, three daemon-like Pods will be created and deployed to each node. Whenever a new node is added, DaemonSets Pod will be deployed to the new node automatically. Therefore, it will be useful to use node level monitoring or log correction.

On the other hand, a Stateful Pod will stick to some resources such as network identifier (Pod name and DNS) and persistent volume (PV). This also guarantees an order during deployment of multiple Pods and during rolling update. For example, if you deploy a Pod named my-pod, and set the scale to 4, then Pod name will be assigned as my-pod-0, my-pod-1, my-pod-2, and my-pod-3. Not only Pod name but also DNS and persistent volume are preserved. For example, when my-pod-2 is recreated due to resource shortages or application crash, those names and volumes are taken over by a new Pod which is also named my-pod-2. It is useful for some cluster based applications such as HDFS and ElasticSearch.

In this recipe, we will demonstrate how to use DaemonSets and StatefulSet; however, to have a better understanding, it should use multiple Kubernetes Nodes environment. To do this, minikube is not ideal, so instead, use either kubeadm/kubespray to create a multiple Node environment.

Using kubeadm or kubespray to set up Kubernetes cluster was described in Chapter 1, Build Your Own Kubernetes Cluster.

To confirm whether that has 2 or more nodes, type kubectl get nodes as follows to check how many nodes you have:

//this result indicates you have 2 nodes
$ kubectl get nodes
NAME STATUS ROLES AGE VERSION
node1 Ready master,node 6h v1.10.2
node2 Ready node 6h v1.10.2

In addition, if you want to execute the StatefulSet recipe later in this chapter, you need a StorageClass to set up a dynamic provisioning environment. It was described in Working with volumes section in Chapter 2Walking through Kubernetes Concepts. It is recommended to use public cloud such as AWS and GCP with a CloudProvider; this will be described in Chapter 6, Building Kubernetes on AWS and Chapter 7, Building Kubernetes on GCP, as well.

To check whether StorageClass is configured or not, use kubectl get sc:

//in Google Kubernetes Engine Environment
$ kubectl get sc
NAME PROVISIONER
standard (default) kubernetes.io/gce-pd
..................Content has been hidden....................

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