Storage
- K8s supports many types of Volumes
- Ephemeral Volumes:
- These volume exist as long as Pod Exists, But once Pod is destroyed this volume is also destroyed
- Persistent Volumes (Storage Classes & Persisten Volume Claims):
- This Volume exists beyond the lifetime of a Pod. K8s doesnot destroy persistent volumes
- Ephemeral Volumes:
- In both the volumes k8s supports different volumes
- azureDisk
- azureFile
- emptyDir
- gcePersistentDisk
- aws ebs
- hostPath
- local
- nfs
- To understand Persistent Volumes Better, we need to understand
- StorageClasses
- Persistent Volume Claims
- A persistent Volume (PV) is a piece of storage in the cluster that has been provisioned by an adminstrator or it can be dynamically provisioned with StorageClasses.
- A PersistentVolumeClaim (PVC) is a request for storage by a user. Claims can request specific size and access modes
-
Provisioning Storage
- Static
- Dynamic
- Lets Create a K8s Cluster in Azure: Refer Here
-
Lets Create a K8s Cluster in AWS (Elastic Kubernetes Service):
- Refer Here
- To connect to AWS we need to create an IAM user Refer Here
- Install aws cli Refer Here
bash
sudo apt update
sudo apt install unzip -y
unzip awscliv2.zip
sudo ./aws/install

- Install kubectl Refer Here
curl -o kubectl https://amazon-eks.s3.us-west-2.amazonaws.com/1.21.2/2021-07-05/bin/linux/amd64/kubectl
sudo cp kubectl /usr/bin
sudo chmod 755 /usr/bin/kubectl
kubectl version - Installing eksctl Refer Here
curl --silent --location "https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_$(uname -s)_amd64.tar.gz" | tar xz -C /tmp
sudo mv /tmp/eksctl /usr/local/bin
eksctl version - Refer Here for eksctl documentation
- Now lets create cluster using eksctl
eksctl create cluster \
--name my-cluster \
--version 1.21 \
--without-nodegroup


-
Note:
- All the images from gitbash will be eks and from powershell will be aks
-
Persistent Volumes
- Official Docs: Refer Here
- Types supported Refer Here
- Creating a Pod/Replication Controller/Deployment with PV, PVC and SC in Azure
- Azure gives the default storage classes

- Created a pvc

- using the pvc claim in rs

- Lets create a load balancer for testing purposes to connect to databse from location

- Insert some data into database

- Now delete replicaset

- Now recreate the replicaset and view the data in the database

- Refer Here for the manifests created for Azure

- Azure gives the default storage classes
- Creating PVC on AWS EKS
- Refer Here for the changes
- Note: Will create a document with resolution on storage
StatefulSet
- Stateful set manages Pods that are based on identical container spec.
- Stateful set maintains stick identity of their pods.
- These pods are created from same spec, but are not interchangable: each has a persistent identifier that it maintains across rescheduling
