From 8922b6a5ef0b912df65795e479cca864130af07c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20Fernando=20Carri=C3=B3n?= Date: Mon, 2 Nov 2026 10:42:37 +0100 Subject: [PATCH] [DND-2024] Support keyless GCS (Workload Identity) on S3Proxy 4.1.2 S3Proxy 4.1.2 uses application default credentials for a GCS backend with no key against Google's endpoint (gaul/s3proxy#1211), instead of sending requests unauthenticated. Document it, require 4.1.2 for a keyless config at render time, and note the storage.buckets.get permission a GET needs. --- charts/s3proxy/Chart.yaml | 4 +- charts/s3proxy/README.md.gotmpl | 51 +++++++++++++++++++-- charts/s3proxy/override-values.example.yaml | 6 +-- charts/s3proxy/templates/NOTES.txt | 2 +- charts/s3proxy/templates/configmap.yaml | 13 +++++- charts/s3proxy/values.yaml | 6 +-- 6 files changed, 68 insertions(+), 14 deletions(-) diff --git a/charts/s3proxy/Chart.yaml b/charts/s3proxy/Chart.yaml index 19f0951..3067b0c 100644 --- a/charts/s3proxy/Chart.yaml +++ b/charts/s3proxy/Chart.yaml @@ -15,13 +15,13 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 1.0.0 +version: 1.1.0 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to # follow Semantic Versioning. They should reflect the version the application is using. # It is recommended to use it with quotes. -appVersion: "4.1.1" +appVersion: "4.1.2" # comet-common is a library chart of shared helpers (names, labels, images, ...) # used across Comet charts. The resolved dependency (charts/*.tgz) is git-ignored, diff --git a/charts/s3proxy/README.md.gotmpl b/charts/s3proxy/README.md.gotmpl index 9136ea9..84e0d4d 100644 --- a/charts/s3proxy/README.md.gotmpl +++ b/charts/s3proxy/README.md.gotmpl @@ -28,7 +28,7 @@ S3Proxy `4.0.0` removed Apache jclouds and, with it, the Atmos and B2 backends a - **`filesystem` / `transient`** — the NIO2 implementations (no toggle). - **`s3`** — the `aws-s3` AWS SDK provider; serves AWS or any S3-compatible endpoint (set `endpoint`). Supports **keyless** auth: leave `accessKeyID`/`secretAccessKey` empty and set `s3.keyless: true` to use the AWS default credential chain (IRSA / EKS Pod Identity / EC2 instance profile). - **`azureblob`** — the Azure SDK; supports Managed/Workload Identity via `azureblob.managedIdentity: true` (no static key) — see "Example 3b". -- **`googleCloudStorage`** — the Google SDK; a static service-account JSON key is required (`serviceAccountKey.value` / `.existingSecret`). **Keyless GCS (Workload Identity/ADC) is not supported by S3Proxy 4.x** — an empty credential selects an unauthenticated (emulator-only) client, not ADC. +- **`googleCloudStorage`** — the Google SDK; authenticates with a service-account JSON key (`serviceAccountKey.value` / `.existingSecret`) or, with no key, application default credentials such as GKE Workload Identity; see "Example 4b". Keyless needs S3Proxy `4.1.2` or later, since earlier releases send requests without credentials; the chart fails at render time if keyless GCS meets an older `image.tag`. - **`openstackSwift`** — the openstack4j SDK (Keystone v3); set `projectName` and, if non-default, `projectDomainName` / `userDomainName`. Removed in chart `1.x`: the `b2` and `rackspaceCloudfiles` backends (jclouds-only, dropped upstream). Rackspace Cloud Files is OpenStack-Swift-compatible — configure it via the `openstackSwift` backend. @@ -214,8 +214,13 @@ persistence: ### Example 4: Google Cloud Storage Backend -The GCS SDK reads the credential as a full service-account JSON key. A static key -is required — S3Proxy 4.x does not support keyless GCS (Workload Identity/ADC). +The GCS SDK reads the credential as a full service-account JSON key. For no key, +see Example 4b. + +Either way, the identity needs `storage.buckets.get` on the bucket as well as +object access, because S3Proxy reads the bucket's metadata on a GET: grant +`roles/storage.legacyBucketReader` alongside `roles/storage.objectAdmin`. With +object access alone, listing works but GETs fail with `AccessDenied`. ```yaml # values-gcs.yaml @@ -244,6 +249,46 @@ persistence: enabled: false # Not needed for GCS backend ``` +### Example 4b: Google Cloud Storage with Workload Identity (no key) + +Leave `serviceAccountKey` empty and the GCS SDK uses application default +credentials, which on GKE with Workload Identity come from the metadata server. +This needs S3Proxy `4.1.2` or later. + +Grant the bucket roles to the Kubernetes service account as a Workload Identity +principal: + +```bash +PROJECT_NUMBER=$(gcloud projects describe my-project --format='value(projectNumber)') +for role in roles/storage.objectAdmin roles/storage.legacyBucketReader +do + gcloud storage buckets add-iam-policy-binding gs://my-bucket --role "$role" \ + --member "principal://iam.googleapis.com/projects/$PROJECT_NUMBER/locations/global/workloadIdentityPools/my-project.svc.id.goog/subject/ns/my-namespace/sa/s3proxy" +done +``` + +```yaml +# values-gcs-wi.yaml +config: + backends: + filesystem: + enabled: false + googleCloudStorage: + enabled: true + projectID: "my-project" # no key to take it from + +serviceAccount: + create: true + name: s3proxy # the name the IAM binding above refers to + # Or link a Google service account instead, after granting this Kubernetes + # service account roles/iam.workloadIdentityUser on it: + # annotations: + # iam.gke.io/gcp-service-account: "s3proxy@my-project.iam.gserviceaccount.com" + +persistence: + enabled: false +``` + ### Example 5: Anonymous Access (No Authentication) ```yaml diff --git a/charts/s3proxy/override-values.example.yaml b/charts/s3proxy/override-values.example.yaml index 5af709e..6744533 100644 --- a/charts/s3proxy/override-values.example.yaml +++ b/charts/s3proxy/override-values.example.yaml @@ -110,11 +110,11 @@ config: # leave key/sasToken empty (see README "Example 3b"). # managedIdentity: true - # Google Cloud Storage backend (Google SDK). A static service-account JSON key is - # required; S3Proxy 4.x does not support keyless GCS (Workload Identity/ADC). + # Google Cloud Storage backend (Google SDK). A service-account JSON key, or no key + # for Workload Identity (S3Proxy >= 4.1.2; see README "Example 4b"). googleCloudStorage: enabled: false # Set to true to use GCS backend - projectID: "my-project" # Optional; otherwise taken from the key + projectID: "my-project" # Optional with a key; set it for Workload Identity serviceAccountKey: # Option 1: the full service-account JSON key inline # value: | diff --git a/charts/s3proxy/templates/NOTES.txt b/charts/s3proxy/templates/NOTES.txt index 1a1ce3e..ea40255 100644 --- a/charts/s3proxy/templates/NOTES.txt +++ b/charts/s3proxy/templates/NOTES.txt @@ -94,7 +94,7 @@ {{- else if .Values.config.backends.azureblob.enabled }} - Make sure to configure Azure Blob backend credentials (or set azureblob.managedIdentity: true) {{- else if .Values.config.backends.googleCloudStorage.enabled }} - - Make sure to configure Google Cloud Storage backend credentials + - Make sure to configure Google Cloud Storage backend credentials (or leave serviceAccountKey empty for Workload Identity) {{- else if .Values.config.backends.openstackSwift.enabled }} - Make sure to configure OpenStack Swift backend credentials {{- end }} diff --git a/charts/s3proxy/templates/configmap.yaml b/charts/s3proxy/templates/configmap.yaml index 64fc92a..6c56c40 100644 --- a/charts/s3proxy/templates/configmap.yaml +++ b/charts/s3proxy/templates/configmap.yaml @@ -99,6 +99,15 @@ s3proxy.large-object-mocking=true {{- fail "config.backends.s3.keyless conflicts with a static credential; a non-empty accessKeyID/secretAccessKey.* disables the AWS default credential chain. Unset them." }} {{- end }} {{- end }} +{{- /* Keyless GCS: before 4.1.2 S3Proxy sends Google's endpoint unauthenticated + requests instead of using application default credentials, so a Workload + Identity setup would otherwise fail only at runtime, as AccessDenied. */}} +{{- $gcs := .Values.config.backends.googleCloudStorage }} +{{- if and $gcs.enabled (not $gcs.endpoint) (not $gcs.serviceAccountKey.value) (not $gcs.serviceAccountKey.existingSecret) (regexMatch "^v?[0-9]+\\.[0-9]+\\.[0-9]+" $s3pVersion) }} + {{- if semverCompare "< 4.1.2" (trimPrefix "v" $s3pVersion) }} + {{- fail (printf "config.backends.googleCloudStorage has no serviceAccountKey, so it relies on Workload Identity/ADC, which needs S3Proxy >= 4.1.2; the effective S3Proxy version is %s. Bump image.tag, or set serviceAccountKey." $s3pVersion) }} + {{- end }} +{{- end }} apiVersion: v1 kind: ConfigMap metadata: @@ -217,8 +226,8 @@ data: # jclouds.credential (the full service-account JSON key) is merged in by the # merge-configs initContainer from the mounted key file, so the multi-line JSON # is escaped to a single properties value and kept out of the ConfigMap. With no - # key the SDK uses an unauthenticated client (emulator only) — S3Proxy 4.x does - # NOT support keyless GCS (Workload Identity/ADC); real GCS needs a static key. + # key the SDK uses application default credentials (Workload Identity) against + # Google's endpoints, and none against an emulator. {{- range $index, $bucket := .Values.config.backends.googleCloudStorage.bucketLocators }} s3proxy.bucket-locator.{{ add $index 1 }}={{ $bucket }} {{- end }} diff --git a/charts/s3proxy/values.yaml b/charts/s3proxy/values.yaml index 278182b..13777bf 100644 --- a/charts/s3proxy/values.yaml +++ b/charts/s3proxy/values.yaml @@ -263,11 +263,11 @@ config: googleCloudStorage: # -- Enable Google Cloud Storage backend (provider `google-cloud-storage`, Google SDK) enabled: false - # -- GCP project ID, emitted as `jclouds.identity` (the GCS SDK store reads it as the project id). Optional: when empty the project is taken from the service-account key. + # -- GCP project ID, emitted as `jclouds.identity` (the GCS SDK store reads it as the project id). Optional with a service-account key, which carries the project; set it for Workload Identity, where there is no key to take it from. projectID: "" - # -- Custom GCS endpoint (`jclouds.endpoint`), e.g. a fake-gcs-server emulator. Empty uses `https://storage.googleapis.com`. An emulator needs no `serviceAccountKey`: with no key the SDK sends unauthenticated requests. + # -- Custom GCS endpoint (`jclouds.endpoint`). Empty uses `https://storage.googleapis.com`. Without a key, an endpoint that is not HTTPS under `googleapis.com` (e.g. a fake-gcs-server emulator) gets unauthenticated requests, while Google's regional and Private Service Connect endpoints under `googleapis.com` get application default credentials. endpoint: "" - # -- Service-account key configuration. The full JSON key is passed to the GCS SDK as `jclouds.credential` (`ServiceAccountCredentials.fromStream`). NOTE: S3Proxy 4.x does NOT support keyless GCS (Workload Identity/ADC) — an empty credential selects an unauthenticated (emulator-only) client, not ADC — so a static key is required against real GCS. + # -- Service-account key configuration. The full JSON key is passed to the GCS SDK as `jclouds.credential` (`ServiceAccountCredentials.fromStream`). Leave it empty for keyless auth: from S3Proxy 4.1.2 the SDK then uses application default credentials, such as GKE Workload Identity (see README "Example 4b"). serviceAccountKey: # -- (string) Inline service-account JSON key content, stored in the chart-owned Secret and mounted as a file the initContainer merges into the backend properties (kept out of the ConfigMap). Used only when `existingSecret` is empty. value: ""