Chapter 3. Advanced Concepts

This chapter addresses how to run stateful containers using persistent volumes and stateful set. It covers different aspects of pods, including automatic scaling of pods using horizontal pod autoscaling, configuring a singleton instance of a pod using daemon sets, and performing health checks of a pod using probes. Using namespaces to share resources in a Kubernetes cluster across different groups is also explained. In addition, the chapter describes how to perform a rolling update of an application using replication controllers and deployments. And finally, it covers exposing a service outside the cluster.

All resource files in this chapter are available at this book’s GitHub repo.

Persistent Volume

Stateful containers, such as Couchbase, need to store data outside the container. This allows the data to be preserved independent of container and pod restarts. To accomplish this, Kubernetes provides volumes, which are essentially directories accessible to the pod. The lifecycle of a volume is tied to the pod that created it. Pods can store data on this volume and preserve data across container restarts. But the volume ceases to exist along with the pod. Moreover, pods are ephemeral and so may be rescheduled on a different host. This means the data cannot be stored on a host as well.

Kubernetes persistent volumes solve this problem by providing persistent, cluster-scoped storage for applications that require long-lived data.

Creating and using a persistent ...

Get Kubernetes for Java Developers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.