
Stateless vs Stateful ?
Most of applications deployed on Kubernetes engine are stateless , stateless application has no persistent storage or volume associated with it. From an operations perspective, this is great news. Different pods all across the cluster can work independently with multiple requests coming to them simultaneously. Stateless application are easier to scale horizontally ,but now Kubernetes also supports stateful applications , Example of stateful application are data driven application such as MYSQL DB, Content management applications etc , state of such applications are preserved on persistence volumes (PV and PVC).
In this blog will dig deep into creating persistence volume PV and PVC in OKE for stateful application containers.
A persistent volume offers persistent storage that enables your data to remain intact, regardless of whether the containers to which the storage is connected are terminated.
With OCI we can provision persistence volume claims for :
- By attaching volumes from OCI block volume service , volumes are connected to cluster via Flexvolume and CSI (container storage interface) .
- By Mounting file systems in OCI File storage service .
Block volume service is used as PV for applications like MYSQL DB where data writes needs to be faster.
PVCs on the Block Volume Service
The Oracle Cloud Infrastructure Block Volume service provides persistent, durable, and high-performance block storage for your data. You can use the CSI volume plugin to connect clusters to volumes from the Block Volume service.
To enable the worker nodes to access Block Volume service volumes, create the additional policy with both the following policy statements:
allow any-user to manage volumes in TENANCY where request.principal.type = ‘cluster’
allow any-user to manage volume-attachments in TENANCY where request.principal.type = ‘cluster’
You can dynamically provision a block volume using the CSI plugin specified by the oci-bv storage class’s definition (provisioner: blockvolume.csi.oraclecloud.com). For example, if the cluster administrator has not created any suitable PVs that match the PVC request.
You define a PVC in a file called csi-bvs-pvc.yaml. For example:
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: mynginxclaim
spec:
storageClassName: “oci-bv”
accessModes:
– ReadWriteOnce
resources:
requests:
storage: 50Gi
Enter the following command to create the PVC from the csi-bvs-pvc.yaml file:
Verify that the PVC has been created by running:
You can use this PVC when creating other objects, such as pods.
Want more ?
Here are some topics and docs related above topic.
creating persistence volume claim and expanding
document covers indetail on creating PVC on block storage and filesystem also to expand without having to reattach PVC.