Skip to content

Add dev-gke-noauth overlay that allows dev version of driver to be deployed #2059

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

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
10 changes: 4 additions & 6 deletions cmd/gce-pd-csi-driver/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,9 @@ var (

extraTagsStr = flag.String("extra-tags", "", "Extra tags to attach to each Compute Disk, Image, Snapshot created. It is a comma separated list of parent id, key and value like '<parent_id1>/<tag_key1>/<tag_value1>,...,<parent_idN>/<tag_keyN>/<tag_valueN>'. parent_id is the Organization or the Project ID or Project name where the tag key and the tag value resources exist. A maximum of 50 tags bindings is allowed for a resource. See https://cloud.google.com/resource-manager/docs/tags/tags-overview, https://cloud.google.com/resource-manager/docs/tags/tags-creating-and-managing for details")

version string
)
driverName = flag.String("driver-name", "pd.csi.storage.gke.io", "Driver name. Defaults to pd.csi.storage.gke.io")

const (
driverName = "pd.csi.storage.gke.io"
version string
)

func init() {
Expand Down Expand Up @@ -150,7 +148,7 @@ func handle() {

var metricsManager *metrics.MetricsManager = nil
if *runControllerService && *httpEndpoint != "" {
mm := metrics.NewMetricsManager()
mm := metrics.NewMetricsManager(*driverName)
mm.InitializeHttpHandler(*httpEndpoint, *metricsPath)
mm.RegisterPDCSIMetric()

Expand Down Expand Up @@ -272,7 +270,7 @@ func handle() {
}
}

err = gceDriver.SetupGCEDriver(driverName, version, extraVolumeLabels, extraTags, identityServer, controllerServer, nodeServer)
err = gceDriver.SetupGCEDriver(*driverName, version, extraVolumeLabels, extraTags, identityServer, controllerServer, nodeServer)
if err != nil {
klog.Fatalf("Failed to initialize GCE CSI Driver: %v", err.Error())
}
Expand Down
5 changes: 4 additions & 1 deletion deploy/kubernetes/base/controller/controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ spec:
# since it replaces GCE Metadata Server with GKE Metadata Server. Remove
# this requirement when issue is resolved and before any exposure of
# metrics ports
hostNetwork: true
hostNetwork: false
nodeSelector:
kubernetes.io/os: linux
serviceAccountName: csi-gce-pd-controller-sa
Expand Down Expand Up @@ -145,6 +145,9 @@ spec:
- "--supports-dynamic-iops-provisioning=hyperdisk-balanced,hyperdisk-extreme"
- "--supports-dynamic-throughput-provisioning=hyperdisk-balanced,hyperdisk-throughput,hyperdisk-ml"
- --enable-data-cache
- --run-node-service=false
- --multi-zone-volume-handle-disk-types=hyperdisk-ml
- --multi-zone-volume-handle-enable
command:
- /gce-pd-csi-driver
env:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
kind: Deployment
apiVersion: apps/v1
metadata:
name: csi-gce-pd-controller
spec:
template:
spec:
containers:
- name: gce-pd-driver
imagePullPolicy: Always
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- op: replace
path: /metadata/name
value: pd.dev.csi.storage.gke.io
3 changes: 3 additions & 0 deletions deploy/kubernetes/overlays/dev-gke-noauth/driver-args.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- op: add
path: /spec/template/spec/containers/0/args/-
value: --driver-name=pd.dev.csi.storage.gke.io
36 changes: 36 additions & 0 deletions deploy/kubernetes/overlays/dev-gke-noauth/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
patchesStrategicMerge:
- controller_always_pull.yaml
- node_always_pull.yaml
- noauth.yaml
- node_overwrite_pdcsi_path.yaml
namespace: gce-pd-csi-driver
resources:
- ../../base/
# Here dev overlay is using the same image as alpha
transformers:
- ../../images/stable-master
# Apply patches to support dynamic provisioning for hyperdisks
patches:
- path: ./driver-args.yaml
target:
group: apps
version: v1
kind: Deployment
name: csi-gce-pd-controller
- path: ./node-driver-args.yaml
target:
group: apps
version: v1
kind: DaemonSet
name: csi-gce-pd-node
- path: ./csidriver_dev_name.yaml
target:
kind: CSIDriver
name: pd.csi.storage.gke.io
# To change the dev image, add something like the following.
images:
- name: gke.gcr.io/gcp-compute-persistent-disk-csi-driver
newName: us-central1-docker.pkg.dev/psch-gke-dev/csi-dev/gcp-compute-persistent-disk-csi-driver
newTag: latest
25 changes: 25 additions & 0 deletions deploy/kubernetes/overlays/dev-gke-noauth/noauth.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
kind: Deployment
apiVersion: apps/v1
metadata:
name: csi-gce-pd-controller
spec:
template:
spec:
containers:
- name: gce-pd-driver
env:
- $patch: delete
name: GOOGLE_APPLICATION_CREDENTIALS
value: "/etc/cloud-sa/cloud-sa.json"
volumeMounts:
- $patch: delete
name: cloud-sa-volume
readOnly: true
mountPath: "/etc/cloud-sa"
volumes:
- $patch: delete
name: cloud-sa-volume
secret:
secretName: cloud-sa


Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- op: add
path: /spec/template/spec/containers/1/args/-
value: --driver-name=pd.dev.csi.storage.gke.io
11 changes: 11 additions & 0 deletions deploy/kubernetes/overlays/dev-gke-noauth/node_always_pull.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
kind: DaemonSet
apiVersion: apps/v1
metadata:
name: csi-gce-pd-node
spec:
template:
spec:
containers:
- name: gce-pd-driver
imagePullPolicy: Always

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
kind: DaemonSet
apiVersion: apps/v1
metadata:
name: csi-gce-pd-node
spec:
template:
spec:
containers:
- name: csi-driver-registrar
args:
- "--v=5"
- "--csi-address=/csi/csi.sock"
- "--kubelet-registration-path=/var/lib/kubelet/plugins/pd.dev.csi.storage.gke.io/csi.sock"
volumes:
- name: plugin-dir
hostPath:
path: /var/lib/kubelet/plugins/pd.dev.csi.storage.gke.io/
type: DirectoryOrCreate
11 changes: 6 additions & 5 deletions pkg/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ const (
// envGKEPDCSIVersion is an environment variable set in the PDCSI controller manifest
// with the current version of the GKE component.
envGKEPDCSIVersion = "GKE_PDCSI_VERSION"
pdcsiDriverName = "pd.csi.storage.gke.io"
DefaultDiskTypeForMetric = "unknownDiskType"
DefaultEnableConfidentialCompute = "unknownConfidentialMode"
DefaultEnableStoragePools = "unknownStoragePools"
Expand All @@ -56,12 +55,14 @@ var (
)

type MetricsManager struct {
registry metrics.KubeRegistry
registry metrics.KubeRegistry
driverName string
}

func NewMetricsManager() MetricsManager {
func NewMetricsManager(driverName string) MetricsManager {
mm := MetricsManager{
registry: metrics.NewKubeRegistry(),
driverName: driverName,
registry: metrics.NewKubeRegistry(),
}
return mm
}
Expand Down Expand Up @@ -97,7 +98,7 @@ func (mm *MetricsManager) RecordOperationErrorMetrics(
enableConfidentialStorage string,
enableStoragePools string) {
errCode := errorCodeLabelValue(operationErr)
pdcsiOperationErrorsMetric.WithLabelValues(pdcsiDriverName, fullMethodName, errCode, diskType, enableConfidentialStorage, enableStoragePools).Inc()
pdcsiOperationErrorsMetric.WithLabelValues(mm.driverName, fullMethodName, errCode, diskType, enableConfidentialStorage, enableStoragePools).Inc()
klog.Infof("Recorded PDCSI operation error code: %q", errCode)
}

Expand Down