Skip to content

Instantly share code, notes, and snippets.

@tibordp
Last active June 6, 2026 20:20
Show Gist options
  • Select an option

  • Save tibordp/09de5c4e43b541dc555afff18fc71e9b to your computer and use it in GitHub Desktop.

Select an option

Save tibordp/09de5c4e43b541dc555afff18fc71e9b to your computer and use it in GitHub Desktop.
MutatingAdmissionPolicy for unqualified Services to default to PreferDualStack
apiVersion: admissionregistration.k8s.io/v1
kind: MutatingAdmissionPolicy
metadata:
name: prefer-dual-stack-services
spec:
matchConstraints:
resourceRules:
- apiGroups: [""]
apiVersions: ["v1"]
operations: ["CREATE"]
resources: ["services"]
matchConditions:
- name: ipfamilypolicy-unset
expression: "!has(object.spec.ipFamilyPolicy)"
- name: not-externalname
expression: 'object.spec.type != "ExternalName"'
failurePolicy: Ignore
reinvocationPolicy: Never
mutations:
- patchType: ApplyConfiguration
applyConfiguration:
expression: >
Object{
spec: Object.spec{
ipFamilyPolicy: "PreferDualStack"
}
}
---
apiVersion: admissionregistration.k8s.io/v1
kind: MutatingAdmissionPolicyBinding
metadata:
name: prefer-dual-stack-services-binding
spec:
policyName: prefer-dual-stack-services
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment