Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update examples and documentation #214

Merged
merged 1 commit into from
May 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
161 changes: 26 additions & 135 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,145 +41,36 @@ See Github [Issues](https://github.com/kubernetes-sigs/gcp-compute-persistent-di

### CreateVolume Parameters

| Parameter | Values | Default | Description |
|--------------------|----------------------|-------------|-----------------------------------------------------------------------------------------------------------------------------|
| "type" | pd-ssd OR pd-standard | pd-standard | Type allows you to choose between standard Persistent Disks or Solid State Drive Persistent Disks |
| "replication-type" | none OR regional-pd | none | Replication type allows you to choose between standard zonal Persistent Disks or highly available Regional Persistent Disks |

### Future Features

See Github [Issues](https://github.com/kubernetes-sigs/gcp-compute-persistent-disk-csi-driver/issues)
| Parameter | Values | Default | Description |
|------------------|---------------------------|---------------|----------------------------------------------------------------------------------------------------|
| type | `pd-ssd` OR `pd-standard` | `pd-standard` | Type allows you to choose between standard Persistent Disks or Solid State Drive Persistent Disks |
| replication-type | `none` OR `regional-pd` | `none` | Replication type allows you to choose between Zonal Persistent Disks or Regional Persistent Disks |

### Topology

This driver supports only one topology key:
`topology.gke.io/zone`
that represents availability by zone.

## Kubernetes User Guide

### Install Driver

1. [One-time per project] Create GCP service account for the CSI driver and set required roles
```
$ PROJECT=your-project-here # GCP project
$ GCE_PD_SA_NAME=my-gce-pd-csi-sa # Name of the service account to create
$ GCE_PD_SA_DIR=/my/safe/credentials/directory # Directory to save the service account key
$ ./deploy/setup-project.sh
```

2. Deploy driver to Kubernetes Cluster
```
$ GCE_PD_SA_DIR=/my/safe/credentials/directory # Directory to get the service account key
$ GCE_PD_DRIVER_VERSION=stable # Driver version to deploy
$ ./deploy/kubernetes/deploy-driver.sh
```

### Zonal Example

1. Create example Zonal Storage Class
```
$ kubectl apply -f ./examples/kubernetes/demo-zonal-sc.yaml
```

2. Create example PVC and Pod
```
$ kubectl apply -f ./examples/kubernetes/demo-pod.yaml
```

3. Verify PV is created and bound to PVC
```
$ kubectl get pvc
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
podpvc Bound pvc-e36abf50-84f3-11e8-8538-42010a800002 10Gi RWO csi-gce-pd 9s
```

4. Verify pod is created and in `RUNNING` state (it may take a few minutes to get to running state)
```
$ kubectl get pods
NAME READY STATUS RESTARTS AGE
web-server 1/1 Running 0 1m
```

### Snapshot Example

Please note that VolumeSnapshot is currently alpha feature. In order to enable this feature, please install CSI driver with
dev version by setting the environment variable "GCE_PD_DRIVER_VERSION=dev"
1. Create example Default Snapshot Class
```
$ kubectl create -f ./examples/kubernetes/demo-defaultsnapshotclass.yaml
```
2. Create a snapshot of the PVC created in above example
```
$ kubectl create -f ./examples/kubernetes/demo-snapshot.yaml
```
3. Verify Snapshot is created and is ready to use
```
$ k get volumesnapshots demo-snapshot-podpvc -o yaml
apiVersion: snapshot.storage.k8s.io/v1alpha1
kind: VolumeSnapshot
metadata:
creationTimestamp: 2018-10-05T16:59:26Z
generation: 1
name: demo-snapshot-podpvc
namespace: default

...

status:
creationTime: 2018-10-05T16:59:27Z
ready: true
restoreSize: 6Gi

```
4. Create a new volume from the snapshot
```
$ kubectl create -f ./examples/kubernetes/demo-restore-snapshot.yaml
```

## Kubernetes Development

### Manual

To build and install a development version of the driver:
```
$ GCE_PD_CSI_STAGING_IMAGE=gcr.io/path/to/driver/image:dev # Location to push dev image to
$ make push-container

# Modify controller.yaml and node.yaml in ./deploy/kubernetes/dev to use dev image
$ GCE_PD_DRIVER_VERSION=dev
$ ./deploy/kubernetes/deploy-driver.sh
```

To bring down driver:
```
$ ./deploy/kubernetes/delete-driver.sh
```

## Testing

Running E2E Tests:
```
$ PROJECT=my-project # GCP Project to run tests in
$ IAM_NAME=my-iam@project.iam.gserviceaccount.com # Existing IAM Account with GCE PD CSI Driver Permissions
$ ./test/run-e2e-local.sh
```

Running Sanity Tests:
```
$ ./test/run-sanity.sh
```

Running Unit Tests:
```
$ ./test/run-unit.sh
```

## Dependency Management

Use [dep](https://github.com/golang/dep)
```
$ dep ensure
```

To modify dependencies or versions change `./Gopkg.toml`
### Kubernetes Beta Features

* Topology: Requires K8s 1.14+ on Master and Nodes and PD driver v0.5.0+
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0.5.0 not yet release

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I change it to "dev", are we going to remember to change it back?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably not, lets leave it like this


### Kubernetes Alpha Features

* Snapshots: Requires K8s 1.13+ on Master and PD driver v0.3.0+ with the alpha
overlay

### Future Features

See Github [Issues](https://github.com/kubernetes-sigs/gcp-compute-persistent-disk-csi-driver/issues)

## Further Documentation

[Local Development](docs/local-development.md)

### Kubernetes

[User Guides](docs/kubernetes/user-guides)

[Driver Development](docs/kubernetes/development.md)
21 changes: 21 additions & 0 deletions docs/kubernetes/development.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Kubernetes Development

## Manual

To build and install a development version of the driver:
```
$ GCE_PD_CSI_STAGING_IMAGE=gcr.io/path/to/driver/image:dev # Location to push dev image to
$ make push-container

# Modify controller.yaml and node.yaml in ./deploy/kubernetes/dev to use dev image
$ GCE_PD_DRIVER_VERSION=dev
$ ./deploy/kubernetes/deploy-driver.sh
```

To bring down driver:
```
$ ./deploy/kubernetes/delete-driver.sh
```

## TODO Testing

87 changes: 87 additions & 0 deletions docs/kubernetes/user-guides/basic.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# Kubernetes Basic User Guide
This guide gives a simple example on how to provision zonal and regional PDs in single-zone and regional clusters.

**Note:** Regional cluster support only available in beta starting with
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe move/duplicate this note in the "regional PD" section

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I duplicated it because you can use single-zone pds in a regional cluster too

Kubernetes 1.14.

## Install Driver

1. [One-time per project] Create GCP service account for the CSI driver and set required roles
```
$ PROJECT=your-project-here # GCP project
$ GCE_PD_SA_NAME=my-gce-pd-csi-sa # Name of the service account to create
$ GCE_PD_SA_DIR=/my/safe/credentials/directory # Directory to save the service account key
$ ./deploy/setup-project.sh
```

2. Deploy driver to Kubernetes Cluster
```
$ GCE_PD_SA_DIR=/my/safe/credentials/directory # Directory to get the service account key
$ GCE_PD_DRIVER_VERSION=stable # Driver version to deploy
$ ./deploy/kubernetes/deploy-driver.sh
```

## Zonal PD example
This example provisions a zonal PD in both single-zone and regional clusters.

1. Create example Zonal Storage Class
```
$ kubectl apply -f ./examples/kubernetes/demo-zonal-sc.yaml
```

2. Create example PVC and Pod
```
$ kubectl apply -f ./examples/kubernetes/demo-pod.yaml
```

3. Verify PV is created and bound to PVC
```
$ kubectl get pvc
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
podpvc Bound pvc-e36abf50-84f3-11e8-8538-42010a800002 10Gi RWO csi-gce-pd 9s
```

4. Verify pod is created and in `RUNNING` state (it may take a few minutes to get to running state)
```
$ kubectl get pods
NAME READY STATUS RESTARTS AGE
web-server 1/1 Running 0 1m
```

## Regional PD example

**Note:** Regional cluster support only available in beta starting with
Kubernetes 1.14.

This example provisions a regional PD in regional clusters.

1. Create example Regional Storage Class. Choose between:

* Unrestricted zones
```
$ kubectl apply -f ./examples/kubernetes/demo-regional-sc.yaml
```

* Restricted zones
```
$ kubectl apply -f ./examples/kubernetes/demo-regional-restricted-sc.yaml
```

2. Create example PVC and Pod
```
$ kubectl apply -f ./examples/kubernetes/demo-pod.yaml
```

3. Verify PV is created and bound to PVC
```
$ kubectl get pvc
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
podpvc Bound pvc-e36abf50-84f3-11e8-8538-42010a800002 10Gi RWO csi-gce-pd 9s
```

4. Verify pod is created and in `RUNNING` state (it may take a few minutes to get to running state)
```
$ kubectl get pods
NAME READY STATUS RESTARTS AGE
web-server 1/1 Running 0 1m
```
51 changes: 51 additions & 0 deletions docs/kubernetes/user-guides/snapshots.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Kubernetes Snapshots User Guide (Alpha)

### Install Driver with alpha snapshot feature

1. [One-time per project] Create GCP service account for the CSI driver and set required roles
```
$ PROJECT=your-project-here # GCP project
$ GCE_PD_SA_NAME=my-gce-pd-csi-sa # Name of the service account to create
$ GCE_PD_SA_DIR=/my/safe/credentials/directory # Directory to save the service account key
$ ./deploy/setup-project.sh
```

2. Deploy driver to Kubernetes Cluster
```
$ GCE_PD_SA_DIR=/my/safe/credentials/directory # Directory to get the service account key
$ GCE_PD_DRIVER_VERSION=alpha # Driver version to deploy
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are we creating a new "alpha" overlay? Right now I think dev basically serves this function(ish)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should update the overlay/docs atomically so we don't have a period of time when docs say to deploy alpha but that doesn't actually do anything

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, i want to create a separate alpha overlay that we can use for another CI test job. I will work on adding one

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I decided to just put the overlay back to dev for now. With topology going beta in 1.14, it's only snapshots that is still alpha.

$ ./deploy/kubernetes/deploy-driver.sh
```

### Snapshot Example

1. Create example Default Snapshot Class
```
$ kubectl create -f ./examples/kubernetes/demo-defaultsnapshotclass.yaml
```
2. Create a snapshot of the PVC created in above example
```
$ kubectl create -f ./examples/kubernetes/demo-snapshot.yaml
```
3. Verify Snapshot is created and is ready to use
```
$ k get volumesnapshots demo-snapshot-podpvc -o yaml
apiVersion: snapshot.storage.k8s.io/v1alpha1
kind: VolumeSnapshot
metadata:
creationTimestamp: 2018-10-05T16:59:26Z
generation: 1
name: demo-snapshot-podpvc
namespace: default

...

status:
creationTime: 2018-10-05T16:59:27Z
ready: true
restoreSize: 6Gi

```
4. Create a new volume from the snapshot
```
$ kubectl create -f ./examples/kubernetes/demo-restore-snapshot.yaml
30 changes: 30 additions & 0 deletions docs/local-development.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Local development
This page contains information on how to develop and test the driver locally.

## Testing

Running E2E Tests:
```
$ PROJECT=my-project # GCP Project to run tests in
$ IAM_NAME=my-iam@project.iam.gserviceaccount.com # Existing IAM Account with GCE PD CSI Driver Permissions
$ ./test/run-e2e-local.sh
```

Running Sanity Tests:
```
$ ./test/run-sanity.sh
```

Running Unit Tests:
```
$ ./test/run-unit.sh
```

## Dependency Management

Use [dep](https://github.com/golang/dep)
```
$ dep ensure
```

To modify dependencies or versions change `./Gopkg.toml`
15 changes: 15 additions & 0 deletions examples/kubernetes/demo-regional-restricted-sc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: csi-gce-pd
provisioner: pd.csi.storage.gke.io
parameters:
type: pd-standard
replication-type: regional-pd
volumeBindingMode: WaitForFirstConsumer
allowedTopologies:
- matchLabelExpressions:
- key: topology.gke.io/zone
values:
- us-central1-a
- us-central1-b
4 changes: 2 additions & 2 deletions examples/kubernetes/demo-regional-sc.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
apiVersion: storage.k8s.io/v1beta1
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: csi-gce-pd
provisioner: pd.csi.storage.gke.io
parameters:
type: pd-standard
replication-type: regional-pd
volumeBindingMode: Immediate
volumeBindingMode: WaitForFirstConsumer
Loading