kubernetes tutorial | Kubernetes Volumes | Demo: create PV, PVC & Mount it a Pod using Local Storage

preview_player
Показать описание
*CERTIFIED KUBERNETES ADMINISTRATOR*
-------------------------------------------------------------------------

*Kubernetes Tutorial | DEMO Create PV PVC and Mount it in a Pod*
-----------------------------------------------------------------------------------------------------------

In this video, you are going to see a DEMO on how to create PV, PVC and mount the same into the Pod.

For suggestions/feedback/doubts contact

Happy Learning !!!

===========================================================================================
*USEFUL LINKS*
----------------------------

*Overview of Volumes*

*Persistent Volumes*

* Kubectl Command Reference*

==========================================================================================
#cka #kubernetes #k8s #container

*DEMO STEPS*
****************

*Step 1: Access & Inspect the Kubernetes Cluster*

$ kubectl cluster-info

$ kubectl get nodes

$ kubectl get pods -n kube-system


*Step 2: Create Persistent Volumes using Local Storage (Static Provisioning)*

*In Worker 1*

$ mkdir -p /pv/pv-1

*In Worker 2*

$ mkdir -p /pv/pv-2

*Create pv-1 & pv-2*

Sample PV manifest
===============================================
apiVersion: v1
kind: PersistentVolume
metadata:
name: pv-1
spec:
accessModes:
- ReadWriteMany
capacity:
storage: 1Gi
persistentVolumeReclaimPolicy: Retain
volumeMode: Filesystem
local:
path: /pv/pv-1
nodeAffinity:
required:
nodeSelectorTerms:
- matchExpressions:
operator: In
values:
================================================

*Step 3: Create Persistent Volumes Claims*

_Create pvc-1 & pvc-2_

Sample PVC Manifest
======================================

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: pvc-1
spec:
accessModes:
- ReadWriteMany
volumeMode: Filesystem
resources:
requests:
storage: 1Gi
=======================================

*Step 4: Create Pods and Mount the Persistent Volume Claims*

_Create Pod-1 and Pod-2 and mount the PVC's respectively_

Sample POD Manifest
===============================================
apiVersion: v1
kind: Pod
metadata:
labels:
app: apache
name: pod-1
spec:
volumes:
- name: myvolume-1
persistentVolumeClaim:
claimName: pvc-1
containers:
- image: httpd
name: apache
volumeMounts:
- name: myvolume-1
mountPath: /usr/local/apache2/htdocs/
==================================================

*Step 5: Create some data within the Pod and check the data persistence*

Create some data under the mountpath folder

$ kubectl exec -it pod-1 -- sh

*Step 6: Delete Pod-2 and Create Pod-3 with Pod 2’s PVC claim*

$ kubectl delete pod pod-2

Now create pod-3 with pod-2's pvc claim and validate the data in pod-3

_THE END_
Рекомендации по теме
Комментарии
Автор

Thank you for the detailed explanations

puru
Автор

Hi, for local storage we want use only rwo only know, but your used RWX, Multiple pod can use pv1 or pv2

balakrishnag
Автор

Hi..great tutorial... (1)U r using localpath right...(2)can we have single pv and multiple pvc...meaning multiple pods will using the same pv i.e., pv1=5G pvc1.1=1G pvc1.2=2G pvc1.3=2G (3)does it fit for pod replicas >1?

joeharyar