Add vSphere Volume Examples
This commit is contained in:
parent
dcde2bd577
commit
2ec0f9577a
|
@ -92,7 +92,7 @@ metadata:
|
|||
name: slow
|
||||
provisioner: kubernetes.io/vsphere-volume
|
||||
parameters:
|
||||
diskformat: thin
|
||||
diskformat: eagerzeroedthick
|
||||
```
|
||||
|
||||
* `diskformat`: `thin`, `zeroedthick` and `eagerzeroedthick`. See vSphere docs for details. Default: `"thin"`.
|
||||
|
|
|
@ -0,0 +1,372 @@
|
|||
<!-- BEGIN MUNGE: UNVERSIONED_WARNING -->
|
||||
|
||||
<!-- BEGIN STRIP_FOR_RELEASE -->
|
||||
|
||||
<img src="http://kubernetes.io/kubernetes/img/warning.png" alt="WARNING"
|
||||
width="25" height="25">
|
||||
<img src="http://kubernetes.io/kubernetes/img/warning.png" alt="WARNING"
|
||||
width="25" height="25">
|
||||
<img src="http://kubernetes.io/kubernetes/img/warning.png" alt="WARNING"
|
||||
width="25" height="25">
|
||||
<img src="http://kubernetes.io/kubernetes/img/warning.png" alt="WARNING"
|
||||
width="25" height="25">
|
||||
<img src="http://kubernetes.io/kubernetes/img/warning.png" alt="WARNING"
|
||||
width="25" height="25">
|
||||
|
||||
<h2>PLEASE NOTE: This document applies to the HEAD of the source tree</h2>
|
||||
|
||||
If you are using a released version of Kubernetes, you should
|
||||
refer to the docs that go with that version.
|
||||
|
||||
Documentation for other releases can be found at
|
||||
[releases.k8s.io](http://releases.k8s.io).
|
||||
</strong>
|
||||
--
|
||||
|
||||
<!-- END STRIP_FOR_RELEASE -->
|
||||
|
||||
<!-- END MUNGE: UNVERSIONED_WARNING -->
|
||||
|
||||
|
||||
# vSphere Volume
|
||||
|
||||
- [Prerequisites](#prerequisites)
|
||||
- [Examples](#examples)
|
||||
- [Volumes](#volumes)
|
||||
- [Persistent Volumes](#persistent-volumes)
|
||||
- [Storage Class](#storage-class)
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- Kubernetes with vSphere Cloud Provider configured.
|
||||
For cloudprovider configuration please refer [vSphere getting started guide](http://kubernetes.io/docs/getting-started-guides/vsphere/).
|
||||
|
||||
## Examples
|
||||
|
||||
### Volumes
|
||||
|
||||
1. Create VMDK.
|
||||
|
||||
First ssh into ESX and then use following command to create vmdk,
|
||||
|
||||
```shell
|
||||
vmkfstools -c 2G /vmfs/volumes/datastore1/volumes/myDisk.vmdk
|
||||
```
|
||||
|
||||
2. Create Pod which uses 'myDisk.vmdk'.
|
||||
|
||||
See example
|
||||
|
||||
```yaml
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: test-vmdk
|
||||
spec:
|
||||
containers:
|
||||
- image: gcr.io/google_containers/test-webserver
|
||||
name: test-container
|
||||
volumeMounts:
|
||||
- mountPath: /test-vmdk
|
||||
name: test-volume
|
||||
volumes:
|
||||
- name: test-volume
|
||||
# This VMDK volume must already exist.
|
||||
vsphereVolume:
|
||||
volumePath: "[datastore1] volumes/myDisk"
|
||||
fsType: ext4
|
||||
```
|
||||
|
||||
[Download example](vsphere-volume-pod.yaml?raw=true)
|
||||
|
||||
Creating the pod:
|
||||
|
||||
``` bash
|
||||
$ kubectl create -f examples/volumes/vsphere/vsphere-volume-pod.yaml
|
||||
```
|
||||
|
||||
Verify that pod is running:
|
||||
|
||||
```bash
|
||||
$ kubectl get pods test-vmdk
|
||||
NAME READY STATUS RESTARTS AGE
|
||||
test-vmdk 1/1 Running 0 48m
|
||||
```
|
||||
|
||||
### Persistent Volumes
|
||||
|
||||
1. Create VMDK.
|
||||
|
||||
First ssh into ESX and then use following command to create vmdk,
|
||||
|
||||
```shell
|
||||
vmkfstools -c 2G /vmfs/volumes/datastore1/volumes/myDisk.vmdk
|
||||
```
|
||||
|
||||
2. Create Persistent Volume.
|
||||
|
||||
See example:
|
||||
|
||||
```yaml
|
||||
apiVersion: v1
|
||||
kind: PersistentVolume
|
||||
metadata:
|
||||
name: pv0001
|
||||
spec:
|
||||
capacity:
|
||||
storage: 2Gi
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
persistentVolumeReclaimPolicy: Retain
|
||||
vsphereVolume:
|
||||
volumePath: "[datastore1] volumes/myDisk"
|
||||
fsType: ext4
|
||||
```
|
||||
|
||||
[Download example](vsphere-volume-pv.yaml?raw=true)
|
||||
|
||||
Creating the persistent volume:
|
||||
|
||||
``` bash
|
||||
$ kubectl create -f examples/volumes/vsphere/vsphere-volume-pv.yaml
|
||||
```
|
||||
|
||||
Verifying persistent volume is created:
|
||||
|
||||
``` bash
|
||||
$ kubectl describe pv pv0001
|
||||
Name: pv0001
|
||||
Labels: <none>
|
||||
Status: Available
|
||||
Claim:
|
||||
Reclaim Policy: Retain
|
||||
Access Modes: RWO
|
||||
Capacity: 2Gi
|
||||
Message:
|
||||
Source:
|
||||
Type: vSphereVolume (a Persistent Disk resource in vSphere)
|
||||
VolumePath: [datastore1] volumes/myDisk
|
||||
FSType: ext4
|
||||
No events.
|
||||
```
|
||||
|
||||
3. Create Persistent Volume Claim.
|
||||
|
||||
See example:
|
||||
|
||||
```yaml
|
||||
kind: PersistentVolumeClaim
|
||||
apiVersion: v1
|
||||
metadata:
|
||||
name: pvc0001
|
||||
spec:
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
resources:
|
||||
requests:
|
||||
storage: 2Gi
|
||||
```
|
||||
|
||||
[Download example](vsphere-volume-pvc.yaml?raw=true)
|
||||
|
||||
Creating the persistent volume claim:
|
||||
|
||||
``` bash
|
||||
$ kubectl create -f examples/volumes/vsphere/vsphere-volume-pvc.yaml
|
||||
```
|
||||
|
||||
Verifying persistent volume claim is created:
|
||||
|
||||
``` bash
|
||||
$ kubectl describe pvc pvc0001
|
||||
Name: pvc0001
|
||||
Namespace: default
|
||||
Status: Bound
|
||||
Volume: pv0001
|
||||
Labels: <none>
|
||||
Capacity: 2Gi
|
||||
Access Modes: RWO
|
||||
No events.
|
||||
```
|
||||
|
||||
3. Create Pod which uses Persistent Volume Claim.
|
||||
|
||||
See example:
|
||||
|
||||
```yaml
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: pvpod
|
||||
spec:
|
||||
containers:
|
||||
- name: test-container
|
||||
image: gcr.io/google_containers/test-webserver
|
||||
volumeMounts:
|
||||
- name: test-volume
|
||||
mountPath: /test-vmdk
|
||||
volumes:
|
||||
- name: vmdk-storage
|
||||
persistentVolumeClaim:
|
||||
claimName: pvc0001
|
||||
```
|
||||
|
||||
[Download example](vsphere-volume-pvcpod.yaml?raw=true)
|
||||
|
||||
Creating the pod:
|
||||
|
||||
``` bash
|
||||
$ kubectl create -f examples/volumes/vsphere/vsphere-volume-pvcpod.yaml
|
||||
```
|
||||
|
||||
Verifying pod is created:
|
||||
|
||||
``` bash
|
||||
$ kubectl get pod pvpod
|
||||
NAME READY STATUS RESTARTS AGE
|
||||
pvpod 1/1 Running 0 48m
|
||||
```
|
||||
|
||||
### Storage Class
|
||||
|
||||
__Note: Here you don't need to create vmdk it is created for you.__
|
||||
1. Create Storage Class.
|
||||
|
||||
See example:
|
||||
|
||||
```yaml
|
||||
kind: StorageClass
|
||||
apiVersion: storage.k8s.io/v1beta1
|
||||
metadata:
|
||||
name: fast
|
||||
provisioner: kubernetes.io/vsphere-volume
|
||||
parameters:
|
||||
diskformat: zeroedthick
|
||||
```
|
||||
|
||||
[Download example](vsphere-volume-sc-fast.yaml?raw=true)
|
||||
|
||||
Creating the storageclass:
|
||||
|
||||
``` bash
|
||||
$ kubectl create -f examples/volumes/vsphere/vsphere-volume-sc-fast.yaml
|
||||
```
|
||||
|
||||
Verifying storage class is created:
|
||||
|
||||
``` bash
|
||||
$ kubectl describe storageclass fast
|
||||
Name: fast
|
||||
Annotations: <none>
|
||||
Provisioner: kubernetes.io/vsphere-volume
|
||||
Parameters: diskformat=zeroedthick
|
||||
No events.
|
||||
```
|
||||
|
||||
2. Create Persistent Volume Claim.
|
||||
|
||||
See example:
|
||||
|
||||
```yaml
|
||||
kind: PersistentVolumeClaim
|
||||
apiVersion: v1
|
||||
metadata:
|
||||
name: pvcsc001
|
||||
annotations:
|
||||
volume.beta.kubernetes.io/storage-class: fast
|
||||
spec:
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
resources:
|
||||
requests:
|
||||
storage: 2Gi
|
||||
```
|
||||
|
||||
[Download example](vsphere-volume-pvcsc.yaml?raw=true)
|
||||
|
||||
Creating the persistent volume claim:
|
||||
|
||||
``` bash
|
||||
$ kubectl create -f examples/volumes/vsphere/vsphere-volume-pvcsc.yaml
|
||||
```
|
||||
|
||||
Verifying persistent volume claim is created:
|
||||
|
||||
``` bash
|
||||
$ kubectl describe pvc pvcsc001
|
||||
Name: pvcsc001
|
||||
Namespace: default
|
||||
Status: Bound
|
||||
Volume: pvc-80f7b5c1-94b6-11e6-a24f-005056a79d2d
|
||||
Labels: <none>
|
||||
Capacity: 2Gi
|
||||
Access Modes: RWO
|
||||
No events.
|
||||
```
|
||||
|
||||
Persistent Volume is automatically created and is bounded to this pvc.
|
||||
|
||||
Verifying persistent volume claim is created:
|
||||
|
||||
``` bash
|
||||
$ kubectl describe pv pvc-80f7b5c1-94b6-11e6-a24f-005056a79d2d
|
||||
Name: pvc-80f7b5c1-94b6-11e6-a24f-005056a79d2d
|
||||
Labels: <none>
|
||||
Status: Bound
|
||||
Claim: default/pvcsc001
|
||||
Reclaim Policy: Delete
|
||||
Access Modes: RWO
|
||||
Capacity: 2Gi
|
||||
Message:
|
||||
Source:
|
||||
Type: vSphereVolume (a Persistent Disk resource in vSphere)
|
||||
VolumePath: [datastore1] kubevols/kubernetes-dynamic-pvc-80f7b5c1-94b6-11e6-a24f-005056a79d2d.vmdk
|
||||
FSType: ext4
|
||||
No events.
|
||||
```
|
||||
|
||||
__Note: VMDK is created inside ```kubevols``` folder in datastore which is mentioned in 'vsphere' cloudprovider configuration.
|
||||
The cloudprovider config is created during setup of Kubernetes cluster on vSphere.__
|
||||
|
||||
3. Create Pod which uses Persistent Volume Claim with storage class.
|
||||
|
||||
See example:
|
||||
|
||||
```yaml
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: pvpod
|
||||
spec:
|
||||
containers:
|
||||
- name: test-container
|
||||
image: gcr.io/google_containers/test-webserver
|
||||
volumeMounts:
|
||||
- name: test-volume
|
||||
mountPath: /test-vmdk
|
||||
volumes:
|
||||
- name: vmdk-storage
|
||||
persistentVolumeClaim:
|
||||
claimName: pvcsc001
|
||||
```
|
||||
|
||||
[Download example](vsphere-volume-pvcscpod.yaml?raw=true)
|
||||
|
||||
Creating the pod:
|
||||
|
||||
``` bash
|
||||
$ kubectl create -f examples/volumes/vsphere/vsphere-volume-pvcscpod.yaml
|
||||
```
|
||||
|
||||
Verifying pod is created:
|
||||
|
||||
``` bash
|
||||
$ kubectl get pod pvpod
|
||||
NAME READY STATUS RESTARTS AGE
|
||||
pvpod 1/1 Running 0 48m
|
||||
```
|
||||
|
||||
|
||||
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
|
||||
[]()
|
||||
<!-- END MUNGE: GENERATED_ANALYTICS -->
|
|
@ -0,0 +1,22 @@
|
|||
apiVersion: extensions/v1beta1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: deployment
|
||||
spec:
|
||||
replicas: 1
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: redis
|
||||
spec:
|
||||
containers:
|
||||
- name: redis
|
||||
image: redis
|
||||
volumeMounts:
|
||||
- name: vmfs-vmdk-storage
|
||||
mountPath: /data/
|
||||
volumes:
|
||||
- name: vmfs-vmdk-storage
|
||||
vsphereVolume:
|
||||
volumePath: "[Datastore] volumes/testdir"
|
||||
fsType: ext4
|
|
@ -0,0 +1,17 @@
|
|||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: test-vmdk
|
||||
spec:
|
||||
containers:
|
||||
- image: gcr.io/google_containers/test-webserver
|
||||
name: test-container
|
||||
volumeMounts:
|
||||
- mountPath: /test-vmdk
|
||||
name: test-volume
|
||||
volumes:
|
||||
- name: test-volume
|
||||
# This VMDK volume must already exist.
|
||||
vsphereVolume:
|
||||
volumePath: "[DatastoreName] volumes/myDisk"
|
||||
fsType: ext4
|
|
@ -0,0 +1,13 @@
|
|||
apiVersion: v1
|
||||
kind: PersistentVolume
|
||||
metadata:
|
||||
name: pv0001
|
||||
spec:
|
||||
capacity:
|
||||
storage: 2Gi
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
persistentVolumeReclaimPolicy: Retain
|
||||
vsphereVolume:
|
||||
volumePath: "[DatastoreName] volumes/myDisk"
|
||||
fsType: ext4
|
|
@ -0,0 +1,10 @@
|
|||
kind: PersistentVolumeClaim
|
||||
apiVersion: v1
|
||||
metadata:
|
||||
name: pvc0001
|
||||
spec:
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
resources:
|
||||
requests:
|
||||
storage: 2Gi
|
|
@ -0,0 +1,15 @@
|
|||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: pvpod
|
||||
spec:
|
||||
containers:
|
||||
- name: test-container
|
||||
image: gcr.io/google_containers/test-webserver
|
||||
volumeMounts:
|
||||
- name: test-volume
|
||||
mountPath: /test-vmdk
|
||||
volumes:
|
||||
- name: vmdk-storage
|
||||
persistentVolumeClaim:
|
||||
claimName: pvc0001
|
|
@ -0,0 +1,12 @@
|
|||
kind: PersistentVolumeClaim
|
||||
apiVersion: v1
|
||||
metadata:
|
||||
name: pvcsc001
|
||||
annotations:
|
||||
volume.beta.kubernetes.io/storage-class: fast
|
||||
spec:
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
resources:
|
||||
requests:
|
||||
storage: 2Gi
|
|
@ -0,0 +1,15 @@
|
|||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: pvpod
|
||||
spec:
|
||||
containers:
|
||||
- name: test-container
|
||||
image: gcr.io/google_containers/test-webserver
|
||||
volumeMounts:
|
||||
- name: test-volume
|
||||
mountPath: /test-vmdk
|
||||
volumes:
|
||||
- name: vmdk-storage
|
||||
persistentVolumeClaim:
|
||||
claimName: pvcsc0001
|
|
@ -0,0 +1,7 @@
|
|||
kind: StorageClass
|
||||
apiVersion: storage.k8s.io/v1beta1
|
||||
metadata:
|
||||
name: fast
|
||||
provisioner: kubernetes.io/vsphere-volume
|
||||
parameters:
|
||||
diskformat: zeroedthick
|
Loading…
Reference in New Issue