3 min read | by Jordi Prats
Feature gates are a set of settings that can be used to enable or disable experimental features in Kubernetes. We can enable or disable features that are in alpha or beta stages of development. We need to keep in mind that these features are not yet stable and are not ready for production use.
In the Kubernetes documentation we can find the list of available feature gates. We are going to use MutatingAdmissionPolicy as an example.
To enable this feature in a kind cluster, we need to set the featureGates and runtimeConfig fields in the cluster configuration file:
featureGates field in the cluster configuration file.runtimeConfig field in the cluster configuration file. We can get the API version from the object definition (or the Kubernetes documentation).Here is an example of a cluster configuration file that is enabling the feature gate and the alpha API for the MutatingAdmissionPolicy feature:
kind: Cluster apiVersion: kind.x-k8s.io/v1alpha4 featureGates: "MutatingAdmissionPolicy": true runtimeConfig: "admissionregistration.k8s.io/v1alpha1": true
We can use kind create cluster with the --config parameter to create the cluster:
$ kind create cluster --config mutatingadmissionpolicy.yaml Creating cluster "kind" ... â Ensuring node image (kindest/node:v1.32.0) đŧ â Preparing nodes đĻ â Writing configuration đ â Starting control-plane đšī¸ â Installing CNI đ â Installing StorageClass đž Set kubectl context to "kind-kind" You can now use your cluster with: kubectl cluster-info --context kind-kind Have a nice day! đ
Once ready, we can validate that the feature is enabled by checking the kube-apiserver pod in the kube-system namespace:
$ kubectl get pod -n kube-system -l component=kube-apiserver -o yaml | grep feature-gates - --feature-gates=MutatingAdmissionPolicy=true
To validate that we have enabled the alpha API, we can use the kubectl explain command on any object beloging to the API group, for example the MutatingAdmissionPolicy object that we are interested in:
$ k explain MutatingAdmissionPolicy KIND: MutatingAdmissionPolicy VERSION: admissionregistration.k8s.io/v1alpha1 DESCRIPTION: MutatingAdmissionPolicy describes the definition of an admission mutation policy that mutates the object coming into admission chain. FIELDS: apiVersion <string> APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources kind <string> Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds metadata <Object> Standard object metadata; More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata. spec <Object> Specification of the desired behavior of the MutatingAdmissionPolicy.
Posted on 10/02/2025