Repository navigation
Description
Summary
ActorTemplate container env currently accepts Kubernetes corev1.EnvVar in the CRD schema, so users can write valueFrom.configMapKeyRef and valueFrom.secretKeyRef in manifests. At runtime, Substrate flattens env vars into its atelet workload protobuf, which historically carried only literal name/value pairs. That means valueFrom entries are accepted by the API but are not usable by actors.
Add support for resolving valueFrom.configMapKeyRef and valueFrom.secretKeyRef for ActorTemplate container env before handing the workload spec to atelet.
Why this matters
- Secret-backed env vars are the standard Kubernetes pattern for API keys and credentials. Without this, demos and real workloads either inline secrets as plain env values in rendered manifests or need custom workaround scripts.
- ConfigMap-backed env vars are the standard Kubernetes pattern for non-secret runtime configuration.
- The current behavior is surprising because the CRD schema exposes Kubernetes EnvVar, including
valueFrom, but Substrate silently loses the source and sends an empty literal value to atelet. - Supporting these two common
valueFromsources makes ActorTemplate behavior closer to what Kubernetes users expect while keeping unsupported sources explicit.
Proposed scope
- Support literal
env.valueas before. - Support
env.valueFrom.configMapKeyReffrom the ActorTemplate namespace. - Support
env.valueFrom.secretKeyReffrom the ActorTemplate namespace. - Preserve Kubernetes
optional: truebehavior by skipping the env var if the referenced object or key is missing. - Return a clear error for missing required objects/keys.
- Return a clear error for unsupported sources such as
fieldRef,resourceFieldRef, andfileKeyRef.
Security / design note
Resolving Secret and ConfigMap references in ate-api means ate-api needs read access to those resources. The straightforward implementation grants the ate-api service account get access to ConfigMaps and Secrets so ActorTemplates work without custom per-namespace RBAC. This is a conscious tradeoff for now, but it should remain a security TODO/design choice.
Possible future designs include per-namespace delegated RBAC, admission-time validation/materialization, or another scoped credential model that avoids broad Secret read access in the control plane.
Acceptance criteria
- ActorTemplate env with
valueFrom.secretKeyRefreaches the actor process with the referenced Secret value. - ActorTemplate env with
valueFrom.configMapKeyRefreaches the actor process with the referenced ConfigMap value. - Missing required refs fail clearly instead of becoming empty env vars.
- Optional missing refs are skipped.
- Unsupported
valueFromsources fail clearly. - Docs call out supported sources and the security/design tradeoff.
Activity
thockin commentedon May 20, 2026
Thank you for citing the security concern. It's pretty significant, IMO
EItanya commentedon May 20, 2026
I also addressed this in the PR I created. I think both approaches have potential downsides. Either we send these over the wire, or we allow all runners to read all secrets. This design could also have overlap with your namespace issue as you could force the runner to coexist with the secrets.
Has there been prior thinking done on this from your side, I definitely want to get this right, but I'll also say that this is an incredibly important thing to add ASAP
thockin commentedon May 20, 2026
Taahir Ahmed (@ahmedtd) and Michael Taufen (@mtaufen) probably done the most thinking on this
mtaufen commentedon May 21, 2026
The industry is broadly converging on a pattern of injecting credentials on the wire to prevent them from ending up in the agent context/being leaked by agents who have access to the env and filesystem. I'd like substrate to natively support this, or be easy to plug in the proxy of your choice.
We may still want some kind of secret support in the future for actors that run agent loops but aren't giving LLMs direct access to the local filesystem or env vars, for example to make it easier for those actors to connect to LLM APIs. But we need to be careful that our approach doesn't just encourage plumbing secrets to where agents also see them.
Finally, NOT supporting secrets is guaranteed to lead to ugly things like putting them in plaintext because "there was no other way to do it" (and agents especially will do this if they feel they have to get a job done), so +1 it's VERY important we address this gap.
ahmedtd commentedon May 21, 2026
Embedding the Kubernetes EnvVar type directly was something I did in the rush for launch --- I will send a PR to replace it with an equivalent substrate-specific type that only has the fields for the things we actively support.
I agree, though, that we need this feature.
We can either have ate-api-server read the ConfigMap / Secret, or atelet. Ideally, if we have atelet read the ConfigMap, we can find some way to piggyback on the actor identity (similar to node isolation in Kubernetes). I can't immediately think of a way to make it work by building on the node restriction plugin / node authorizer because the ActorTemplate is not necessarily in the same namespace as the worker pod (if it were, then atelet could impersonate kubelet and get access to the ConfigMap / Secret via node authorizer).
Probably the design that makes the most sense for now is to make sure that ate-api-server has permission to read all relevant ConfigMaps and Secrets, and interpolate the values into the RPC call to atelet. ate-api-server is already highly privileged, and all of the RPC calls are going to be protected with mTLS.
ahmedtd commentedon May 21, 2026
One open question I have is: if the environment variable values change on resume (because we read them again from the configmap, and the configmap was updated), does that break the gVisor snapshot?
They definitely won't be updated in the memory of the running snapshot, but I don't know what is safe to change in the OCI bundle vs what is not when restoring from a snapshot.
ahmedtd commentedon May 21, 2026
nybidari or Fabricio Voznika (@fvoznika) Do you know the answer to the above?
EItanya commentedon May 22, 2026
This is the design I went with for #20, I left it draft only because I wanted to continue the discussion but the implementation should be ok.
I couldn't agree with this more.
I think in the long-term saying that secrets can never be injected into actors directly may be overly restrictive, but for agents of course injecting on the wire is much more secure. I wonder if an API that allows for either/or could be the most flexible and allow for the most security in the long-term.
fvoznika commentedon May 22, 2026
We decided to allow changes in environment variables between save/restore sessions, especially to support golden images and fork cases where parts of the environment changes. However, environment variables are stored in a memory block in the user mode processes and can't be changed by the kernel. So upon restore, the new environment variables are placed in
/proc/gvisor/spec_environand the application must refresh them to get the new values. More details here.mtaufen commentedon May 22, 2026
We need to think about scalability here. Is the intent that these sources be per-template or per-actor?
mtaufen commentedon May 22, 2026
Not to mention security - ate-api-server still runs in the cluster, so this is giving a handful of K8s nodes access to many/most secrets. Now I wish we'd done a real authorizer for ReferenceGrant. https://github.com/kubernetes/enhancements/tree/master/keps/sig-auth/3766-referencegrant
mtaufen commentedon May 22, 2026
Do we log RPC arguments today? Can we tag this data as sensitive for redaction before any RPC logs are printed?
mtaufen commentedon May 27, 2026
Another thing to consider: substrate doesn't have its own concept of namespaces yet (not to mention noderestriction), so does Secret support let you mount anyone else's secret by default? Need to plan a path forward that doesn't prevent us from adding that isolation later.
ahmedtd commentedon May 27, 2026
The PR treats this the same as Kubernetes does --- the secret/configmap needs to be in the same k8s namespace as the actortemplate. That seems like a reasonable level of access restriction to me.
16 remaining items
ahmedtd commentedon Jun 2, 2026
We don't allow you to change these things (or we won't, as soon as ActorTemplate is immutable). For a given actor lifecycle, right now, you can be confident that memory snapshots are in use.
If the SLO is not 100%, then the feature seems useless? If the snapshot is not recoverable, then the actor should be considered dead (and maybe, eventually, when we figure out how to port an actor between actor templates, you might need to run that process to get a new cold boot and memory state0.
Memory snapshots are not an optimization if they cannot reliably hold state, since as an application developer you will be forced to write to a DB on disk, or a remote data store. At that point it's just the ADK multitenant model with extra steps.
ahmedtd commentedon Jun 2, 2026
People expect to plumb in API keys via environment variables. If we do not provide this feature, they will instead embed the secret in the ActorTemplate's environment variable definition.
Projected volumes are definitely the "correct" way to put this stuff in (or even better, figure out how to use your Actor Identity JWT to authenticate to whichever remote API you are calling). But we need to meet people (and LLM APIs) where they're at.
(Update): For this use case of people plumbing in static API keys, rotation is already assumed to be a pain, and basically unhandled. That's why I think it's fine to read it once at cold boot (typically, during the golden snapshot process), and keep that value frozen.
thockin commentedon Jun 2, 2026
I don't buy that as a durable property. Actor upgrades are almost certainly a thing we need to tackle without destroying actors.
ahmedtd commentedon Jun 2, 2026
Sure, but it will need to be something where an human operator or controller explicitly marshals the actor through a process:
thockin commentedon Jun 2, 2026
I agree with the possible exception of "Signal the actor" - since it is as-yet undefined, we're just hand-waving.
I agree with the API key use-case and constraints. I am trying to understand if there are more use-cases, in particular for ConfigMaps, and in very particular cases that would need mutability.
EItanya commentedon Jun 2, 2026
Without wading too much into the deeper argument here, I do think that at the very least we can start here with ONLY Secret support and leave ConfigMaps for another day. Potentially only supporting mounted volumes for those. What do yall think?
thockin commentedon Jun 2, 2026
Starting with the things we know we need is the correct path. I was hoping to solve multiple things in one movement, but it seems we can't, so let's do the parts we understand.
secretKeyRefwhich is set upon the first resume SGTM. We don't want to serialize that into any API, so it COULD change value if the actor's memory state is lost for any reason.EItanya commentedon Jun 2, 2026
Just to be 100% clear, you're saying we SHOULD NOT restart the actor if the env vars change
thockin commentedon Jun 2, 2026
I think that's correct. Doing so might be surprising (in a bad way) and we don't KNOW we need it yet, so we can't reason about the implications.
EItanya commentedon Jun 2, 2026
Implemented the narrowed scope from this thread in PR #20 at commit EItanya/substrate@6945caa.
This keeps ActorTemplate env support to literal values plus secretKeyRef only, removes ConfigMap env support, removes the public last_resolved_env_* API fields, and removes env-change snapshot invalidation/restart behavior. Secret values are still resolved by ate-api and sent to atelet on the cold/spec path, with existing RPC redaction retained.
[-]Support ConfigMap and Secret env sources in ActorTemplate containers[/-][+]Support Secret env sources in ActorTemplate containers[/+]Support actortemplate secret env (#20)
fix: repair jwt e2e setup and worker test sync (agent-substrate#15)
Remove the secretKeyRef env sources feature (#835)