<p>I created an admission webhook in Kubernetes including resources for deployments and StatefulSet.</p>
<p>The mutation webhook works on Deployments but not in StatefulSets.</p>
<p>I tried searching in documentations, but the example is only on deployments and ReplicaSets.</p>
<p>Are admission controllers supported in StatefulSets in Kubernetes?
I am using the 1.16 version.</p>
<p>In the documentation:</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingWebhookConfiguration
...
webhooks:
- name: my-webhook.example.com
  rules:
  - operations: [&quot;CREATE&quot;, &quot;UPDATE&quot;]
    apiGroups: [&quot;apps&quot;]
    apiVersions: [&quot;v1&quot;, &quot;v1beta1&quot;]
    resources: [&quot;deployments&quot;, &quot;replicasets&quot;]
    scope: &quot;Namespaced&quot;
</code></pre>
<p>Please advise.</p>

<p>It should be, for example, the PingCap TiDB operator <a href="https://docs.pingcap.com/tidb-in-kubernetes/stable/enable-admission-webhook#functionality-of-admission-controller" rel="nofollow noreferrer">has an option to enable/disable the admission controller</a> for the StatefulSet it manages.</p>
<p>I'm not really sure what behavior you are seeing? It's not allowing you to create a StatefulSet? If yes, you can start you with '*' values and work your way down. For example, allow all namespaces:</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingWebhookConfiguration
...
webhooks:
- name: my-webhook.example.com
  rules:
  - operations: [&quot;CREATE&quot;, &quot;UPDATE&quot;]
    apiGroups: [&quot;apps&quot;]
    apiVersions: [&quot;v1&quot;, &quot;v1beta1&quot;]
    resources: [&quot;deployments&quot;, &quot;replicasets&quot;, &quot;statefulsets&quot;]
    scope: &quot;*&quot;
</code></pre>
