From 04f76f0b6e4c1432aa5f99a07c0724c027968330 Mon Sep 17 00:00:00 2001 From: Marcello DeSales Date: Fri, 16 Oct 2026 22:30:26 -0700 Subject: [PATCH] chart: deliver atelet credential-provider plugins from images and mount Secrets for them Add atelet.imageCredentialProviderPlugins (each plugin installs itself from its image into an emptyDir by an init container, instead of a node bin directory) and atelet.imageCredentialProviderSecrets (Secrets mounted read-only under /run/image-credential-provider/secrets/ for the plugins, e.g. a dockerconfigjson a docker-config plugin answers from). Defaults are empty, so the rendered manifests are unchanged. With chart unit tests. Refs agent-substrate/substrate#2669. (cherry picked from commit 3ddccccbcfadacdd47735b37ee0f5be08c73a4ad) --- charts/substrate/README.md | 2 + charts/substrate/templates/atelet.yaml | 48 ++++++++++++- .../atelet_credential_provider_test.yaml | 69 +++++++++++++++++++ .../values/credential-provider-plugins.yaml | 32 +++++++++ charts/substrate/values.yaml | 16 +++++ 5 files changed, 165 insertions(+), 2 deletions(-) create mode 100644 charts/substrate/tests/atelet_credential_provider_test.yaml create mode 100644 charts/substrate/tests/values/credential-provider-plugins.yaml diff --git a/charts/substrate/README.md b/charts/substrate/README.md index 4f04e61153..e44ebf1680 100644 --- a/charts/substrate/README.md +++ b/charts/substrate/README.md @@ -65,6 +65,8 @@ See `values.yaml` for the full set; the important keys: | `atelet.imageCredentialProviderConfig` | `""` | Host path to the kubelet credential provider config; set together with the bin directory | | `atelet.imageCredentialProviderConfigYAML` | `""` | Credential provider config as text, rendered into a ConfigMap, for nodes where that file cannot be authored or must differ from the kubelet's; mutually exclusive with the host path | | `atelet.imageCredentialProviderBinDir` | `""` | Host path to the kubelet credential provider binaries; both paths are mounted read-only | +| `atelet.imageCredentialProviderPlugins` | `[]` | Credential provider plugins delivered from images instead of a node directory (set this or the bin directory): each `{name, image[, command, args]}` becomes an init container that installs its binary (default args `install /run/image-credential-provider/bin`) into an emptyDir atelet loads plugins from — no host path, so it works on any cluster | +| `atelet.imageCredentialProviderSecrets` | `[]` | Secrets mounted read-only at `/run/image-credential-provider/secrets/` for the plugins, each `{name[, secretName, optional, items]}` — e.g. a `kubernetes.io/dockerconfigjson` Secret a docker-config plugin answers from (point the provider's `env` `DOCKER_CONFIG` at that directory) | | `credentialProvider.namespacePolicies` | `[]` | Default-deny atespace-to-namespace grants; the chart includes get-only Secret RBAC for the provider | | `ateApi.actorJWTIssuer` | `https://..svc` | Issuer placed in actor JWTs; set a stable URL reachable by relying parties | | `objectStorePlugin.extraEnv` | `[]` | Object storage credentials/settings shared by both object-store plugins | diff --git a/charts/substrate/templates/atelet.yaml b/charts/substrate/templates/atelet.yaml index 278150d72f..008524a0e0 100644 --- a/charts/substrate/templates/atelet.yaml +++ b/charts/substrate/templates/atelet.yaml @@ -18,8 +18,15 @@ limitations under the License. {{- fail "set only one of atelet.imageCredentialProviderConfig and atelet.imageCredentialProviderConfigYAML" }} {{- end }} {{- $credentialProviderConfig := or .Values.atelet.imageCredentialProviderConfig .Values.atelet.imageCredentialProviderConfigYAML }} -{{- if ne (empty $credentialProviderConfig) (empty .Values.atelet.imageCredentialProviderBinDir) }} -{{- fail "atelet.imageCredentialProviderConfig (or atelet.imageCredentialProviderConfigYAML) and atelet.imageCredentialProviderBinDir must be set together" }} +{{- $credentialProviderPlugins := .Values.atelet.imageCredentialProviderPlugins }} +{{- if and $credentialProviderPlugins .Values.atelet.imageCredentialProviderBinDir }} +{{- fail "set only one of atelet.imageCredentialProviderPlugins (plugins from images, emptyDir) and atelet.imageCredentialProviderBinDir (a node directory)" }} +{{- end }} +{{- if ne (empty $credentialProviderConfig) (and (empty .Values.atelet.imageCredentialProviderBinDir) (empty $credentialProviderPlugins)) }} +{{- fail "atelet.imageCredentialProviderConfig (or atelet.imageCredentialProviderConfigYAML) needs atelet.imageCredentialProviderBinDir or atelet.imageCredentialProviderPlugins, and they need it" }} +{{- end }} +{{- if and .Values.atelet.imageCredentialProviderSecrets (not $credentialProviderConfig) }} +{{- fail "atelet.imageCredentialProviderSecrets needs a credential provider config (atelet.imageCredentialProviderConfigYAML)" }} {{- end }} # atelet @@ -139,6 +146,25 @@ spec: effect: NoSchedule {{- with include "substrate.imagePullSecrets" . }}{{- . | nindent 6 }}{{- end }} initContainers: +{{- range $credentialProviderPlugins }} + # Installs a credential-provider plugin binary from its image into the shared emptyDir. + - name: {{ printf "credential-provider-%s" .name | trunc 63 | trimSuffix "-" }} + image: {{ .image | quote }} + {{- with .command }} + command: {{ toJson . }} + {{- end }} + args: {{ toJson (default (list "install" "/run/image-credential-provider/bin") .args) }} + securityContext: + runAsNonRoot: true + runAsUser: 65532 + allowPrivilegeEscalation: false + readOnlyRootFilesystem: true + capabilities: + drop: ["ALL"] + volumeMounts: + - name: image-credential-provider-bin + mountPath: /run/image-credential-provider/bin +{{- end }} - name: objectstore-plugin image: {{ include "substrate.componentImage" (list "objectstore-plugin" .) }} restartPolicy: Always @@ -277,6 +303,11 @@ spec: subPath: config.yaml {{- end }} readOnly: true +{{- range .Values.atelet.imageCredentialProviderSecrets }} + - name: {{ printf "image-credential-%s" .name | trunc 63 | trimSuffix "-" }} + mountPath: {{ printf "/run/image-credential-provider/secrets/%s" .name }} + readOnly: true +{{- end }} {{- end }} volumes: - name: objectstore-plugin @@ -303,9 +334,22 @@ spec: type: Directory {{- if $credentialProviderConfig }} - name: image-credential-provider-bin +{{- if $credentialProviderPlugins }} + emptyDir: {} +{{- else }} hostPath: path: {{ .Values.atelet.imageCredentialProviderBinDir | quote }} type: Directory +{{- end }} +{{- range .Values.atelet.imageCredentialProviderSecrets }} + - name: {{ printf "image-credential-%s" .name | trunc 63 | trimSuffix "-" }} + secret: + secretName: {{ default .name .secretName | quote }} + optional: {{ default false .optional }} + {{- with .items }} + items: {{ toJson . }} + {{- end }} +{{- end }} - name: image-credential-provider-config {{- if .Values.atelet.imageCredentialProviderConfigYAML }} configMap: diff --git a/charts/substrate/tests/atelet_credential_provider_test.yaml b/charts/substrate/tests/atelet_credential_provider_test.yaml new file mode 100644 index 0000000000..fdbcba04a5 --- /dev/null +++ b/charts/substrate/tests/atelet_credential_provider_test.yaml @@ -0,0 +1,69 @@ +# Copyright 2026 The Agent Substrate Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +suite: atelet credential-provider plugins from images +templates: +- atelet.yaml +release: + name: substrate + namespace: ate-system +values: +- ./values/credential-provider-plugins.yaml +tests: +- it: installs each plugin from its image into an emptyDir and passes both flags + documentSelector: + path: kind + value: DaemonSet + asserts: + - equal: + path: spec.template.spec.initContainers[0].name + value: credential-provider-dockerconfig-credential-provider + - equal: + path: spec.template.spec.initContainers[0].args + value: ["install", "/run/image-credential-provider/bin"] + - contains: + path: spec.template.spec.containers[0].args + content: --image-credential-provider-bin-dir=/run/image-credential-provider/bin + - contains: + path: spec.template.spec.volumes + content: + name: image-credential-provider-bin + emptyDir: {} +- it: mounts the plugin Secrets read-only + documentSelector: + path: kind + value: DaemonSet + asserts: + - contains: + path: spec.template.spec.containers[0].volumeMounts + content: + name: image-credential-registry + mountPath: /run/image-credential-provider/secrets/registry + readOnly: true + - contains: + path: spec.template.spec.volumes + content: + name: image-credential-registry + secret: + secretName: atelet-registry-auth + optional: true + items: + - key: .dockerconfigjson + path: config.json +- it: refuses plugins together with a node bin directory + set: + atelet.imageCredentialProviderBinDir: /home/kubernetes/bin + asserts: + - failedTemplate: + errorPattern: set only one of atelet.imageCredentialProviderPlugins diff --git a/charts/substrate/tests/values/credential-provider-plugins.yaml b/charts/substrate/tests/values/credential-provider-plugins.yaml new file mode 100644 index 0000000000..c26f84a8f1 --- /dev/null +++ b/charts/substrate/tests/values/credential-provider-plugins.yaml @@ -0,0 +1,32 @@ +# Copyright 2026 The Agent Substrate Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +atelet: + imageCredentialProviderPlugins: + - name: dockerconfig-credential-provider + image: ghcr.io/planeodev/google-substrate/dockerconfig-credential-provider@sha256:0000000000000000000000000000000000000000000000000000000000000000 + imageCredentialProviderSecrets: + - name: registry + secretName: atelet-registry-auth + optional: true + items: [{key: .dockerconfigjson, path: config.json}] + imageCredentialProviderConfigYAML: | + apiVersion: kubelet.config.k8s.io/v1 + kind: CredentialProviderConfig + providers: + - name: dockerconfig-credential-provider + apiVersion: credentialprovider.kubelet.k8s.io/v1 + matchImages: ["ghcr.io"] + defaultCacheDuration: 5m + env: [{name: DOCKER_CONFIG, value: /run/image-credential-provider/secrets/registry}] diff --git a/charts/substrate/values.yaml b/charts/substrate/values.yaml index 9dcd7f6473..340aab4c81 100644 --- a/charts/substrate/values.yaml +++ b/charts/substrate/values.yaml @@ -83,6 +83,22 @@ atelet: # either one still needs the bin directory. imageCredentialProviderConfigYAML: "" imageCredentialProviderBinDir: "" + # Credential-provider plugins delivered from IMAGES instead of a node directory (set this OR + # imageCredentialProviderBinDir): each entry becomes an init container that installs its binary into an + # emptyDir atelet loads plugins from — no host path, any cluster. The image's entrypoint is run with + # args (default ["install", "/run/image-credential-provider/bin"]); the binary's name must match the + # provider `name` in the CredentialProviderConfig. + # - name: dockerconfig-credential-provider + # image: ghcr.io///dockerconfig-credential-provider@sha256: + imageCredentialProviderPlugins: [] + # Secrets mounted read-only at /run/image-credential-provider/secrets/ for the plugins (e.g. a + # kubernetes.io/dockerconfigjson Secret a docker-config plugin answers from; point the provider's `env` + # DOCKER_CONFIG at the directory and map `.dockerconfigjson` to `config.json` with items). + # - name: registry + # secretName: atelet-registry-auth + # optional: true + # items: [{key: .dockerconfigjson, path: config.json}] + imageCredentialProviderSecrets: [] storageBackend: s3 extraArgs: [] extraEnv: []