-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3521d05
commit cbd39e8
Showing
7 changed files
with
135 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#################################################################################################### | ||
# Author: Cuong. Duong Manh <[email protected]> | ||
# Description: This is an example of using block volume | ||
# This example will create a StorageClass, a PVC and a Pod | ||
# The Pod will use the PVC to mount a block volume to /var/lib/www/html | ||
# The Pod will use nginx image to serve the content of the block volume | ||
#################################################################################################### | ||
|
||
apiVersion: storage.k8s.io/v1 | ||
kind: StorageClass | ||
metadata: | ||
name: my-storage-class # [1] The StorageClass name, CAN be changed | ||
provisioner: csi.vngcloud.vn # The CSI driver name | ||
parameters: | ||
type: vtype-6790f903-38d2-454d-919e-5b49184b5927 # Change it to your volume type UUID or name | ||
--- | ||
|
||
apiVersion: v1 | ||
kind: PersistentVolumeClaim | ||
metadata: | ||
name: my-pvc # [2] The PVC name, CAN be changed | ||
spec: | ||
accessModes: | ||
- ReadWriteOnce # MUST set this value, currently only support RWO | ||
resources: | ||
requests: | ||
storage: 20Gi # [3] The PVC size, CAN be changed, this value MUST be in the valid range of the proper volume type | ||
storageClassName: my-storage-class # MUST be same value with [1], not set this value will use default StorageClass | ||
--- | ||
|
||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: nginx | ||
spec: | ||
containers: | ||
- image: nginx | ||
imagePullPolicy: Always | ||
name: nginx | ||
ports: | ||
- containerPort: 80 | ||
protocol: TCP | ||
volumeMounts: | ||
- mountPath: /var/lib/www/html # The mount path in container, CAN be changed | ||
name: my-volume-name # MUST be same value with [4] | ||
volumes: | ||
- name: my-volume-name # [4] The volume mount name, CAN be changed | ||
persistentVolumeClaim: | ||
claimName: my-pvc # MUST be same value with [2] | ||
readOnly: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
src/helm-charts/vcontainer-storage-interface/example/block-volume.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<div style="float: right;"><img src="../../../images/01.png" width="160px" /></div><br> | ||
|
||
|
||
# Block volume | ||
The following manifest will first create a `StorageClass` named `my-storage-class` and subsequently generate a `PersistentVolumeClaim` named `my-pvc`. Finally, it will deploy an `nginx` `Pod` utilizing the aforementioned `PersistentVolumeClaim`: | ||
|
||
***File [block-volume.yaml](https://github.com/vngcloud/vcontainer-helm-infra-documentation/manifests/block-volume/block-volume.yaml)*** | ||
```yaml= | ||
apiVersion: storage.k8s.io/v1 | ||
kind: StorageClass | ||
metadata: | ||
name: my-storage-class # [1] The StorageClass name, CAN be changed | ||
provisioner: csi.vngcloud.vn # The CSI driver name | ||
parameters: | ||
type: vtype-6790f903-38d2-454d-919e-5b49184b5927 # Change it to your volume type UUID from portal | ||
--- | ||
apiVersion: v1 | ||
kind: PersistentVolumeClaim | ||
metadata: | ||
name: my-pvc # [2] The PVC name, CAN be changed | ||
spec: | ||
accessModes: | ||
- ReadWriteOnce # MUST set this value, currently only support RWO | ||
resources: | ||
requests: | ||
storage: 20Gi # [3] The PVC size, CAN be changed, this value MUST be in the valid range of the proper volume type | ||
storageClassName: my-storage-class # MUST be same value with [1], not set this value will use default StorageClass | ||
--- | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: nginx | ||
spec: | ||
containers: | ||
- image: nginx | ||
imagePullPolicy: Always | ||
name: nginx | ||
ports: | ||
- containerPort: 80 | ||
protocol: TCP | ||
volumeMounts: | ||
- mountPath: /var/lib/www/html # The mount path in container, CAN be changed | ||
name: my-volume-name # MUST be same value with [4] | ||
volumes: | ||
- name: my-volume-name # [4] The volume mount name, CAN be changed | ||
persistentVolumeClaim: | ||
claimName: my-pvc # MUST be same value with [2] | ||
readOnly: false | ||
``` | ||
|
||
Apply the manifest: | ||
```bash= | ||
kubectl apply -f block-volume.yaml | ||
``` | ||
|
||
<center> | ||
|
||
![](./../../../images/17.png) | ||
|
||
</center> | ||
|
||
Verify the associated resources within a few seconds: | ||
```bash= | ||
kubectl get sc,pvc,pod -owide | ||
``` | ||
|
||
<center> | ||
|
||
![](./../../../images/18.png) | ||
|
||
</center> | ||
|
||
Users also can verify this `PersistentVolumeClaim` on the **VNG CLOUD portal**: | ||
|
||
<center> | ||
|
||
![](./../../../images/19.png) | ||
|
||
</center> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.