From f20100b67ad3298c235b2f63c55a609f45c5f03b Mon Sep 17 00:00:00 2001 From: Marcello DeSales Date: Fri, 16 Oct 2026 22:25:44 -0700 Subject: [PATCH 1/9] Pull actor images from private registries with a Kubernetes Secret Add cmd/dockerconfig-credential-provider, a kubelet-protocol image credential provider that answers atelet's credential-provider exec calls from a mounted .dockerconfigjson Secret, and the kustomize component manifests/ate-install/components/image-credential-secret that installs it without GKE host paths (plugin via an init container into an emptyDir, config from a ConfigMap, credentials from the Secret ate-system/atelet-registry-auth). Add the e2e suite internal/e2e/suites/imagepullsecret and the DeployProbe WithImage option it uses: a fresh-digest copy of the probe in a private registry must be refused anonymously and still reach its golden snapshot. Refs #2669, #868, #1919. (cherry picked from commit 90399b2b941841f9cba40926e16fb37a9c8d6d4c) --- .../workflows/planeo-private-pull-e2e.yaml | 100 +++++++++ cmd/dockerconfig-credential-provider/main.go | 191 ++++++++++++++++++ .../main_test.go | 119 +++++++++++ internal/e2e/fixture.go | 12 ++ internal/e2e/probe.go | 21 +- .../imagepullsecret/imagepullsecret_test.go | 184 +++++++++++++++++ .../suites/imagepullsecret/testmain_test.go | 24 +++ .../credential-provider-config.yaml | 39 ++++ .../kustomization.yaml | 106 ++++++++++ .../kustomization.yaml | 26 +++ 10 files changed, 820 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/planeo-private-pull-e2e.yaml create mode 100644 cmd/dockerconfig-credential-provider/main.go create mode 100644 cmd/dockerconfig-credential-provider/main_test.go create mode 100644 internal/e2e/suites/imagepullsecret/imagepullsecret_test.go create mode 100644 internal/e2e/suites/imagepullsecret/testmain_test.go create mode 100644 manifests/ate-install/components/image-credential-secret/credential-provider-config.yaml create mode 100644 manifests/ate-install/components/image-credential-secret/kustomization.yaml create mode 100644 manifests/ate-install/kind-image-credential-secret/kustomization.yaml diff --git a/.github/workflows/planeo-private-pull-e2e.yaml b/.github/workflows/planeo-private-pull-e2e.yaml new file mode 100644 index 0000000000..247c402099 --- /dev/null +++ b/.github/workflows/planeo-private-pull-e2e.yaml @@ -0,0 +1,100 @@ +# FORK-ONLY (planeodev/google-substrate) — NOT part of the upstream contribution. +# +# Proves Secret-based private image pulls for actors end to end on a real registry: kind + Agent Substrate (gVisor) +# installed exactly as upstream's e2e does, then atelet re-applied with +# manifests/ate-install/components/image-credential-secret (via manifests/ate-install/kind-image-credential-secret), +# then internal/e2e/suites/imagepullsecret pulls the probe from a PRIVATE GHCR package of this fork. +# +# Credentials: only this job's GITHUB_TOKEN (packages: write to push the private copy, read for the pull) — it is +# ephemeral, masked in logs, and lives only in the throwaway kind cluster's Secret. No stored secret. +# The package ghcr.io/planeodev/google-substrate/e2e-private-probe MUST be private: the suite fails if an +# anonymous read succeeds (set it private once in the org's package settings if GitHub created it public). +name: planeo-private-pull-e2e + +on: + push: + branches: ['planeo/**'] + workflow_dispatch: + +permissions: + contents: read + packages: write + +concurrency: + group: planeo-private-pull-e2e-${{ github.ref }} + cancel-in-progress: true + +jobs: + e2e-private-pull: + runs-on: ubuntu-latest + timeout-minutes: 90 + env: + E2E_ATENET_DATAPLANE: envoy + ARTIFACTS: ${{ github.workspace }}/_artifacts + E2E_PRIVATE_REPOSITORY: ghcr.io/${{ github.repository }}/e2e-private-probe + steps: + - name: Checkout + uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0 + - name: Setup Go + uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5.6.0 + with: + go-version-file: 'go.mod' + cache: false + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1 + with: + driver-opts: network=host + buildkitd-config-inline: | + [registry."localhost:5001"] + http = true + - name: Enable KVM + run: | + echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' \ + | sudo tee /etc/udev/rules.d/99-kvm4all.rules + sudo udevadm control --reload-rules + sudo udevadm trigger --name-match=kvm + - name: Create cluster + run: hack/create-kind-cluster.sh + - name: Install Agent Substrate + run: hack/install-ate-kind.sh --deploy-ate-system + - name: Registry Secret for atelet (before atelet restarts, so the volume is populated at start) + env: + REGISTRY_USER: ${{ github.actor }} + REGISTRY_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + kubectl -n ate-system create secret docker-registry atelet-registry-auth \ + --docker-server=ghcr.io --docker-username="${REGISTRY_USER}" --docker-password="${REGISTRY_TOKEN}" \ + --dry-run=client -o yaml | kubectl apply -f - >/dev/null + echo "Secret ate-system/atelet-registry-auth created (value not printed)" + - name: Re-apply atelet with the image-credential-secret component + env: + KO_DOCKER_REPO: localhost:5001 + run: | + kubectl kustomize --load-restrictor LoadRestrictionsNone manifests/ate-install/kind-image-credential-secret \ + > "${RUNNER_TEMP}/atelet.yaml" + KO_CONFIG_PATH="${PWD}" hack/run-tool.sh ko resolve -f "${RUNNER_TEMP}/atelet.yaml" | kubectl apply -f - + kubectl -n ate-system rollout status daemonset/atelet --timeout=10m + kubectl -n ate-system get pods -l app=atelet -o wide + - name: Focus the node on gVisor + run: hack/e2e-focus-sandbox-class.sh gvisor + - name: Run the private-pull e2e + env: + E2E_PRIVATE_REGISTRY_USERNAME: ${{ github.actor }} + E2E_PRIVATE_REGISTRY_PASSWORD: ${{ secrets.GITHUB_TOKEN }} + E2E_JUNIT_FILE: ${{ github.workspace }}/_artifacts/e2e-imagepullsecret.xml + run: hack/run-e2e-kind.sh ./internal/e2e/suites/imagepullsecret -v -args --no-color + - name: Diagnostics + if: always() + run: | + { + echo "### planeo-private-pull-e2e" + echo + echo '```' + kubectl -n ate-system get pods -o wide 2>&1 | head -40 + echo '```' + echo '#### atelet log (credential provider + pulls)' + echo '```' + kubectl -n ate-system logs daemonset/atelet -c atelet --tail=400 2>&1 \ + | grep -iE 'credential|provider|pull|auth|ghcr|e2e-private' | tail -60 + echo '```' + } >> "${GITHUB_STEP_SUMMARY}" diff --git a/cmd/dockerconfig-credential-provider/main.go b/cmd/dockerconfig-credential-provider/main.go new file mode 100644 index 0000000000..9a9ab4030f --- /dev/null +++ b/cmd/dockerconfig-credential-provider/main.go @@ -0,0 +1,191 @@ +// Copyright 2026 Google LLC +// +// 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. + +// dockerconfig-credential-provider — a kubelet-protocol image credential provider that answers from a Docker +// config file (the `.dockerconfigjson` of a Kubernetes Secret, mounted read-only), so Agent Substrate's node +// agent (atelet) can pull PRIVATE actor images with ordinary Kubernetes Secrets. +// +// atelet pulls actor images itself and authenticates through kubelet credential-provider exec plugins +// (--image-credential-provider-config / --image-credential-provider-bin-dir). Outside GKE there is usually no +// node plugin for the registry an install pulls from; this one serves static credentials from a Secret, so a +// cluster needs neither host files nor a cloud-specific plugin (see +// manifests/ate-install/components/image-credential-secret). +// +// Protocol (credentialprovider.kubelet.k8s.io/v1): a CredentialProviderRequest {image} as JSON on stdin; a +// CredentialProviderResponse on stdout. The docker config is $DOCKER_CONFIG/config.json (set DOCKER_CONFIG +// in the provider's `env` in the CredentialProviderConfig). No matching registry → an empty `auth` (the pull +// falls back to the next provider / anonymous); a malformed request or config → exit 1. +// +// `dockerconfig-credential-provider install ` copies this binary to /dockerconfig-credential-provider +// (the image is distroless — no cp) for the init container. Credentials are never logged. +package main + +import ( + "encoding/base64" + "encoding/json" + "errors" + "fmt" + "io" + "os" + "path/filepath" + "strings" +) + +const ( + apiVersion = "credentialprovider.kubelet.k8s.io/v1" + binaryName = "dockerconfig-credential-provider" + cacheDuration = "5m" // atelet ignores durations under one minute (#917) +) + +type request struct { + APIVersion string `json:"apiVersion"` + Kind string `json:"kind"` + Image string `json:"image"` +} + +type authConfig struct { + Username string `json:"username"` + Password string `json:"password"` +} + +type response struct { + APIVersion string `json:"apiVersion"` + Kind string `json:"kind"` + CacheKeyType string `json:"cacheKeyType"` + CacheDuration string `json:"cacheDuration"` + Auth map[string]authConfig `json:"auth"` +} + +// dockerConfig is the `.dockerconfigjson` / ~/.docker/config.json shape. +type dockerConfig struct { + Auths map[string]struct { + Username string `json:"username"` + Password string `json:"password"` + Auth string `json:"auth"` // base64("user:password"), used when username/password are absent + } `json:"auths"` +} + +func main() { + if len(os.Args) == 3 && os.Args[1] == "install" { + if err := install(os.Args[2]); err != nil { + fmt.Fprintln(os.Stderr, "install:", err) + os.Exit(1) + } + return + } + if err := run(os.Stdin, os.Stdout, os.Getenv("DOCKER_CONFIG")); err != nil { + fmt.Fprintln(os.Stderr, binaryName+":", err) + os.Exit(1) + } +} + +func run(in io.Reader, out io.Writer, configDir string) error { + var req request + if err := json.NewDecoder(in).Decode(&req); err != nil { + return fmt.Errorf("decode CredentialProviderRequest: %w", err) + } + if req.APIVersion != apiVersion || req.Kind != "CredentialProviderRequest" || req.Image == "" { + return fmt.Errorf("unsupported request (apiVersion %q, kind %q, image set: %t)", req.APIVersion, req.Kind, req.Image != "") + } + if configDir == "" { + return errors.New("DOCKER_CONFIG is not set (point it at the mounted Secret's directory)") + } + cfg, err := loadConfig(filepath.Join(configDir, "config.json")) + if err != nil { + return err + } + resp := response{APIVersion: apiVersion, Kind: "CredentialProviderResponse", CacheKeyType: "Registry", + CacheDuration: cacheDuration, Auth: map[string]authConfig{}} + host := registryHost(req.Image) + if a, ok := lookup(cfg, host); ok { + resp.Auth[host] = a + } + return json.NewEncoder(out).Encode(resp) +} + +func loadConfig(path string) (*dockerConfig, error) { + raw, err := os.ReadFile(path) + if err != nil { + return nil, fmt.Errorf("read docker config: %w", err) + } + var cfg dockerConfig + if err := json.Unmarshal(raw, &cfg); err != nil { + return nil, fmt.Errorf("parse docker config %s: %w", path, err) + } + return &cfg, nil +} + +// registryHost returns the registry part of an image reference, the way Docker resolves it: the first path +// component when it looks like a host (has a dot or a port, or is localhost), else Docker Hub. +func registryHost(image string) string { + first, _, found := strings.Cut(image, "/") + if found && (strings.ContainsAny(first, ".:") || first == "localhost") { + return first + } + return "docker.io" +} + +// lookup finds the entry for host; config keys may be bare hosts or URLs (https://ghcr.io, https://index.docker.io/v1/). +func lookup(cfg *dockerConfig, host string) (authConfig, bool) { + for key, e := range cfg.Auths { + k := strings.TrimPrefix(strings.TrimPrefix(key, "https://"), "http://") + k, _, _ = strings.Cut(k, "/") + if k == "index.docker.io" { + k = "docker.io" + } + if k != host { + continue + } + user, pass := e.Username, e.Password + if (user == "" || pass == "") && e.Auth != "" { + dec, err := base64.StdEncoding.DecodeString(e.Auth) + if err != nil { + continue + } + user, pass, _ = strings.Cut(string(dec), ":") + } + if user == "" || pass == "" { + continue + } + return authConfig{Username: user, Password: pass}, true + } + return authConfig{}, false +} + +// install copies this executable to dir/binaryName (0755) — the init container's only job. +func install(dir string) error { + self, err := os.Executable() + if err != nil { + return err + } + src, err := os.Open(self) + if err != nil { + return err + } + defer src.Close() + dst := filepath.Join(dir, binaryName) + f, err := os.OpenFile(dst, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0o755) + if err != nil { + return err + } + if _, err := io.Copy(f, src); err != nil { + f.Close() + return err + } + if err := f.Close(); err != nil { + return err + } + fmt.Println("installed", dst) + return nil +} diff --git a/cmd/dockerconfig-credential-provider/main_test.go b/cmd/dockerconfig-credential-provider/main_test.go new file mode 100644 index 0000000000..0a6e81debe --- /dev/null +++ b/cmd/dockerconfig-credential-provider/main_test.go @@ -0,0 +1,119 @@ +// Copyright 2026 Google LLC +// +// 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. + +package main + +import ( + "bytes" + "encoding/json" + "os" + "path/filepath" + "strings" + "testing" +) + +// Synthetic credentials only. "aHViOnB3" = base64("hub:pw"); "bm9wYXNz" = base64("nopass") (no password). +const cfgJSON = `{"auths":{ + "ghcr.io":{"username":"robot","password":"s3cret"}, + "https://index.docker.io/v1/":{"auth":"aHViOnB3"}, + "registry.example.com:5000":{"auth":"bm9wYXNz"} +}}` + +func writeConfig(t *testing.T) string { + t.Helper() + dir := t.TempDir() + if err := os.WriteFile(filepath.Join(dir, "config.json"), []byte(cfgJSON), 0o600); err != nil { + t.Fatal(err) + } + return dir +} + +func call(t *testing.T, dir, image string) response { + t.Helper() + req := `{"apiVersion":"credentialprovider.kubelet.k8s.io/v1","kind":"CredentialProviderRequest","image":"` + image + `"}` + var out bytes.Buffer + if err := run(strings.NewReader(req), &out, dir); err != nil { + t.Fatal(err) + } + var resp response + if err := json.Unmarshal(out.Bytes(), &resp); err != nil { + t.Fatal(err) + } + return resp +} + +func TestMatchesRegistry(t *testing.T) { + resp := call(t, writeConfig(t), "ghcr.io/planeodev/claude-agents/samples/adk-agents@sha256:"+strings.Repeat("a", 64)) + if resp.APIVersion != apiVersion || resp.Kind != "CredentialProviderResponse" || resp.CacheKeyType != "Registry" || resp.CacheDuration != "5m" { + t.Fatalf("bad envelope: %+v", resp) + } + if got := resp.Auth["ghcr.io"]; got.Username != "robot" || got.Password != "s3cret" { + t.Fatalf("ghcr.io auth = %+v", got) + } +} + +func TestDockerHubAndAuthField(t *testing.T) { + resp := call(t, writeConfig(t), "library/busybox:1.36") + if got := resp.Auth["docker.io"]; got.Username != "hub" || got.Password != "pw" { + t.Fatalf("docker.io auth (from the base64 auth field) = %+v", got) + } +} + +func TestUnknownRegistryIsEmptyNotError(t *testing.T) { + if resp := call(t, writeConfig(t), "quay.io/org/img:1"); len(resp.Auth) != 0 { + t.Fatalf("want no auth (anonymous fallback), got %+v", resp.Auth) + } +} + +func TestIncompleteEntrySkipped(t *testing.T) { + if resp := call(t, writeConfig(t), "registry.example.com:5000/a/b:1"); len(resp.Auth) != 0 { + t.Fatalf("want no auth for an entry without a password, got %+v", resp.Auth) + } +} + +func TestErrors(t *testing.T) { + var out bytes.Buffer + if err := run(strings.NewReader(`{"apiVersion":"v0","kind":"x","image":"a"}`), &out, writeConfig(t)); err == nil { + t.Fatal("want an error for a wrong apiVersion") + } + req := `{"apiVersion":"credentialprovider.kubelet.k8s.io/v1","kind":"CredentialProviderRequest","image":"ghcr.io/a/b"}` + if err := run(strings.NewReader(req), &out, ""); err == nil { + t.Fatal("want an error when DOCKER_CONFIG is unset") + } + if err := run(strings.NewReader(req), &out, t.TempDir()); err == nil { + t.Fatal("want an error when config.json is missing") + } +} + +func TestRegistryHost(t *testing.T) { + for in, want := range map[string]string{ + "ghcr.io/a/b@sha256:x": "ghcr.io", "localhost/a": "localhost", "localhost:5000/a": "localhost:5000", + "busybox": "docker.io", "library/busybox": "docker.io", "my.reg:443/x/y:1": "my.reg:443", + } { + if got := registryHost(in); got != want { + t.Errorf("registryHost(%q) = %q, want %q", in, got, want) + } + } +} + +func TestInstall(t *testing.T) { + dir := t.TempDir() + if err := install(dir); err != nil { + t.Fatal(err) + } + st, err := os.Stat(filepath.Join(dir, binaryName)) + if err != nil || st.Mode().Perm()&0o100 == 0 { + t.Fatalf("installed binary missing or not executable: %v %v", st, err) + } +} diff --git a/internal/e2e/fixture.go b/internal/e2e/fixture.go index 20b573146f..81ad8fc7e8 100644 --- a/internal/e2e/fixture.go +++ b/internal/e2e/fixture.go @@ -117,6 +117,13 @@ type SubstrateFixtureManifests struct { // namespace holding the pool) and the created templates. func DeploySubstrateFixture(t *testing.T, ctx context.Context, clients *Clients, manifests SubstrateFixtureManifests, bucket, name string, trustBundles []string) (string, []*ateapipb.ActorTemplate) { t.Helper() + return deploySubstrateFixture(t, ctx, clients, manifests, bucket, name, trustBundles, nil) +} + +// deploySubstrateFixture is DeploySubstrateFixture with an optional mutate hook applied to every rendered +// template before it is created (nil: none). +func deploySubstrateFixture(t *testing.T, ctx context.Context, clients *Clients, manifests SubstrateFixtureManifests, bucket, name string, trustBundles []string, mutate func(*ateapipb.ActorTemplate)) (string, []*ateapipb.ActorTemplate) { + t.Helper() // The pool manifest also carries the namespace. Its cleanup is registered // first so it runs last (t.Cleanup is LIFO), after the templates that @@ -135,6 +142,11 @@ func DeploySubstrateFixture(t *testing.T, ctx context.Context, clients *Clients, tmplInline, tmplBlocks := substrateTemplateSubstitutions(bucket, name, trustBundles) rendered := koResolve(t, renderManifest(t, manifests.Template, tmplInline, tmplBlocks)) templates := decodeSubstrateTemplates(t, rendered) + if mutate != nil { + for _, tmpl := range templates { + mutate(tmpl) + } + } atespace := templates[0].GetMetadata().GetAtespace() for _, tmpl := range templates { diff --git a/internal/e2e/probe.go b/internal/e2e/probe.go index fbd99e339a..f681a0561e 100644 --- a/internal/e2e/probe.go +++ b/internal/e2e/probe.go @@ -36,7 +36,10 @@ var probeManifests = SubstrateFixtureManifests{ // ProbeOption adjusts what DeployProbe installs. type ProbeOption func(*probeConfig) -type probeConfig struct{ trustBundles []string } +type probeConfig struct { + trustBundles []string + image string +} // The allowlisted names atelet resolves trust bundles by. const ( @@ -54,6 +57,12 @@ func WithTrustBundle() ProbeOption { return func(c *probeConfig) { c.trustBundles = append(c.trustBundles, egressTrustBundleName) } } +// WithImage runs the probe from image (a digest-pinned reference) instead of the one ko builds — e.g. a copy +// of the probe in a private registry, to prove a pull path. The template's containers all take it. +func WithImage(image string) ProbeOption { + return func(c *probeConfig) { c.image = image } +} + // WithSystemRoots adds the WebPKI roots atelet ships to the probe's projected // trust file, as the egress demo's template combines them with the egress // trust bundle. @@ -81,6 +90,14 @@ func DeployProbe(t *testing.T, bucket, name string, opts ...ProbeOption) (string EnsureEgressTrustBundle(t, context.Background(), GetClients()) } - atespace, templates := DeploySubstrateFixture(t, context.Background(), GetClients(), probeManifests, bucket, name, cfg.trustBundles) + var mutate func(*ateapipb.ActorTemplate) + if cfg.image != "" { + mutate = func(tmpl *ateapipb.ActorTemplate) { + for _, c := range tmpl.GetContainers() { + c.Image = cfg.image + } + } + } + atespace, templates := deploySubstrateFixture(t, context.Background(), GetClients(), probeManifests, bucket, name, cfg.trustBundles, mutate) return atespace, templates[0] } diff --git a/internal/e2e/suites/imagepullsecret/imagepullsecret_test.go b/internal/e2e/suites/imagepullsecret/imagepullsecret_test.go new file mode 100644 index 0000000000..c5ba47ddb2 --- /dev/null +++ b/internal/e2e/suites/imagepullsecret/imagepullsecret_test.go @@ -0,0 +1,184 @@ +// Copyright 2026 Google LLC +// +// 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. + +// Package imagepullsecret e2e-tests pulling an actor image from a PRIVATE registry with the credentials of a +// Kubernetes Secret: atelet installed with manifests/ate-install/components/image-credential-secret runs +// cmd/dockerconfig-credential-provider, which answers its credential-provider exec calls from the Secret +// ate-system/atelet-registry-auth (type kubernetes.io/dockerconfigjson). +package imagepullsecret + +import ( + "context" + "fmt" + "os" + "path/filepath" + "strings" + "testing" + "time" + + "github.com/google/go-containerregistry/pkg/authn" + "github.com/google/go-containerregistry/pkg/name" + v1 "github.com/google/go-containerregistry/pkg/v1" + "github.com/google/go-containerregistry/pkg/v1/mutate" + "github.com/google/go-containerregistry/pkg/v1/remote" + "go.ate.dev/substrate/internal/e2e" + apierrors "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +const ( + secretNamespace = "ate-system" + secretName = "atelet-registry-auth" + probeImportPath = "go.ate.dev/substrate/internal/e2e/fixtures/probe" +) + +// TestActorImageFromPrivateRegistry proves a private image reaches a sandbox ONLY through the Secret: +// +// - private: an anonymous HEAD of the copied image is refused by the registry, so a pass below cannot come +// from public access; +// - fresh digest: the copy carries a per-run annotation, so its manifest digest is new and no node's image +// cache can serve it (a cache hit skips the network, and with it authentication); +// - pulled with the Secret: a probe template whose image is the private copy reaches its golden snapshot, +// which atelet can only build after pulling the image with the credentials the plugin returned. +// +// It needs a registry the cluster reaches over TLS (atelet allows plain HTTP only for localhost registries) +// and credentials that can push and pull there; it skips when they are not configured: +// +// E2E_PRIVATE_REPOSITORY e.g. ghcr.io///e2e-private-probe (a PRIVATE repository) +// E2E_PRIVATE_REGISTRY_USERNAME a user that can push and pull it +// E2E_PRIVATE_REGISTRY_PASSWORD its token +// +// The install must include the component, and the Secret must exist before atelet starts (a Secret volume +// created later reaches the pod only on the kubelet's next sync): +// +// kubectl -n ate-system create secret docker-registry atelet-registry-auth \ +// --docker-server= --docker-username= --docker-password= +// ko resolve -f <(kubectl kustomize --load-restrictor LoadRestrictionsNone \ +// manifests/ate-install/kind-image-credential-secret) | kubectl apply -f - +// hack/run-e2e-kind.sh ./internal/e2e/suites/imagepullsecret -v -args --no-color +func TestActorImageFromPrivateRegistry(t *testing.T) { + repo := os.Getenv("E2E_PRIVATE_REPOSITORY") + user := os.Getenv("E2E_PRIVATE_REGISTRY_USERNAME") + pass := os.Getenv("E2E_PRIVATE_REGISTRY_PASSWORD") + if repo == "" || user == "" || pass == "" { + t.Skip("E2E_PRIVATE_REPOSITORY, E2E_PRIVATE_REGISTRY_USERNAME and E2E_PRIVATE_REGISTRY_PASSWORD are not set") + } + env, err := e2e.CheckEnv("BUCKET_NAME", "KO_DOCKER_REPO") + if err != nil { + t.Fatalf("CheckEnv failed: %v", err) + } + ctx := context.Background() + + if _, err := e2e.GetClients().K8s.CoreV1().Secrets(secretNamespace).Get(ctx, secretName, metav1.GetOptions{}); err != nil { + if apierrors.IsNotFound(err) { + t.Fatalf("Secret %s/%s is missing: create it before installing the image-credential-secret component (see the test doc)", secretNamespace, secretName) + } + t.Fatalf("get Secret %s/%s: %v", secretNamespace, secretName, err) + } + + source := buildProbe(t) + private := pushPrivateCopy(t, ctx, source, repo, &authn.Basic{Username: user, Password: pass}) + t.Logf("private copy: %s", private) + + // The registry must refuse an anonymous read, or the pull below proves nothing about the Secret. + ref, err := name.ParseReference(private) + if err != nil { + t.Fatalf("parse %s: %v", private, err) + } + if _, err := remote.Head(ref, remote.WithContext(ctx)); err == nil { + t.Fatalf("%s is readable anonymously: E2E_PRIVATE_REPOSITORY must name a private repository", private) + } else { + t.Logf("anonymous HEAD refused, as expected: %v", err) + } + + // DeployProbe waits for the template's golden snapshot: atelet pulled the image (with the plugin's + // credentials) and booted it. + atespace, tmpl := e2e.DeployProbe(t, env["BUCKET_NAME"], "imagepullsecret", e2e.WithImage(private)) + if got := tmpl.GetContainers()[0].GetImage(); got != private { + t.Fatalf("template image = %q, want the private copy %q", got, private) + } + t.Logf("golden snapshot built from the private image in atespace %s", atespace) +} + +// buildProbe builds the probe fixture with ko and returns its digest-pinned reference in KO_DOCKER_REPO. +func buildProbe(t *testing.T) string { + t.Helper() + root, err := e2e.FindRepoRoot() + if err != nil { + t.Fatalf("FindRepoRoot: %v", err) + } + out := e2e.RunCmdOutput(t, []string{"KO_CONFIG_PATH=" + root}, filepath.Join(root, "hack/run-tool.sh"), "ko", "build", probeImportPath) + fields := strings.Fields(strings.TrimSpace(string(out))) + if len(fields) == 0 { + t.Fatalf("ko build %s printed no image reference", probeImportPath) + } + return fields[len(fields)-1] +} + +// pushPrivateCopy copies source (an image or an index) to repo with a per-run annotation — a new manifest +// digest — and returns the digest-pinned reference of the copy. Credentials are used only for the push. +func pushPrivateCopy(t *testing.T, ctx context.Context, source, repo string, auth authn.Authenticator) string { + t.Helper() + ctx, cancel := context.WithTimeout(ctx, 5*time.Minute) + defer cancel() + + src, err := name.ParseReference(source, name.Insecure) // KO_DOCKER_REPO is the plain-HTTP kind registry + if err != nil { + t.Fatalf("parse %s: %v", source, err) + } + run := fmt.Sprintf("run-%d", time.Now().UnixNano()) + dst, err := name.NewTag(repo + ":" + run) + if err != nil { + t.Fatalf("tag %s:%s: %v", repo, run, err) + } + stamp := map[string]string{"dev.ate.e2e.imagepullsecret/run": run} + desc, err := remote.Get(src, remote.WithContext(ctx)) + if err != nil { + t.Fatalf("read %s: %v", source, err) + } + + var digest v1.Hash + if desc.MediaType.IsIndex() { + idx, err := desc.ImageIndex() + if err != nil { + t.Fatalf("index %s: %v", source, err) + } + annotated, ok := mutate.Annotations(idx, stamp).(v1.ImageIndex) + if !ok { + t.Fatalf("annotate index %s: unexpected type", source) + } + if err := remote.WriteIndex(dst, annotated, remote.WithAuth(auth), remote.WithContext(ctx)); err != nil { + t.Fatalf("push %s: %v", dst, err) + } + if digest, err = annotated.Digest(); err != nil { + t.Fatalf("digest of %s: %v", dst, err) + } + } else { + img, err := desc.Image() + if err != nil { + t.Fatalf("image %s: %v", source, err) + } + annotated, ok := mutate.Annotations(img, stamp).(v1.Image) + if !ok { + t.Fatalf("annotate image %s: unexpected type", source) + } + if err := remote.Write(dst, annotated, remote.WithAuth(auth), remote.WithContext(ctx)); err != nil { + t.Fatalf("push %s: %v", dst, err) + } + if digest, err = annotated.Digest(); err != nil { + t.Fatalf("digest of %s: %v", dst, err) + } + } + return repo + "@" + digest.String() +} diff --git a/internal/e2e/suites/imagepullsecret/testmain_test.go b/internal/e2e/suites/imagepullsecret/testmain_test.go new file mode 100644 index 0000000000..1df206a4e4 --- /dev/null +++ b/internal/e2e/suites/imagepullsecret/testmain_test.go @@ -0,0 +1,24 @@ +// Copyright 2026 Google LLC +// +// 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. + +package imagepullsecret + +import ( + "os" + "testing" + + "go.ate.dev/substrate/internal/e2e" +) + +func TestMain(m *testing.M) { os.Exit(e2e.RunTestMain(m)) } diff --git a/manifests/ate-install/components/image-credential-secret/credential-provider-config.yaml b/manifests/ate-install/components/image-credential-secret/credential-provider-config.yaml new file mode 100644 index 0000000000..454ad5921d --- /dev/null +++ b/manifests/ate-install/components/image-credential-secret/credential-provider-config.yaml @@ -0,0 +1,39 @@ +# Copyright 2026 Google LLC +# +# 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. + +# The CredentialProviderConfig atelet loads (kubelet.config.k8s.io/v1). One provider: the docker-config plugin +# reading the Secret mounted at /run/image-credential-provider/registry. It returns credentials only for the +# registries the Secret has an entry for (an empty answer otherwise, so the pull falls through to the next +# provider or goes anonymous). Narrow matchImages to those registries to avoid exec-ing it for every pull. +apiVersion: v1 +kind: ConfigMap +metadata: + name: atelet-image-credential-provider + namespace: ate-system +data: + config.yaml: | + apiVersion: kubelet.config.k8s.io/v1 + kind: CredentialProviderConfig + providers: + - name: dockerconfig-credential-provider + apiVersion: credentialprovider.kubelet.k8s.io/v1 + matchImages: + - "*" + - "*.*" + - "*.*.*" + - "*.*.*.*" + defaultCacheDuration: 5m + env: + - name: DOCKER_CONFIG + value: /run/image-credential-provider/registry diff --git a/manifests/ate-install/components/image-credential-secret/kustomization.yaml b/manifests/ate-install/components/image-credential-secret/kustomization.yaml new file mode 100644 index 0000000000..2dad984e2b --- /dev/null +++ b/manifests/ate-install/components/image-credential-secret/kustomization.yaml @@ -0,0 +1,106 @@ +# Copyright 2026 Google LLC +# +# 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. + +# Lets atelet pull actor (and image-volume) images from PRIVATE registries with an ordinary Kubernetes +# Secret, on any cluster — no node files, no cloud-specific plugin. +# +# atelet authenticates image pulls only through kubelet credential-provider exec plugins (#917/#2104). The +# base manifest wires them to GKE's node paths (/home/kubernetes/bin, /etc/srv/kubernetes/cri_auth_config.yaml), +# which other clusters do not have (#2669). This component replaces both host paths: +# - the plugin directory becomes an emptyDir, filled by an init container with +# cmd/dockerconfig-credential-provider (it copies itself: `install `); +# - the CredentialProviderConfig comes from the ConfigMap below (credential-provider-config.yaml); +# - the credentials come from the Secret atelet-registry-auth (type kubernetes.io/dockerconfigjson, the +# same shape as an imagePullSecret), mounted read-only; the plugin reads it on every call, so a rotated +# Secret applies without restarting atelet. The Secret is optional: atelet starts (pulling anonymously) +# before it exists. +# +# kubectl -n ate-system create secret docker-registry atelet-registry-auth \ +# --docker-server= --docker-username= --docker-password= +# +# The two --image-credential-provider-* flags are appended because overlays such as ../../kind drop them; +# where the base already sets them the values are identical (the last one wins). +# +# Scope: the credentials are node-level — every actor on a node can pull what the Secret can read (the same +# boundary as a node's own credential provider; per-tenant pull secrets are #868 / #2080). Narrow +# matchImages in credential-provider-config.yaml to the registries the Secret serves. + +apiVersion: kustomize.config.k8s.io/v1alpha1 +kind: Component + +resources: + - credential-provider-config.yaml + +patches: + - target: + kind: DaemonSet + name: atelet + patch: |- + - op: add + path: /spec/template/spec/containers/0/args/- + value: --image-credential-provider-config=/run/image-credential-provider/config.yaml + - op: add + path: /spec/template/spec/containers/0/args/- + value: --image-credential-provider-bin-dir=/run/image-credential-provider/bin + - patch: |- + apiVersion: apps/v1 + kind: DaemonSet + metadata: + name: atelet + namespace: ate-system + spec: + template: + spec: + initContainers: + - name: install-credential-providers + image: ko://go.ate.dev/substrate/cmd/dockerconfig-credential-provider + args: ["install", "/run/image-credential-provider/bin"] + securityContext: + runAsNonRoot: true + runAsUser: 65532 + allowPrivilegeEscalation: false + readOnlyRootFilesystem: true + capabilities: + drop: ["ALL"] + volumeMounts: + - name: image-credential-provider-bin + mountPath: /run/image-credential-provider/bin + containers: + - name: atelet + volumeMounts: + - name: image-credential-provider-bin + mountPath: /run/image-credential-provider/bin + readOnly: true + - name: image-credential-provider-config + mountPath: /run/image-credential-provider/config.yaml + subPath: config.yaml + readOnly: true + - name: image-credential-provider-registry + mountPath: /run/image-credential-provider/registry + readOnly: true + volumes: + - name: image-credential-provider-bin + hostPath: null + emptyDir: {} + - name: image-credential-provider-config + hostPath: null + configMap: + name: atelet-image-credential-provider + - name: image-credential-provider-registry + secret: + secretName: atelet-registry-auth + optional: true + items: + - key: .dockerconfigjson + path: config.json diff --git a/manifests/ate-install/kind-image-credential-secret/kustomization.yaml b/manifests/ate-install/kind-image-credential-secret/kustomization.yaml new file mode 100644 index 0000000000..c0f18cb68d --- /dev/null +++ b/manifests/ate-install/kind-image-credential-secret/kustomization.yaml @@ -0,0 +1,26 @@ +# Copyright 2026 Google LLC +# +# 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. + +# kind's atelet with the image-credential-secret component: the atelet overlay ../kind/atelet (which drops the +# GKE credential-provider flags and host mounts) plus private-registry pulls from the Secret +# ate-system/atelet-registry-auth. Applied after the kind install (ko resolve -f <(kubectl kustomize …)) by the +# private-registry e2e (internal/e2e/suites/imagepullsecret). +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +resources: + - ../kind/atelet + +components: + - ../components/image-credential-secret From f62b1ea4255a309bc7fd952a456089a44f023fd1 Mon Sep 17 00:00:00 2001 From: Marcello DeSales Date: Fri, 16 Oct 2026 22:26:34 -0700 Subject: [PATCH 2/9] Use The Agent Substrate Authors header on the new files; add it to the fork-only workflow (cherry picked from commit 8bfa324df2c9025dd17fe6434885911dce378af4) --- .github/workflows/planeo-private-pull-e2e.yaml | 14 ++++++++++++++ cmd/dockerconfig-credential-provider/main.go | 2 +- cmd/dockerconfig-credential-provider/main_test.go | 2 +- .../suites/imagepullsecret/imagepullsecret_test.go | 2 +- .../e2e/suites/imagepullsecret/testmain_test.go | 2 +- .../credential-provider-config.yaml | 2 +- .../image-credential-secret/kustomization.yaml | 2 +- .../kustomization.yaml | 2 +- 8 files changed, 21 insertions(+), 7 deletions(-) diff --git a/.github/workflows/planeo-private-pull-e2e.yaml b/.github/workflows/planeo-private-pull-e2e.yaml index 247c402099..b8a5a30e71 100644 --- a/.github/workflows/planeo-private-pull-e2e.yaml +++ b/.github/workflows/planeo-private-pull-e2e.yaml @@ -1,3 +1,17 @@ +# 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. + # FORK-ONLY (planeodev/google-substrate) — NOT part of the upstream contribution. # # Proves Secret-based private image pulls for actors end to end on a real registry: kind + Agent Substrate (gVisor) diff --git a/cmd/dockerconfig-credential-provider/main.go b/cmd/dockerconfig-credential-provider/main.go index 9a9ab4030f..2ff636cc6f 100644 --- a/cmd/dockerconfig-credential-provider/main.go +++ b/cmd/dockerconfig-credential-provider/main.go @@ -1,4 +1,4 @@ -// Copyright 2026 Google LLC +// 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. diff --git a/cmd/dockerconfig-credential-provider/main_test.go b/cmd/dockerconfig-credential-provider/main_test.go index 0a6e81debe..a485f5f9ea 100644 --- a/cmd/dockerconfig-credential-provider/main_test.go +++ b/cmd/dockerconfig-credential-provider/main_test.go @@ -1,4 +1,4 @@ -// Copyright 2026 Google LLC +// 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. diff --git a/internal/e2e/suites/imagepullsecret/imagepullsecret_test.go b/internal/e2e/suites/imagepullsecret/imagepullsecret_test.go index c5ba47ddb2..2f3ee96679 100644 --- a/internal/e2e/suites/imagepullsecret/imagepullsecret_test.go +++ b/internal/e2e/suites/imagepullsecret/imagepullsecret_test.go @@ -1,4 +1,4 @@ -// Copyright 2026 Google LLC +// 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. diff --git a/internal/e2e/suites/imagepullsecret/testmain_test.go b/internal/e2e/suites/imagepullsecret/testmain_test.go index 1df206a4e4..958380ccb5 100644 --- a/internal/e2e/suites/imagepullsecret/testmain_test.go +++ b/internal/e2e/suites/imagepullsecret/testmain_test.go @@ -1,4 +1,4 @@ -// Copyright 2026 Google LLC +// 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. diff --git a/manifests/ate-install/components/image-credential-secret/credential-provider-config.yaml b/manifests/ate-install/components/image-credential-secret/credential-provider-config.yaml index 454ad5921d..266fa70ff8 100644 --- a/manifests/ate-install/components/image-credential-secret/credential-provider-config.yaml +++ b/manifests/ate-install/components/image-credential-secret/credential-provider-config.yaml @@ -1,4 +1,4 @@ -# Copyright 2026 Google LLC +# 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. diff --git a/manifests/ate-install/components/image-credential-secret/kustomization.yaml b/manifests/ate-install/components/image-credential-secret/kustomization.yaml index 2dad984e2b..0fd9384b4b 100644 --- a/manifests/ate-install/components/image-credential-secret/kustomization.yaml +++ b/manifests/ate-install/components/image-credential-secret/kustomization.yaml @@ -1,4 +1,4 @@ -# Copyright 2026 Google LLC +# 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. diff --git a/manifests/ate-install/kind-image-credential-secret/kustomization.yaml b/manifests/ate-install/kind-image-credential-secret/kustomization.yaml index c0f18cb68d..d7256608a0 100644 --- a/manifests/ate-install/kind-image-credential-secret/kustomization.yaml +++ b/manifests/ate-install/kind-image-credential-secret/kustomization.yaml @@ -1,4 +1,4 @@ -# Copyright 2026 Google LLC +# 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. From 78b8ce9382db833b7bc3d45b383e72afd5c026b0 Mon Sep 17 00:00:00 2001 From: Marcello DeSales Date: Fri, 16 Oct 2026 22:30:54 -0700 Subject: [PATCH 3/9] planeo-private-pull-e2e: set ATE_CREDENTIAL_PROVIDER like upstream's e2e job (cherry picked from commit 7b1c3fdbbfdadece17c0792f096a432a2f460f8a) --- .github/workflows/planeo-private-pull-e2e.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/planeo-private-pull-e2e.yaml b/.github/workflows/planeo-private-pull-e2e.yaml index b8a5a30e71..5343eaa86b 100644 --- a/.github/workflows/planeo-private-pull-e2e.yaml +++ b/.github/workflows/planeo-private-pull-e2e.yaml @@ -44,6 +44,8 @@ jobs: timeout-minutes: 90 env: E2E_ATENET_DATAPLANE: envoy + # Same as upstream's e2e job: the installer requires an egress credential provider (the bundled k8s.io one). + ATE_CREDENTIAL_PROVIDER: '{"name":"k8s.io"}' ARTIFACTS: ${{ github.workspace }}/_artifacts E2E_PRIVATE_REPOSITORY: ghcr.io/${{ github.repository }}/e2e-private-probe steps: From 2573820b087ba5589771915b5e68bc65f66b1e8e Mon Sep 17 00:00:00 2001 From: Marcello DeSales Date: Fri, 16 Oct 2026 22:43:00 -0700 Subject: [PATCH 4/9] planeo-private-pull-e2e: drop the sandbox-class focus step (it expects upstream's micro-VM demo, which this scoped job does not install) (cherry picked from commit 7e2af7a47cc29aa393c412c3b9262fa3a5cbcf9c) --- .github/workflows/planeo-private-pull-e2e.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/planeo-private-pull-e2e.yaml b/.github/workflows/planeo-private-pull-e2e.yaml index 5343eaa86b..2406b0845d 100644 --- a/.github/workflows/planeo-private-pull-e2e.yaml +++ b/.github/workflows/planeo-private-pull-e2e.yaml @@ -91,8 +91,6 @@ jobs: KO_CONFIG_PATH="${PWD}" hack/run-tool.sh ko resolve -f "${RUNNER_TEMP}/atelet.yaml" | kubectl apply -f - kubectl -n ate-system rollout status daemonset/atelet --timeout=10m kubectl -n ate-system get pods -l app=atelet -o wide - - name: Focus the node on gVisor - run: hack/e2e-focus-sandbox-class.sh gvisor - name: Run the private-pull e2e env: E2E_PRIVATE_REGISTRY_USERNAME: ${{ github.actor }} From 52d2eed447c91d6db8cfae95f9f52464f809669a Mon Sep 17 00:00:00 2001 From: Marcello DeSales Date: Fri, 16 Oct 2026 22:55:42 -0700 Subject: [PATCH 5/9] Pass --preview to the private-pull e2e as CI requires (cherry picked from commit 768450e1c863de9fed99880d119e767ffebcb272) --- .github/workflows/planeo-private-pull-e2e.yaml | 2 +- internal/e2e/suites/imagepullsecret/imagepullsecret_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/planeo-private-pull-e2e.yaml b/.github/workflows/planeo-private-pull-e2e.yaml index 2406b0845d..8cb6435cbc 100644 --- a/.github/workflows/planeo-private-pull-e2e.yaml +++ b/.github/workflows/planeo-private-pull-e2e.yaml @@ -96,7 +96,7 @@ jobs: E2E_PRIVATE_REGISTRY_USERNAME: ${{ github.actor }} E2E_PRIVATE_REGISTRY_PASSWORD: ${{ secrets.GITHUB_TOKEN }} E2E_JUNIT_FILE: ${{ github.workspace }}/_artifacts/e2e-imagepullsecret.xml - run: hack/run-e2e-kind.sh ./internal/e2e/suites/imagepullsecret -v -args --no-color + run: hack/run-e2e-kind.sh ./internal/e2e/suites/imagepullsecret -v -args --no-color --preview="" - name: Diagnostics if: always() run: | diff --git a/internal/e2e/suites/imagepullsecret/imagepullsecret_test.go b/internal/e2e/suites/imagepullsecret/imagepullsecret_test.go index 2f3ee96679..886cefbf4f 100644 --- a/internal/e2e/suites/imagepullsecret/imagepullsecret_test.go +++ b/internal/e2e/suites/imagepullsecret/imagepullsecret_test.go @@ -66,7 +66,7 @@ const ( // --docker-server= --docker-username= --docker-password= // ko resolve -f <(kubectl kustomize --load-restrictor LoadRestrictionsNone \ // manifests/ate-install/kind-image-credential-secret) | kubectl apply -f - -// hack/run-e2e-kind.sh ./internal/e2e/suites/imagepullsecret -v -args --no-color +// hack/run-e2e-kind.sh ./internal/e2e/suites/imagepullsecret -v -args --no-color --preview="" func TestActorImageFromPrivateRegistry(t *testing.T) { repo := os.Getenv("E2E_PRIVATE_REPOSITORY") user := os.Getenv("E2E_PRIVATE_REGISTRY_USERNAME") From 3fc3bee41d9c6cb102e7b47e81457ea5df973151 Mon Sep 17 00:00:00 2001 From: Marcello DeSales Date: Sat, 17 Oct 2026 04:48:41 -0700 Subject: [PATCH 6/9] imagepullsecret: prove the denied case (stock atelet cannot pull the private image) before the allowed one; capture atelet pull evidence (cherry picked from commit 5f53076295aa4fe2731cde89240afe460de1d34c) --- .../workflows/planeo-private-pull-e2e.yaml | 32 ++++++++- internal/e2e/fixture.go | 21 ++++-- internal/e2e/probe.go | 13 +++- .../imagepullsecret/imagepullsecret_test.go | 65 +++++++++++++++++-- 4 files changed, 115 insertions(+), 16 deletions(-) diff --git a/.github/workflows/planeo-private-pull-e2e.yaml b/.github/workflows/planeo-private-pull-e2e.yaml index 8cb6435cbc..b917fb45d4 100644 --- a/.github/workflows/planeo-private-pull-e2e.yaml +++ b/.github/workflows/planeo-private-pull-e2e.yaml @@ -27,7 +27,7 @@ name: planeo-private-pull-e2e on: push: - branches: ['planeo/**'] + branches: ['planeo/**', 'feature/**'] workflow_dispatch: permissions: @@ -73,6 +73,13 @@ jobs: run: hack/create-kind-cluster.sh - name: Install Agent Substrate run: hack/install-ate-kind.sh --deploy-ate-system + - name: "Phase 1 — denied: stock atelet (no credentials) must NOT pull the private image" + env: + E2E_PRIVATE_PULL_EXPECT: denied + E2E_PRIVATE_REGISTRY_USERNAME: ${{ github.actor }} + E2E_PRIVATE_REGISTRY_PASSWORD: ${{ secrets.GITHUB_TOKEN }} + E2E_JUNIT_FILE: ${{ github.workspace }}/_artifacts/e2e-imagepullsecret-denied.xml + run: hack/run-e2e-kind.sh ./internal/e2e/suites/imagepullsecret -v -args --no-color --preview="" - name: Registry Secret for atelet (before atelet restarts, so the volume is populated at start) env: REGISTRY_USER: ${{ github.actor }} @@ -91,12 +98,31 @@ jobs: KO_CONFIG_PATH="${PWD}" hack/run-tool.sh ko resolve -f "${RUNNER_TEMP}/atelet.yaml" | kubectl apply -f - kubectl -n ate-system rollout status daemonset/atelet --timeout=10m kubectl -n ate-system get pods -l app=atelet -o wide - - name: Run the private-pull e2e + - name: "Phase 2 — allowed: atelet with the component + Secret must pull the private image" env: + E2E_PRIVATE_PULL_EXPECT: allowed E2E_PRIVATE_REGISTRY_USERNAME: ${{ github.actor }} E2E_PRIVATE_REGISTRY_PASSWORD: ${{ secrets.GITHUB_TOKEN }} - E2E_JUNIT_FILE: ${{ github.workspace }}/_artifacts/e2e-imagepullsecret.xml + E2E_JUNIT_FILE: ${{ github.workspace }}/_artifacts/e2e-imagepullsecret-allowed.xml run: hack/run-e2e-kind.sh ./internal/e2e/suites/imagepullsecret -v -args --no-color --preview="" + - name: Evidence — atelet's pulls of the private image (credential provider → registry → layers) + if: always() + run: | + mkdir -p "${ARTIFACTS}" + for p in $(kubectl -n ate-system get pods -l app=atelet -o name); do + kubectl -n ate-system logs "$p" -c atelet --timestamps > "${ARTIFACTS}/$(basename "$p").log" 2>&1 || true + kubectl -n ate-system logs "$p" -c atelet --timestamps --previous > "${ARTIFACTS}/$(basename "$p")-previous.log" 2>/dev/null || true + done + echo "::group::atelet lines about the private repository (${E2E_PRIVATE_REPOSITORY})" + cat "${ARTIFACTS}"/atelet-*.log | grep -E "e2e-private-probe|credential|provider|unauthori|denied" | head -200 + echo "::endgroup::" + - name: Upload evidence + if: always() + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 + with: + name: planeo-private-pull-evidence + path: _artifacts/ + retention-days: 30 - name: Diagnostics if: always() run: | diff --git a/internal/e2e/fixture.go b/internal/e2e/fixture.go index 81ad8fc7e8..7cf502d3c5 100644 --- a/internal/e2e/fixture.go +++ b/internal/e2e/fixture.go @@ -117,12 +117,18 @@ type SubstrateFixtureManifests struct { // namespace holding the pool) and the created templates. func DeploySubstrateFixture(t *testing.T, ctx context.Context, clients *Clients, manifests SubstrateFixtureManifests, bucket, name string, trustBundles []string) (string, []*ateapipb.ActorTemplate) { t.Helper() - return deploySubstrateFixture(t, ctx, clients, manifests, bucket, name, trustBundles, nil) + return deploySubstrateFixture(t, ctx, clients, manifests, bucket, name, trustBundles, fixtureOptions{}) } -// deploySubstrateFixture is DeploySubstrateFixture with an optional mutate hook applied to every rendered -// template before it is created (nil: none). -func deploySubstrateFixture(t *testing.T, ctx context.Context, clients *Clients, manifests SubstrateFixtureManifests, bucket, name string, trustBundles []string, mutate func(*ateapipb.ActorTemplate)) (string, []*ateapipb.ActorTemplate) { +// fixtureOptions adjusts deploySubstrateFixture: mutate is applied to every rendered template before it is +// created (nil: none); skipGoldenWait returns right after the templates are created instead of waiting for +// their golden snapshots (for tests that expect the golden build to fail). +type fixtureOptions struct { + mutate func(*ateapipb.ActorTemplate) + skipGoldenWait bool +} + +func deploySubstrateFixture(t *testing.T, ctx context.Context, clients *Clients, manifests SubstrateFixtureManifests, bucket, name string, trustBundles []string, opts fixtureOptions) (string, []*ateapipb.ActorTemplate) { t.Helper() // The pool manifest also carries the namespace. Its cleanup is registered @@ -142,9 +148,9 @@ func deploySubstrateFixture(t *testing.T, ctx context.Context, clients *Clients, tmplInline, tmplBlocks := substrateTemplateSubstitutions(bucket, name, trustBundles) rendered := koResolve(t, renderManifest(t, manifests.Template, tmplInline, tmplBlocks)) templates := decodeSubstrateTemplates(t, rendered) - if mutate != nil { + if opts.mutate != nil { for _, tmpl := range templates { - mutate(tmpl) + opts.mutate(tmpl) } } @@ -192,6 +198,9 @@ func deploySubstrateFixture(t *testing.T, ctx context.Context, clients *Clients, for _, tmpl := range created { t.Logf("Waiting for ActorTemplate %s/%s golden snapshot...", atespace, tmpl.GetMetadata().GetName()) + if opts.skipGoldenWait { + continue + } WaitForSubstrateTemplateReady(ctx, t, clients, atespace, tmpl.GetMetadata().GetName()) } return atespace, created diff --git a/internal/e2e/probe.go b/internal/e2e/probe.go index f681a0561e..bb6efb5fa7 100644 --- a/internal/e2e/probe.go +++ b/internal/e2e/probe.go @@ -37,8 +37,9 @@ var probeManifests = SubstrateFixtureManifests{ type ProbeOption func(*probeConfig) type probeConfig struct { - trustBundles []string - image string + trustBundles []string + image string + skipGoldenWait bool } // The allowlisted names atelet resolves trust bundles by. @@ -63,6 +64,12 @@ func WithImage(image string) ProbeOption { return func(c *probeConfig) { c.image = image } } +// WithoutGoldenWait returns as soon as the template is created instead of waiting for its golden snapshot, +// for tests that expect the golden build to fail (they poll the template's GoldenSnapshotStatus themselves). +func WithoutGoldenWait() ProbeOption { + return func(c *probeConfig) { c.skipGoldenWait = true } +} + // WithSystemRoots adds the WebPKI roots atelet ships to the probe's projected // trust file, as the egress demo's template combines them with the egress // trust bundle. @@ -98,6 +105,6 @@ func DeployProbe(t *testing.T, bucket, name string, opts ...ProbeOption) (string } } } - atespace, templates := deploySubstrateFixture(t, context.Background(), GetClients(), probeManifests, bucket, name, cfg.trustBundles, mutate) + atespace, templates := deploySubstrateFixture(t, context.Background(), GetClients(), probeManifests, bucket, name, cfg.trustBundles, fixtureOptions{mutate: mutate, skipGoldenWait: cfg.skipGoldenWait}) return atespace, templates[0] } diff --git a/internal/e2e/suites/imagepullsecret/imagepullsecret_test.go b/internal/e2e/suites/imagepullsecret/imagepullsecret_test.go index 886cefbf4f..3c5694d7eb 100644 --- a/internal/e2e/suites/imagepullsecret/imagepullsecret_test.go +++ b/internal/e2e/suites/imagepullsecret/imagepullsecret_test.go @@ -23,6 +23,7 @@ import ( "fmt" "os" "path/filepath" + "regexp" "strings" "testing" "time" @@ -33,6 +34,7 @@ import ( "github.com/google/go-containerregistry/pkg/v1/mutate" "github.com/google/go-containerregistry/pkg/v1/remote" "go.ate.dev/substrate/internal/e2e" + "go.ate.dev/substrate/pkg/proto/ateapipb" apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -52,6 +54,12 @@ const ( // - pulled with the Secret: a probe template whose image is the private copy reaches its golden snapshot, // which atelet can only build after pulling the image with the credentials the plugin returned. // +// E2E_PRIVATE_PULL_EXPECT selects the phase (the same private copy, the same probe, two installs): +// +// denied atelet WITHOUT the component (the stock install): the golden build must fail, refused by the +// registry — proving the image is unreachable without the Secret. Run this first. +// allowed (default) atelet WITH the component and the Secret: the golden snapshot must be built. +// // It needs a registry the cluster reaches over TLS (atelet allows plain HTTP only for localhost registries) // and credentials that can push and pull there; it skips when they are not configured: // @@ -80,11 +88,20 @@ func TestActorImageFromPrivateRegistry(t *testing.T) { } ctx := context.Background() - if _, err := e2e.GetClients().K8s.CoreV1().Secrets(secretNamespace).Get(ctx, secretName, metav1.GetOptions{}); err != nil { - if apierrors.IsNotFound(err) { - t.Fatalf("Secret %s/%s is missing: create it before installing the image-credential-secret component (see the test doc)", secretNamespace, secretName) + expect := os.Getenv("E2E_PRIVATE_PULL_EXPECT") + if expect == "" { + expect = "allowed" + } + if expect != "allowed" && expect != "denied" { + t.Fatalf("E2E_PRIVATE_PULL_EXPECT=%q: want allowed or denied", expect) + } + if expect == "allowed" { + if _, err := e2e.GetClients().K8s.CoreV1().Secrets(secretNamespace).Get(ctx, secretName, metav1.GetOptions{}); err != nil { + if apierrors.IsNotFound(err) { + t.Fatalf("Secret %s/%s is missing: create it before installing the image-credential-secret component (see the test doc)", secretNamespace, secretName) + } + t.Fatalf("get Secret %s/%s: %v", secretNamespace, secretName, err) } - t.Fatalf("get Secret %s/%s: %v", secretNamespace, secretName, err) } source := buildProbe(t) @@ -102,6 +119,11 @@ func TestActorImageFromPrivateRegistry(t *testing.T) { t.Logf("anonymous HEAD refused, as expected: %v", err) } + if expect == "denied" { + expectPullDenied(t, ctx, env["BUCKET_NAME"], private) + return + } + // DeployProbe waits for the template's golden snapshot: atelet pulled the image (with the plugin's // credentials) and booted it. atespace, tmpl := e2e.DeployProbe(t, env["BUCKET_NAME"], "imagepullsecret", e2e.WithImage(private)) @@ -182,3 +204,38 @@ func pushPrivateCopy(t *testing.T, ctx context.Context, source, repo string, aut } return repo + "@" + digest.String() } + +// pullDenied matches how a registry refuses an unauthenticated pull, as atelet reports it in the template's +// GoldenSnapshotStatus (go-containerregistry transport errors carry the HTTP status and registry error code). +var pullDenied = regexp.MustCompile(`(?i)unauthori[sz]ed|denied|forbidden|authentication required|\b40[13]\b`) + +// expectPullDenied deploys the probe from the private image and requires its golden build to FAIL with a +// registry refusal: without credentials the image cannot be pulled. A golden snapshot appearing is a failure. +func expectPullDenied(t *testing.T, ctx context.Context, bucket, private string) { + t.Helper() + atespace, tmpl := e2e.DeployProbe(t, bucket, "imagepullsecret-denied", e2e.WithImage(private), e2e.WithoutGoldenWait()) + ref := &ateapipb.ObjectRef{Atespace: atespace, Name: tmpl.GetMetadata().GetName()} + ctx, cancel := context.WithTimeout(ctx, e2e.TemplateReadyTimeout(t)) + defer cancel() + for { + at, err := e2e.GetClients().SubstrateAPI.GetActorTemplate(ctx, &ateapipb.GetActorTemplateRequest{ActorTemplate: ref}) + if err == nil { + st := at.GetStatus().GetGoldenSnapshotStatus() + if st.GetGoldenTag().GetName() != "" { + t.Fatalf("golden snapshot built from %s without credentials: the image is not private to this cluster", private) + } + if msg := st.GetErrorMessage(); msg != "" { + if !pullDenied.MatchString(msg) { + t.Fatalf("golden build failed, but not with a registry refusal: %s", msg) + } + t.Logf("golden build refused without credentials, as expected: %s", msg) + return + } + } + select { + case <-ctx.Done(): + t.Fatalf("timed out waiting for the golden build of %s/%s to fail (last err %v)", atespace, ref.GetName(), err) + case <-time.After(time.Second): + } + } +} From d5d22caba4367e76f6d5690d1fb67cbaed8c6b4d Mon Sep 17 00:00:00 2001 From: Marcello DeSales Date: Sat, 17 Oct 2026 04:59:39 -0700 Subject: [PATCH 7/9] imagepullsecret: assert the denied case on atelet's own log (the template status abstracts the registry refusal) (cherry picked from commit 806888f7b7d218aa86f3a21b339f1591f809c6cb) --- .../imagepullsecret/imagepullsecret_test.go | 39 ++++++++++++++++--- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/internal/e2e/suites/imagepullsecret/imagepullsecret_test.go b/internal/e2e/suites/imagepullsecret/imagepullsecret_test.go index 3c5694d7eb..6f7b8cc448 100644 --- a/internal/e2e/suites/imagepullsecret/imagepullsecret_test.go +++ b/internal/e2e/suites/imagepullsecret/imagepullsecret_test.go @@ -35,6 +35,7 @@ import ( "github.com/google/go-containerregistry/pkg/v1/remote" "go.ate.dev/substrate/internal/e2e" "go.ate.dev/substrate/pkg/proto/ateapipb" + corev1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -205,8 +206,8 @@ func pushPrivateCopy(t *testing.T, ctx context.Context, source, repo string, aut return repo + "@" + digest.String() } -// pullDenied matches how a registry refuses an unauthenticated pull, as atelet reports it in the template's -// GoldenSnapshotStatus (go-containerregistry transport errors carry the HTTP status and registry error code). +// pullDenied matches how a registry refuses an unauthenticated pull in atelet's log (go-containerregistry +// transport errors carry the registry's error code, e.g. GHCR's "UNAUTHORIZED: authentication required"). var pullDenied = regexp.MustCompile(`(?i)unauthori[sz]ed|denied|forbidden|authentication required|\b40[13]\b`) // expectPullDenied deploys the probe from the private image and requires its golden build to FAIL with a @@ -225,10 +226,14 @@ func expectPullDenied(t *testing.T, ctx context.Context, bucket, private string) t.Fatalf("golden snapshot built from %s without credentials: the image is not private to this cluster", private) } if msg := st.GetErrorMessage(); msg != "" { - if !pullDenied.MatchString(msg) { - t.Fatalf("golden build failed, but not with a registry refusal: %s", msg) + // The template status abstracts the cause (e.g. "GoldenActorCrashed"); the registry's refusal is in + // atelet's log, on the EnsureImage of this exact digest. + t.Logf("golden build failed without credentials: %s", msg) + line := ateletLogLine(t, ctx, private) + if line == "" { + t.Fatalf("golden build failed, but atelet logged no registry refusal for %s", private) } - t.Logf("golden build refused without credentials, as expected: %s", msg) + t.Logf("atelet: %s", line) return } } @@ -239,3 +244,27 @@ func expectPullDenied(t *testing.T, ctx context.Context, bucket, private string) } } } + +// ateletLogLine returns the first atelet log line that names image and carries a registry refusal ("" if +// none) — the pull error atelet hit, as it reported it. +func ateletLogLine(t *testing.T, ctx context.Context, image string) string { + t.Helper() + k8s := e2e.GetClients().K8s + pods, err := k8s.CoreV1().Pods(secretNamespace).List(ctx, metav1.ListOptions{LabelSelector: "app=atelet"}) + if err != nil { + t.Fatalf("list atelet pods: %v", err) + } + for _, p := range pods.Items { + raw, err := k8s.CoreV1().Pods(secretNamespace).GetLogs(p.Name, &corev1.PodLogOptions{Container: "atelet"}).DoRaw(ctx) + if err != nil { + t.Logf("logs of %s: %v", p.Name, err) + continue + } + for _, l := range strings.Split(string(raw), "\n") { + if strings.Contains(l, image) && pullDenied.MatchString(l) { + return l + } + } + } + return "" +} From f2c063fb576dcea3a338bd5f3cab3859493db21f Mon Sep 17 00:00:00 2001 From: Marcello DeSales Date: Sat, 17 Oct 2026 05:32:18 -0700 Subject: [PATCH 8/9] ate-setup: register cmd/dockerconfig-credential-provider in images.Components (published with the release images; manifests and the list agree) (cherry picked from commit 444988c0d8612a2be371e0ae7fe1d3cb92078bb8) --- cmd/ate-setup/internal/images/images.go | 1 + 1 file changed, 1 insertion(+) diff --git a/cmd/ate-setup/internal/images/images.go b/cmd/ate-setup/internal/images/images.go index 79ae3fd69b..28b3e4fc17 100644 --- a/cmd/ate-setup/internal/images/images.go +++ b/cmd/ate-setup/internal/images/images.go @@ -50,6 +50,7 @@ var Components = []string{ "cmd/benchmarking/isolate/fake-atelet", "cmd/benchmarking/isolate/fake-workersync", "cmd/credential-provider/kubernetes-secrets", + "cmd/dockerconfig-credential-provider", "cmd/objectstore-plugin", "cmd/podcertcontroller", "demos/counter", From 86e685d4c71487b48cbae483acbd931408aba794 Mon Sep 17 00:00:00 2001 From: Marcello DeSales Date: Sat, 17 Oct 2026 05:44:40 -0700 Subject: [PATCH 9/9] fork-only: publish the credential plugin image from feature branches (digest in the run summary) (cherry picked from commit 3fce1e6f43d57084ad66058fdac3a0f3f2cc2d54) --- .../planeo-publish-credential-plugin.yaml | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 .github/workflows/planeo-publish-credential-plugin.yaml diff --git a/.github/workflows/planeo-publish-credential-plugin.yaml b/.github/workflows/planeo-publish-credential-plugin.yaml new file mode 100644 index 0000000000..322256b380 --- /dev/null +++ b/.github/workflows/planeo-publish-credential-plugin.yaml @@ -0,0 +1,67 @@ +# 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. + +# FORK-ONLY (planeodev/google-substrate) — NOT part of the upstream contribution. +# +# Publishes cmd/dockerconfig-credential-provider exactly as upstream builds images (ko, distroless, linux/amd64 + +# linux/arm64) to ghcr.io/planeodev/google-substrate/dockerconfig-credential-provider:-, and writes the +# digest to the run summary — the digest planeo-infra pins for atelet's init container until upstream publishes the +# image with its release (it is registered in images.Components, which ate-setup publish iterates). +# The image holds no secret; it is public with this public fork. +name: planeo-publish-credential-plugin + +on: + push: + branches: ['feature/**'] + paths: + - cmd/dockerconfig-credential-provider/** + - .github/workflows/planeo-publish-credential-plugin.yaml + workflow_dispatch: + +permissions: + contents: read + packages: write + +jobs: + publish: + runs-on: ubuntu-latest + timeout-minutes: 20 + steps: + - name: Checkout + uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0 + - name: Setup Go + uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5.6.0 + with: + go-version-file: 'go.mod' + cache: false + - name: Unit tests + run: go test ./cmd/dockerconfig-credential-provider/ + - name: Build and push with ko + env: + KO_DOCKER_REPO: ghcr.io/${{ github.repository }} + REGISTRY_USER: ${{ github.actor }} + REGISTRY_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + set -euo pipefail + tag="$(printf '%s' "${GITHUB_REF_NAME}" | tr '/' '-')-${GITHUB_SHA::7}" + printf '%s' "${REGISTRY_TOKEN}" | KO_CONFIG_PATH="${PWD}" hack/run-tool.sh ko login ghcr.io --username "${REGISTRY_USER}" --password-stdin + ref="$(KO_CONFIG_PATH="${PWD}" hack/run-tool.sh ko build --bare=false --base-import-paths \ + --platform=linux/amd64,linux/arm64 --tags "${tag}" ./cmd/dockerconfig-credential-provider)" + echo "ref=${ref}" + { + echo "### dockerconfig-credential-provider" + echo + echo "- digest-pinned: \`${ref}\`" + echo "- tag: \`${KO_DOCKER_REPO}/dockerconfig-credential-provider:${tag}\`" + } >> "${GITHUB_STEP_SUMMARY}"