Motivation:
This article shows how a volume (Google PD) can be attached, detached to a Kubernetes node. This can also be used as a reference to show how the same volume can be re-attached to a different Kubernetes node. VolumeAttachment API (csi attacher controller) is the one which makes this a reality with Kubernetes as the client side CSI implementation.
kubernetes > kubectl get nodes
NAME STATUS ROLES AGE VERSION
gke-amitd-ddp-default-pool-d5aa3f95-ht99 Ready <none> 92m v1.13.7-gke.24
gke-amitd-ddp-default-pool-d5aa3f95-t8p1 Ready <none> 92m v1.13.7-gke.24
gke-amitd-ddp-default-pool-d5aa3f95-wq0f Ready <none> 92m v1.13.7-gke.24
kubernetes >
Setup Details
CSI controller runs as a StatefulSet with single replica & uses following images:
- gcr.io/gke-release/csi-provisioner:v1.0.1-gke.0
- gcr.io/gke-release/csi-attacher:v1.0.1-gke.0
- gcr.io/gke-release/gcp-compute-persistent-disk-csi-driver:v0.4.0-gke.0
CSI node runs as a DaemonSet & uses following images:
- gcr.io/gke-release/csi-node-driver-registrar:v1.0.1-gke.0
- gcr.io/gke-release/gcp-compute-persistent-disk-csi-driver:v0.4.0-gke.0
Separate ServiceAccounts need to be created for following node as well as controller drivers
ClusterRole rules for provisioner need to be set for following resources:
- persistentvolumes
- persistentvolumeclaims
- storageclasses
- events
- nodes
- csinodes
ClusterRole rules for attacher need to be set for following resources:
- persistentvolumes
- nodes
- csinodes
- volumeattachments
PriorityClass needs to be set for both csi controller as well as csi node
Run Steps
deploy > pwd
/home/amit/work/src/sigs.k8s.io/gcp-compute-persistent-disk-csi-driver/deploy
deploy > ./setup-project.sh
PROJECT is strong-xxx-112112
GCE_PD_SA_NAME is amitd-404
GCE_PD_SA_DIR is /home/amit/safe/gcp
Service account amitd-404@strong-xxx-112112.iam.gserviceaccount.com exists. Would you like to create a new one (y) or reuse the existing one (n)
(y/n)y
deploy > ll /home/amit/mysafe/gcp/cloud-sa.json
-rw------- 1 amit amit 2324 Sep 11 14:14 /home/amit/mysafe/gcp/cloud-sa.json
ddp > kubectl get sts
NAME READY AGE
csi-gce-pd-controller 1/1 46s
ddp >
ddp > kubectl get daemonset
NAME DESIRED CURRENT READY UP-TO-DATE AVAILABLE NODE SELECTOR AGE
csi-gce-pd-node 3 3 3 3 3 <none> 51s
ddp >
ddp > kubectl get po
NAME READY STATUS RESTARTS AGE
csi-gce-pd-controller-0 3/3 Running 0 17s
csi-gce-pd-node-6f9rt 2/2 Running 0 17s
csi-gce-pd-node-cbb5v 2/2 Running 0 17s
csi-gce-pd-node-mwvwk 2/2 Running 0 17s
Motivation: This article shows how a volume (Google PD) can be attached, detached to a Kubernetes node. This can also be used as a reference to show how the same volume can be re-attached to a different Kubernetes node. VolumeAttachment API (csi attacher controller) is the one which makes this a reality with Kubernetes as the client side CSI implementation.
References
Kubernetes Cluster Details
Setup Details
Separate ServiceAccounts need to be created for following node as well as controller drivers
PriorityClass needs to be set for both csi controller as well as csi node
Run Steps
Apply following VolumeAttachment resource
kubernetes > kubectl get volumeattachment my-attach -oyaml