Difficulty: Advanced
What were PodPresets in Kubernetes, why were they removed, and what do teams use instead today?
PodPresets were an alpha Kubernetes API (settings.k8s.io/v1alpha1) that automatically injected environment variables, envFrom sources, volumes and volume mounts into Pods at creation time, based on a label selector in the same namespace. They let platform teams add shared configuration such as a database Secret or a common cache volume without every app team editing its manifests. PodPresets never left alpha and were removed in Kubernetes 1.20; today the same job is done with mutating admission webhooks, policy engines like Kyverno, or the newer built-in MutatingAdmissionPolicy.
settings.k8s.io/v1alpha1 API and the PodPreset admission plugin on the API server.PodPreset in a namespace with a selector such as role: frontend.If the injected data conflicted with what the Pod already defined, the preset was not applied and an event was recorded.
| Option | How it works | Typical use |
|---|---|---|
| Mutating admission webhook | Your HTTPS service receives the object and returns a JSON patch | Istio and Linkerd sidecar injection, Vault Agent injector |
| Kyverno mutate policies | Declarative YAML policies, run as a webhook | Add labels, default resources, inject env or volumes |
| OPA Gatekeeper mutation | Assign and AssignMetadata resources | Org-wide defaults with Rego-based validation |
| MutatingAdmissionPolicy | Built-in, CEL-based, no webhook server needed | Simple in-process mutations (newer, beta in recent releases) |
| Helm or Kustomize | Inject at build time, before apply | Keeps the mutation visible in Git |
failurePolicy: Fail can block all Pod creation), and harder debugging.If you answer this in an interview, frame PodPresets as history and spend most of the time on how admission control works now. That is what the interviewer really wants to hear.
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: inject-redis-config
spec:
rules:
- name: add-redis-env
match:
any:
- resources:
kinds: ["Pod"]
selector:
matchLabels:
uses-cache: "true"
mutate:
patchStrategicMerge:
spec:
containers:
- (name): "*" # every container in the Pod
env:
- name: REDIS_HOST
value: redis.cache.svc.cluster.local
- name: REDIS_PORT
value: "6379"
Any Pod labelled `uses-cache: "true"` gets the Redis settings injected at admission time, which is exactly the PodPreset use case with a supported, actively maintained tool.
PodPreset, Mutating Admission Webhook, Kyverno, MutatingAdmissionPolicy, Admission Control