Admission Controllers

What is an Admission Controller?

An Admission Controller is a plugin in Kubernetes that intercepts requests to the Kubernetes API server and evaluates them before they are persisted in the cluster’s etcd database. Admission controllers enforce policies and modify requests to ensure they comply with the rules and configurations of the cluster. They play a crucial role in securing and managing Kubernetes environments by validating and mutating resource configurations.

How Does an Admission Controller Work?

When a user or application submits a request to the Kubernetes API server, the request passes through authentication and authorization checks. If the request is valid, it is then intercepted by one or more admission controllers. These controllers can perform the following actions:

  • Validation: Ensure that the request adheres to defined policies (e.g., checking resource quotas).
  • Mutation: Modify the request to enforce defaults or add missing fields (e.g., adding labels or annotations).

If all admission controllers approve the request, it proceeds to be persisted in etcd and applied to the cluster. If a controller rejects the request, it is denied, and an error is returned to the user.

Why Are Admission Controllers Important?

Admission controllers enhance the security, consistency, and manageability of Kubernetes clusters by enforcing policies and configurations. They allow administrators to implement custom rules, enforce best practices, and ensure compliance with organizational requirements. Without admission controllers, clusters would lack a key mechanism for controlling resource creation and modification.

Types of Admission Controllers

  • Validating Admission Controllers: Evaluate incoming requests and approve or deny them based on policies.
  • Mutating Admission Controllers: Modify requests to enforce default values or add required configurations.

Examples of Common Admission Controllers

  • NamespaceLifecycle: Prevents actions on resources in deleted or terminating namespaces.
  • ResourceQuota: Ensures resource quotas are not exceeded in a namespace.
  • PodSecurity: Enforces pod security standards, such as privilege restrictions.
  • LimitRanger: Enforces default or maximum resource limits for pods and containers.
  • MutatingWebhook and ValidatingWebhook: Enable custom admission policies via external webhooks.

Benefits of Admission Controllers

  • Policy Enforcement: Ensure resources comply with cluster policies and organizational standards.
  • Improved Security: Block potentially harmful configurations, such as privileged pods or excessive resource requests.
  • Consistency: Automatically apply default settings and validate resource configurations.
  • Customizability: Use webhooks to implement custom validation or mutation logic.

Use Cases for Admission Controllers

  1. Security Enforcement: Block privileged containers or enforce security policies for pods.
  2. Resource Management: Enforce quotas or default resource requests and limits.
  3. Default Configurations: Automatically add default labels, annotations, or configurations to resources.
  4. Compliance: Ensure all resources meet organizational and regulatory compliance requirements.

Summary

Admission Controllers in Kubernetes are vital plugins that enforce policies and modify resource requests before they are stored in the cluster. By enabling validation, mutation, and policy enforcement, admission controllers ensure that clusters remain secure, consistent, and compliant with organizational standards. They are a cornerstone of Kubernetes’ extensible and secure architecture.

Related Posts

Don’t let DevOps stand in the way of your epic goals.

Set Your Business Up To Soar.

Book a Free Consult to explore how SlickFinch can support your business with Turnkey and Custom Solutions for all of your DevOps needs.