Kubernetes' persistent volume and dynamic provisioning

Kubernetes supports a variety of persistent volumes, for example, public cloud storage such as AWS EBS and Google persistent disks. It also supports network (distributed) filesystems such as NFS, GlusterFS, and Ceph. In addition, it can also support a block device such as iSCSI and Fibre Channel. Based on the environment and infrastructure, a Kubernetes administrator can choose the best matching types of persistent volume.

The following example is using a GCP persistent disk as a persistent volume. The first step is to create a GCP persistent disk and name it gce-pd-1.

If you use AWS EBS, Google persistent disk, or Azure disk storage, the Kubernetes node must be in the same cloud platform. In addition, Kubernetes has a limit on maximum volumes per node. Please look at the Kubernetes documentation at https://kubernetes.io/docs/concepts/storage/storage-limits/

Then, specify the name gce-pd-1 in the Deployment definition:

$ cat tomcat-pv.yml 
apiVersion: apps/v1
kind: Deployment
metadata:
name: tomcat
spec:
replicas: 1
selector:
matchLabels:
run: tomcat
template:
metadata:
labels:
run: tomcat
spec:
containers:
- image: tomcat
name: tomcat
ports:
- containerPort: 8080
volumeMounts:
- mountPath: /usr/local/tomcat/logs
name: tomcat-log
volumes:
- name: tomcat-log
gcePersistentDisk:
pdName: gce-pd-1
fsType: ext4

This will mount the persistent disk from the GCE persistent disk to /usr/local/tomcat/logs, which can persist Tomcat application logs.

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

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