From 669fed2531ebdf3a1805014e5865050bb9fede14 Mon Sep 17 00:00:00 2001 From: Elijah Rodriguez-Beltran Date: Tue, 11 Aug 2026 22:46:47 +0000 Subject: [PATCH] Adopt pod-identity for authenticated CSI controller communication. CONV=08b81b20-9977-45df-b98e-9e340bc55e2d --- .../servicednssigner/servicednssigner.go | 4 + hack/install-ate.sh | 22 +- hack/install-demo-counter.sh | 9 +- hack/setup-csi-hostpath-kind.sh | 40 ++- .../deploy/csi-hostpath-testing.yaml | 96 ++++- internal/volume/csi/client.go | 20 +- internal/volume/csi/client_test.go | 2 +- internal/volume/csi/plugin.go | 75 +++- internal/volume/csi/plugin_test.go | 14 +- internal/volume/csi/tls_test.go | 334 ++++++++++++++++++ .../generated/ate.dev_csidriverconfigs.yaml | 20 ++ manifests/ate-install/kind/kustomization.yaml | 1 + pkg/api/v1alpha1/csidriverconfig_types.go | 21 ++ pkg/api/v1alpha1/zz_generated.deepcopy.go | 22 +- 14 files changed, 628 insertions(+), 52 deletions(-) create mode 100644 internal/volume/csi/tls_test.go diff --git a/cmd/podcertcontroller/internal/servicednssigner/servicednssigner.go b/cmd/podcertcontroller/internal/servicednssigner/servicednssigner.go index 1a995b20d..36f908e71 100644 --- a/cmd/podcertcontroller/internal/servicednssigner/servicednssigner.go +++ b/cmd/podcertcontroller/internal/servicednssigner/servicednssigner.go @@ -113,6 +113,10 @@ func (h *Impl) MakeCert(ctx context.Context, pcr *certsv1beta1.PodCertificateReq continue } + if len(svc.Spec.Selector) == 0 { + continue + } + // Find the set of pods that the service selects. matchedPods, err := h.kc.CoreV1().Pods(pcr.ObjectMeta.Namespace).List(ctx, metav1.ListOptions{ LabelSelector: metav1.FormatLabelSelector(&metav1.LabelSelector{MatchLabels: svc.Spec.Selector}), diff --git a/hack/install-ate.sh b/hack/install-ate.sh index 5ace949c2..f1b13f47b 100755 --- a/hack/install-ate.sh +++ b/hack/install-ate.sh @@ -471,14 +471,6 @@ deploy_ate_system() { # schemas and RBAC (role.yaml has no other apply path). deploy_crds - if [[ "${SETUP_CSI:-false}" == "true" ]]; then - if [[ "${ATE_INSTALL_KIND:-false}" == "true" ]]; then - setup_csi - else - echo "Warning: CSI setup is only supported for Kind local installations. Skipping." - fi - fi - # Enforce per-class SandboxConfig asset requirements (applied before any # SandboxConfig so the defaults below are validated too). run_kubectl apply -f manifests/ate-install/sandboxconfig-validation.yaml @@ -514,6 +506,18 @@ deploy_ate_system() { run_kubectl apply -f manifests/ate-install/postgres.yaml fi + # CSI setup must run after podcertificate-controller is ready and trust bundles + # exist. The ghostunnel sidecar uses projected podCertificate and clusterTrustBundle + # volumes which cannot be fulfilled until podcertcontroller is actively signing, + # otherwise rollout of csi-hostpath-socat times out. + if [[ "${SETUP_CSI:-false}" == "true" ]]; then + if [[ "${ATE_INSTALL_KIND:-false}" == "true" ]]; then + setup_csi + else + echo "Warning: CSI setup is only supported for Kind local installations. Skipping." + fi + fi + local manifests="" manifests="$(render_ate_system_manifests)" echo "${manifests}" | run_kubectl apply -f - @@ -787,7 +791,7 @@ done # flag they configure (e.g. --benchmark-worker-count before/after # --deploy-benchmarks). The dispatch loop below also accepts these flags but # treats them as no-ops since the value is already captured here. -SETUP_CSI=false +SETUP_CSI="${SETUP_CSI:-false}" BENCHMARK_WORKER_COUNT=1 BENCHMARK_SANDBOX_CLASS=gvisor prescan_args=("$@") diff --git a/hack/install-demo-counter.sh b/hack/install-demo-counter.sh index c2248271e..54e7191a9 100644 --- a/hack/install-demo-counter.sh +++ b/hack/install-demo-counter.sh @@ -43,9 +43,16 @@ demo-counter_deploy() { local ext_vol_mount_cmd=("-e" "/\${EXTERNAL_VOLUME_MOUNTS}/d") local ext_vol_spec_cmd=("-e" "/\${EXTERNAL_VOLUMES}/d") if [[ "${with_external_volume}" == "true" ]]; then + # csi-hostpath-sc only exists when hack/setup-csi-hostpath-kind.sh has run (via SETUP_CSI=true). + # Otherwise fall back to the default "standard" StorageClass. + local storage_class="standard" + if [[ "${SETUP_CSI:-false}" == "true" ]]; then + storage_class="csi-hostpath-sc" + fi + validate_cmd=("-e" "s|\${VALIDATE_EXISTING_FILE_PATH_ARG}| - --validate-existing-file-path=/external-data/test.txt|g") ext_vol_mount_cmd=("-e" "s|\${EXTERNAL_VOLUME_MOUNTS}| - name: external-data\n mountPath: /external-data|g") - ext_vol_spec_cmd=("-e" "s|\${EXTERNAL_VOLUMES}| - name: external-data\n externalVolumeTemplate:\n capacity: 1Gi\n storageClassName: standard|g") + ext_vol_spec_cmd=("-e" "s|\${EXTERNAL_VOLUMES}| - name: external-data\n externalVolumeTemplate:\n capacity: 1Gi\n storageClassName: ${storage_class}|g") fi sed -e "s|\${BUCKET_NAME}|${BUCKET_NAME}|g" \ diff --git a/hack/setup-csi-hostpath-kind.sh b/hack/setup-csi-hostpath-kind.sh index 74365b394..d2a8af06e 100755 --- a/hack/setup-csi-hostpath-kind.sh +++ b/hack/setup-csi-hostpath-kind.sh @@ -54,6 +54,25 @@ else echo "Warning: Kind node ${KIND_NODE} not running. Skipping directory cleanup." fi +# 2 Expose CSI Controller over TCP Service. +# This Service must be created before the driver pod deploys for the servicednssigner +# because servicednssigner to issue a certificate. +echo "Exposing CSI Controller over TCP Service..." +cat <