Skip to content

Commit

Permalink
Merge pull request #730 from saikat-royc/release-1.2
Browse files Browse the repository at this point in the history
Cherrypick #682,  #684, #693, #703, #718, #719, #720 to release-1.2 from master
  • Loading branch information
k8s-ci-robot authored Mar 24, 2021
2 parents 29b0a50 + c2b08a0 commit 4b1d767
Show file tree
Hide file tree
Showing 191 changed files with 32,438 additions and 1,071 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ See Github [Issues](https://github.com/kubernetes-sigs/gcp-compute-persistent-di
| 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 |
| disk-encryption-kms-key | Fully qualified resource identifier for the key to use to encrypt new disks. | Empty string. | Encrypt disk using Customer Managed Encryption Key (CMEK). See [GKE Docs](https://cloud.google.com/kubernetes-engine/docs/how-to/using-cmek#create_a_cmek_protected_attached_disk) for details. |
| labels | `key1=value1,key2=value2` | | Labels allow you to assign custom [GCE Disk labels](https://cloud.google.com/compute/docs/labeling-resources). |

### Topology

Expand Down
21 changes: 20 additions & 1 deletion cmd/gce-pd-csi-driver/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ import (

"k8s.io/klog"

"sigs.k8s.io/gcp-compute-persistent-disk-csi-driver/pkg/common"
gce "sigs.k8s.io/gcp-compute-persistent-disk-csi-driver/pkg/gce-cloud-provider/compute"
metadataservice "sigs.k8s.io/gcp-compute-persistent-disk-csi-driver/pkg/gce-cloud-provider/metadata"
driver "sigs.k8s.io/gcp-compute-persistent-disk-csi-driver/pkg/gce-pd-csi-driver"
"sigs.k8s.io/gcp-compute-persistent-disk-csi-driver/pkg/metrics"
mountmanager "sigs.k8s.io/gcp-compute-persistent-disk-csi-driver/pkg/mount-manager"
)

Expand All @@ -35,6 +37,9 @@ var (
endpoint = flag.String("endpoint", "unix:/tmp/csi.sock", "CSI endpoint")
runControllerService = flag.Bool("run-controller-service", true, "If set to false then the CSI driver does not activate its controller service (default: true)")
runNodeService = flag.Bool("run-node-service", true, "If set to false then the CSI driver does not activate its node service (default: true)")
httpEndpoint = flag.String("http-endpoint", "", "The TCP network address where the prometheus metrics endpoint will listen (example: `:8080`). The default is empty string, which means metrics endpoint is disabled.")
metricsPath = flag.String("metrics-path", "/metrics", "The HTTP path where prometheus metrics will be exposed. Default is `/metrics`.")
extraVolumeLabelsStr = flag.String("extra-labels", "", "Extra labels to attach to each PD created. It is a comma separated list of key value pairs like '<key1>=<value1>,<key2>=<value2>'. See https://cloud.google.com/compute/docs/labeling-resources for details")
version string
)

Expand Down Expand Up @@ -67,6 +72,20 @@ func handle() {
}
klog.V(2).Infof("Driver vendor version %v", version)

if *runControllerService && *httpEndpoint != "" && metrics.IsGKEComponentVersionAvailable() {
mm := metrics.NewMetricsManager()
mm.InitializeHttpHandler(*httpEndpoint, *metricsPath)
mm.EmitGKEComponentVersion()
}

if len(*extraVolumeLabelsStr) > 0 && !*runControllerService {
klog.Fatalf("Extra volume labels provided but not running controller")
}
extraVolumeLabels, err := common.ConvertLabelsStringToMap(*extraVolumeLabelsStr)
if err != nil {
klog.Fatalf("Bad extra volume labels: %v", err)
}

gceDriver := driver.GetGCEDriver()

//Initialize GCE Driver
Expand Down Expand Up @@ -104,7 +123,7 @@ func handle() {
nodeServer = driver.NewNodeServer(gceDriver, mounter, deviceUtils, meta, statter)
}

err = gceDriver.SetupGCEDriver(driverName, version, identityServer, controllerServer, nodeServer)
err = gceDriver.SetupGCEDriver(driverName, version, extraVolumeLabels, identityServer, controllerServer, nodeServer)
if err != nil {
klog.Fatalf("Failed to initialize GCE CSI Driver: %v", err)
}
Expand Down
2 changes: 1 addition & 1 deletion deploy/kubernetes/install-kustomize.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ curl -s https://api.github.com/repos/kubernetes-sigs/kustomize/releases |\
grep browser_download |\
grep $opsys |\
cut -d '"' -f 4 |\
grep /kustomize/v3.8.6 |\
grep /kustomize/v3.9.4 |\
sort | tail -n 1 |\
xargs curl -s -O -L

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# for gce-pd-driver
- op: add
path: /spec/template/spec/containers/4/args/2
value: "--extra-labels=csi=gce-pd-driver # Used for testing, not to be merged to stable"
10 changes: 10 additions & 0 deletions examples/kubernetes/demo-labeled-sc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Example StorageClass that adds labels to the GCP PD.
# This requires v1.2.1 or higher.
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: csi-gce-pd
provisioner: pd.csi.storage.gke.io
parameters:
labels: key1=value1,key2=value2
volumeBindingMode: WaitForFirstConsumer
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ require (
gopkg.in/warnings.v0 v0.1.2 // indirect
k8s.io/apimachinery v0.18.0
k8s.io/client-go v11.0.1-0.20190805182717-6502b5e7b1b5+incompatible
k8s.io/component-base v0.18.0
k8s.io/klog v1.0.0
k8s.io/kubernetes v1.18.0
k8s.io/test-infra v0.0.0-20200115230622-70a5174aa78d
Expand Down
Loading

0 comments on commit 4b1d767

Please sign in to comment.