Unlike virtualization, in modern containerization technologies Kubernetes or Openshift doesn't include embedded storage with containers. Altough a standard vm contains embedded storage due to requirement of operation systems, already comes with virtual disks and it's storage space.
In Kubernetes, Openshift and other variants, as an Administrator, you need to preconfigure the storage for for your containers/pods. You or your administrator needs to provide your node to persistent storage space(s). This spaces can be traditional block storage (iscsi, fc), file storage (cifs,nfs) or cloud storage (s3,azure files,ebs).
Whatever technology you use, you need a Persistent Volume Claim (PVC) to provide persistent storage space to containers.
As a first task, I recommend you to create a resource quota for your PVC to limit exhausting storage space. I'm going to tell openshift to limit "the project" or "namespace" to use total 500GB storage space and maximum allowed PVC count to limit 3.
[ozgurkkisa@workstation ~]$oc create quota storage \ --hard=requests.storage=500G,persistentvolumeclaims=3In other words, an Admin or a Developer can create max 3 PvC and total 500 GB space for projects containers. So they would be create space for their containers, for instance pvc1 = 150 GB, pvc2 = 150 GB, pv3 = 200 GB.
[ozgurkkisa@workstation ~]$ touch pvc.ymlOpen file that you created with your favorite text editor. For example nano or vim. Then write or paste the content below :
apiVersion: v1 kind: PersistentVolumeClaim metadata: name: Apache-www spec: accessModes: - ReadWriteManystorageClassName: nfs-storage
resources: requests: storage: 300Gi
[student@workstation ~]$ oc apply -f pvc.yml persistentvolumeclaim/Apache-www created
oc delete persistentvolumeclaim Apache-www persistentvolumeclaim "Apache-www" deleted
[student@workstation ~]$ oc get persistentvolumeclaims NAMESTATUS
VOLUME CAPACITY ACCESS MODESSTORAGECLASS
AGE Apache-wwwBound
pvc-... 300Gi RWXnfs-storage
15s
apiVersion: apps/v1
kind: Deployment
metadata:
name: httpd
spec:
replicas: 1
selector:
app: httpd
template:
metadata:
labels:
app: httpd
spec:
containers:
- image: registy.access.redhat.com/rhscl/httpd-24-rhel7
imagePullPolicy : Always
name: httpd
ports:
- containerport: 8080
protocol: TCP
- containerPort: 8443
protocol: TCP
VolumeMounts:
- mountPath: /var/www/html
name: html
restartPolicy: Always
volumes:
- name: html
persistenVolumeClaim:
Apache-www
Be aware that marked with yellow lines. These are volume spesific data that bind persistent storage to our container/pod. In the sample above, we simply add persistent volume claim named Apache-www and it's related space to containers /var/www/html directory.[ozgurkkisa@workstation ~]$ oc apply -f apache.yml
Comments
Post a Comment