-
Notifications
You must be signed in to change notification settings - Fork 808
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'kubernetes-sigs:master' into 1182-quote-extra-tags-arg
- Loading branch information
Showing
294 changed files
with
8,194 additions
and
14,320 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
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
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
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 |
---|---|---|
@@ -1,39 +1,36 @@ | ||
## Raw Block Volume | ||
This example shows how to consume a dynamically-provisioned EBS volume as a raw block device. | ||
|
||
### Edit [Persistence Volume Claim Spec](./specs/raw-claim.yaml) | ||
Make sure the `volumeMode` is `Block`. | ||
|
||
### Edit [Application Pod](./specs/pod.yaml) | ||
Make sure the pod is consuming the PVC with the defined name and `volumeDevices` is used instead of `volumeMounts`. | ||
|
||
### Deploy the Application | ||
```sh | ||
kubectl apply -f examples/kubernetes/block-volume/specs/storageclass.yaml | ||
kubectl apply -f examples/kubernetes/block-volume/specs/raw-claim.yaml | ||
kubectl apply -f examples/kubernetes/block-volume/specs/pod.yaml | ||
``` | ||
|
||
### Access Block Device | ||
After the objects are created, verify that pod is running: | ||
|
||
```sh | ||
$ kubectl get pods | ||
NAME READY STATUS RESTARTS AGE | ||
app 1/1 Running 0 16m | ||
``` | ||
Verify the device node is mounted inside the container: | ||
|
||
```sh | ||
$ kubectl exec -ti app -- ls -al /dev/xvda | ||
brw-rw---- 1 root disk 202, 23296 Mar 12 04:23 /dev/xvda | ||
``` | ||
|
||
Write to the device using: | ||
|
||
```sh | ||
dd if=/dev/zero of=/dev/xvda bs=1024k count=100 | ||
100+0 records in | ||
100+0 records out | ||
104857600 bytes (105 MB, 100 MiB) copied, 0.0492386 s, 2.1 GB/s | ||
``` | ||
# Raw Block Volume | ||
|
||
## Prerequisites | ||
|
||
1. Kubernetes 1.13+ (CSI 1.0). | ||
2. The [aws-ebs-csi-driver](https://github.com/kubernetes-sigs/aws-ebs-csi-driver) installed. | ||
|
||
## Usage | ||
|
||
This example shows you how to create and consume a dynamically-provisioned EBS volume as a raw block device. | ||
|
||
1. Deploy the provided pod on your cluster along with the `StorageClass` and `PersistentVolumeClaim`: | ||
```sh | ||
$ kubectl apply -f manifests | ||
|
||
pod/app created | ||
persistentvolumeclaim/block-claim created | ||
storageclass.storage.k8s.io/ebs-sc created | ||
``` | ||
|
||
2. Validate the `PersistentVolumeClaim` is bound to your `PersistentVolume`. | ||
```sh | ||
$ kubectl get pvc block-claim | ||
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE | ||
block-claim Bound pvc-2074bf0a-4726-44f2-bb7a-eb4292d4f40a 10Gi RWO ebs-sc | ||
``` | ||
|
||
3. Cleanup resources: | ||
```sh | ||
$ kubectl delete -f manifests | ||
pod "app" deleted | ||
persistentvolumeclaim "block-claim" deleted | ||
storageclass.storage.k8s.io "ebs-sc" deleted | ||
``` |
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 |
---|---|---|
|
@@ -9,4 +9,4 @@ spec: | |
storageClassName: ebs-sc | ||
resources: | ||
requests: | ||
storage: 10Gi | ||
storage: 4Gi |
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...amic-provisioning/specs/storageclass.yaml → .../block-volume/manifests/storageclass.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
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 |
---|---|---|
@@ -1,30 +1,44 @@ | ||
# Dynamic Volume Provisioning | ||
This example shows how to create a EBS volume and consume it from container dynamically. | ||
|
||
## Prerequisites | ||
|
||
1. Kubernetes 1.13+ (CSI 1.0). | ||
|
||
2. The [aws-ebs-csi-driver](https://github.com/kubernetes-sigs/aws-ebs-csi-driver) is installed. | ||
2. The [aws-ebs-csi-driver](https://github.com/kubernetes-sigs/aws-ebs-csi-driver) installed. | ||
|
||
## Usage | ||
|
||
1. Create a sample app along with the StorageClass and the PersistentVolumeClaim: | ||
``` | ||
kubectl apply -f specs/ | ||
``` | ||
This example shows you how to dynamically provision an EBS volume in your cluster. | ||
|
||
1. Deploy the provided pod on your cluster along with the `StorageClass` and `PersistentVolumeClaim`: | ||
```sh | ||
$ kubectl apply -f manifests | ||
|
||
persistentvolumeclaim/ebs-claim created | ||
pod/app created | ||
storageclass.storage.k8s.io/ebs-sc created | ||
``` | ||
|
||
2. Validate the volume was created and `volumeHandle` contains an EBS volumeID: | ||
``` | ||
kubectl describe pv | ||
``` | ||
2. Validate the `PersistentVolumeClaim` is bound to your `PersistentVolume`. | ||
```sh | ||
$ kubectl get pvc ebs-claim | ||
3. Validate the pod successfully wrote data to the volume: | ||
``` | ||
kubectl exec -it app cat /data/out.txt | ||
``` | ||
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE | ||
ebs-claim Bound pvc-9124c6d0-382a-49c5-9494-bcb60f6c0c9c 4Gi RWO ebs-sc 30m | ||
``` | ||
|
||
3. Validate the pod successfully wrote data to the dynamically provisioned volume: | ||
```sh | ||
$ kubectl exec app -- cat /data/out.txt | ||
Tue Feb 22 01:24:44 UTC 2022 | ||
... | ||
``` | ||
|
||
4. Cleanup resources: | ||
``` | ||
kubectl delete -f specs/ | ||
``` | ||
```sh | ||
$ kubectl delete -f manifests | ||
persistentvolumeclaim "ebs-claim" deleted | ||
pod "app" deleted | ||
storageclass.storage.k8s.io "ebs-sc" deleted | ||
``` |
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 |
---|---|---|
|
@@ -8,4 +8,4 @@ spec: | |
storageClassName: ebs-sc | ||
resources: | ||
requests: | ||
storage: 4Gi | ||
storage: 4Gi |
17 changes: 17 additions & 0 deletions
17
examples/kubernetes/dynamic-provisioning/manifests/pod.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,17 @@ | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: app | ||
spec: | ||
containers: | ||
- name: app | ||
image: centos | ||
command: ["/bin/sh"] | ||
args: ["-c", "while true; do echo $(date -u) >> /data/out.txt; sleep 5; done"] | ||
volumeMounts: | ||
- name: persistent-storage | ||
mountPath: /data | ||
volumes: | ||
- name: persistent-storage | ||
persistentVolumeClaim: | ||
claimName: ebs-claim |
2 changes: 1 addition & 1 deletion
2
.../snapshot/specs/classes/storageclass.yaml → ...-provisioning/manifests/storageclass.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
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 |
---|---|---|
@@ -1,43 +1,52 @@ | ||
## Volume Resizing | ||
This example shows how to resize EBS persistence volume using volume resizing features. | ||
# Volume Resizing | ||
|
||
**Note** | ||
1. CSI volume resizing is still alpha as of Kubernetes 1.15 | ||
2. EBS has a limit of one volume modification every 6 hours. Refer to [EBS documentation](https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_ModifyVolume.html) for more details. | ||
## Prerequisites | ||
|
||
1. Kubernetes 1.13+ (CSI 1.0). | ||
2. The [aws-ebs-csi-driver](https://github.com/kubernetes-sigs/aws-ebs-csi-driver) installed. | ||
|
||
## Usage | ||
1. Add `allowVolumeExpansion: true` in the StorageClass spec in [example manifest](./spec/example.yaml) to enable volume expansion. You can only expand a PVC if its storage class’s allowVolumeExpansion field is set to true | ||
|
||
2. Deploy the example: | ||
```sh | ||
kubectl apply -f specs/ | ||
``` | ||
|
||
3. Verify the volume is created and Pod is running: | ||
```sh | ||
kubectl get pv | ||
kubectl get po app | ||
``` | ||
|
||
4. Expand the volume size by increasing the capacity in PVC's `spec.resources.requests.storage`: | ||
```sh | ||
kubectl edit pvc ebs-claim | ||
``` | ||
Save the result at the end of the edit. | ||
|
||
5. Verify that both the persistence volume and persistence volume claim are resized: | ||
```sh | ||
kubectl get pv | ||
kubectl get pvc | ||
``` | ||
You should see that both should have the new value relfected in the capacity fields. | ||
|
||
6. Verify that the application is continuously running without any interruption: | ||
```sh | ||
kubectl exec -it app cat /data/out.txt | ||
``` | ||
|
||
7. Cleanup resources: | ||
``` | ||
kubectl delete -f specs/ | ||
``` | ||
|
||
In this example, an EBS volume of `4Gi` is resized to `8Gi` using the volume resizing feature. | ||
|
||
1. Deploy the provided pod on your cluster along with the `StorageClass` and `PersistentVolumeClaim`: | ||
```sh | ||
$ kubectl apply -f manifests | ||
|
||
persistentvolumeclaim/ebs-claim created | ||
pod/app created | ||
storageclass.storage.k8s.io/resize-sc created | ||
``` | ||
|
||
2. Validate the `PersistentVolumeClaim` is bound to your `PersistentVolume`. | ||
```sh | ||
$ kubectl get pvc ebs-claim | ||
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE | ||
ebs-claim Bound pvc-b0f6d590-f4b3-4329-a118-49cd09f6993c 4Gi RWO resize-sc 28s | ||
``` | ||
|
||
3. Expand the volume size by increasing the `capacity` specification in the `PersistentVolumeClaim`. | ||
```sh | ||
$ export KUBE_EDITOR="nano" && kubectl edit pvc ebs-claim | ||
``` | ||
|
||
4. Verify that both the persistence volume and persistence volume claim have been appropriately resized: | ||
```sh | ||
$ kubectl get pv && kubectl get pvc | ||
NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS | ||
pvc-b0f6d590-f4b3-4329-a118-49cd09f6993c 8Gi RWO Delete Bound default/ebs-claim resize-sc | ||
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE | ||
ebs-claim Bound pvc-b0f6d590-f4b3-4329-a118-49cd09f6993c 8Gi RWO resize-sc 23m | ||
``` | ||
|
||
5. Cleanup resources: | ||
```sh | ||
$ kubectl delete -f manifests | ||
persistentvolumeclaim "ebs-claim" deleted | ||
pod "app" deleted | ||
storageclass.storage.k8s.io "resize-sc" deleted | ||
``` |
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: ebs-claim | ||
spec: | ||
accessModes: | ||
- ReadWriteOnce | ||
storageClassName: resize-sc | ||
resources: | ||
requests: | ||
storage: 4Gi |
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,17 @@ | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: app | ||
spec: | ||
containers: | ||
- name: app | ||
image: centos | ||
command: ["/bin/sh"] | ||
args: ["tail -f /dev/null"] | ||
volumeMounts: | ||
- name: persistent-storage | ||
mountPath: /data | ||
volumes: | ||
- name: persistent-storage | ||
persistentVolumeClaim: | ||
claimName: ebs-claim |
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: storage.k8s.io/v1 | ||
kind: StorageClass | ||
metadata: | ||
name: resize-sc | ||
provisioner: ebs.csi.aws.com | ||
allowVolumeExpansion: true |
Oops, something went wrong.