# Admission Controller

* Admision controller helps us to enforce how a cluster is used
* Prebuilt admision controllers in k8s
  * AlwaysPullImages
  * DefaultStorageClass
  * EventRateLimit
  * NamespaceExists
  * Etc
* We can view enabled admission controllers in api server config
* Update admission controllers at flag `--enable-admission-plugins`
* To disable, ue flag `--disable-admission-plugins`

![Admission Controller](/files/w2eW7fDOMK7R9VgIcxBd)

* Admission controller is ued to validate requets from user

## Validating & Mutating Admission Controllers

* To create your own admiion control logic you are provided with "MutatingAdmision Webhook" and "ValidatingAdmision Webhook"

![Request Reponse](/files/3mzA5tzkrT39vTbbEHNO)

```yaml
apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingWebhookConfiguration
metadata:
  name: "pod-policy.example.com"
webhooks:
- name: "pod-policy.example.com"
  clientConfig:
    service:
      name: "webhook-ns"
      namespace: "webhook-svc"
    caBundle: "xxxx"
  rules:
  - apiGroups: [""]
    apiVersions: ["v1"]
    operations: ["CREATE"]
```

## Lab Learnings

* Create tls ecrets from cert & Key

```bash
k create secret tls <name> --cert=cert/location --key=key/location
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://notes.kaiwalyakoparkar.com/ckad/pod-design/admission-controller.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
