-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
csi-hostpath-driver & volumesnapshots addons docs and test
- Loading branch information
Showing
9 changed files
with
282 additions
and
1 deletion.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
site/content/en/docs/tutorials/volume_snapshots_and_csi.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,40 @@ | ||
--- | ||
title: "CSI Driver and Volume Snapshots" | ||
linkTitle: "CSI Driver and Volume Snapshots" | ||
weight: 1 | ||
date: 2020-08-06 | ||
description: > | ||
CSI Driver and Volume Snapshots | ||
--- | ||
|
||
## Overview | ||
|
||
This tutorial explains how to set up the CSI Hostpath Driver in minikube and create volume snapshots. | ||
|
||
## Prerequisites | ||
|
||
- latest version of minikube | ||
|
||
## Tutorial | ||
|
||
Support for volume snapshots in minikube is provided through the `volumesnapshots` addon. This addon provisions the required | ||
CRDs and deploys the Volume Snapshot Controller. It is <b>enabled by default</b>. | ||
|
||
However, the default storage provider in minikube does not implement the CSI interface and thus is NOT capable of | ||
creating/handling volume snapshots. To utilize the volume snapshots functionality, you must first deploy a CSI driver. | ||
To make this easy, minikube offers the `csi-hostpath-driver` addon, which deploys the [CSI Hostpath Driver](https://github.com/kubernetes-csi/csi-driver-host-path). | ||
By default, this addon is <b>disabled</b>. | ||
|
||
You can enable/disable either of the above-mentioned addons using | ||
```shell script | ||
minikube addons enable [ADDON_NAME] | ||
minikube addons disable [ADDON_NAME] | ||
``` | ||
|
||
The `csi-hostpath-driver` addon deploys its required resources into the `kube-system` namespace and sets up a dedicated | ||
storage class called `csi-hostpath-sc` that you need to reference in your PVCs. The driver itself is created under the | ||
name `hostpath.csi.k8s.io`. Use this wherever necessary (for example snapshot class definitions). | ||
|
||
Once both addons are enabled, you can create persistent volumes and snapshots using standard ways (for a quick test of | ||
volume snapshots, you can find some example yaml files with a step-by-step [here](https://kubernetes-csi.github.io/docs/snapshot-restore-feature.html)). | ||
The driver stores all persistent volumes in the `/var/lib/csi-hostpath-data/` directory of minikube's host. |
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
22 changes: 22 additions & 0 deletions
22
test/integration/testdata/csi-hostpath-driver/pv-pod-restore.yaml
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,22 @@ | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: task-pv-pod-restore | ||
labels: | ||
app: task-pv-pod-restore | ||
spec: | ||
volumes: | ||
- name: task-pv-storage | ||
persistentVolumeClaim: | ||
claimName: hpvc-restore | ||
containers: | ||
- name: task-pv-container | ||
image: nginx | ||
ports: | ||
- containerPort: 80 | ||
name: "http-server" | ||
volumeMounts: | ||
- mountPath: "/usr/share/nginx/html" | ||
name: task-pv-storage | ||
|
||
|
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,22 @@ | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: task-pv-pod | ||
labels: | ||
app: task-pv-pod | ||
spec: | ||
volumes: | ||
- name: task-pv-storage | ||
persistentVolumeClaim: | ||
claimName: hpvc | ||
containers: | ||
- name: task-pv-container | ||
image: nginx | ||
ports: | ||
- containerPort: 80 | ||
name: "http-server" | ||
volumeMounts: | ||
- mountPath: "/usr/share/nginx/html" | ||
name: task-pv-storage | ||
|
||
|
15 changes: 15 additions & 0 deletions
15
test/integration/testdata/csi-hostpath-driver/pvc-restore.yaml
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,15 @@ | ||
apiVersion: v1 | ||
kind: PersistentVolumeClaim | ||
metadata: | ||
name: hpvc-restore | ||
spec: | ||
storageClassName: csi-hostpath-sc | ||
dataSource: | ||
name: new-snapshot-demo | ||
kind: VolumeSnapshot | ||
apiGroup: snapshot.storage.k8s.io | ||
accessModes: | ||
- ReadWriteOnce | ||
resources: | ||
requests: | ||
storage: 1Gi |
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,11 @@ | ||
apiVersion: v1 | ||
kind: PersistentVolumeClaim | ||
metadata: | ||
name: hpvc | ||
spec: | ||
storageClassName: csi-hostpath-sc | ||
accessModes: | ||
- ReadWriteOnce | ||
resources: | ||
requests: | ||
storage: 1Gi |
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,8 @@ | ||
apiVersion: snapshot.storage.k8s.io/v1beta1 | ||
kind: VolumeSnapshot | ||
metadata: | ||
name: new-snapshot-demo | ||
spec: | ||
volumeSnapshotClassName: csi-hostpath-snapclass | ||
source: | ||
persistentVolumeClaimName: hpvc |
6 changes: 6 additions & 0 deletions
6
test/integration/testdata/csi-hostpath-driver/snapshotclass.yaml
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,6 @@ | ||
apiVersion: snapshot.storage.k8s.io/v1beta1 | ||
kind: VolumeSnapshotClass | ||
metadata: | ||
name: csi-hostpath-snapclass | ||
driver: hostpath.csi.k8s.io #csi-hostpath | ||
deletionPolicy: Delete |