---
title: "A Simple Kubernetes Admission Webhook"
description: "A Kubernetes validating and mutating admission webhook can be a minimal, stateless Go HTTPS server that receives AdmissionReview requests and returns allow/deny decisions or base64-encoded JSON patches."
url: "https://swe.quest/articles/a-simple-kubernetes-admission-webhook-50cc4dc0d3369d0a"
canonical: "https://slack.engineering/simple-kubernetes-webhook/"
source: "Slack Engineering"
published: "2021-12-14"
difficulty: "medium"
kind: "How-to"
reading_minutes: 10
tags: ["kubernetes","go"]
---

# A Simple Kubernetes Admission Webhook

A post on [Slack Engineering](https://swe.quest/sources/slack.md), published 2021-12-14, 10 min read, How-to. Original: [https://slack.engineering/simple-kubernetes-webhook/](https://slack.engineering/simple-kubernetes-webhook/)

## Summary

A Kubernetes validating and mutating admission webhook can be a minimal, stateless Go HTTPS server that receives AdmissionReview requests and returns allow/deny decisions or base64-encoded JSON patches. No Kubebuilder or Operator SDK is needed. The walkthrough covers the Deployment, Service, TLS Secret (SAN must match the service hostname) and the Validating/MutatingWebhookConfiguration objects, including using a namespaceSelector so the webhook doesn't gate its own pods. It then shows pluggable validator and mutator interfaces, used for pod-name checks, env injection and annotation-driven tolerations. Practical lessons: webhook invocation order isn't guaranteed and reinvocationPolicy: IfNeeded can call a webhook twice, so mutations must be idempotent, and local testing must be backed by a prod-like environment.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Kubernetes](https://swe.quest/tags/kubernetes.md) (Infrastructure)
- [Go](https://swe.quest/tags/go.md) (Languages)

## Prerequisites

- Kubernetes pods and deployments ([easy posts on Kubernetes](https://swe.quest/tags/kubernetes.md?difficulty=easy))
- Go HTTP servers ([easy posts on Go](https://swe.quest/tags/go.md?difficulty=easy))
- TLS certificates ([easy posts on Cryptography](https://swe.quest/tags/cryptography.md?difficulty=easy))

## Keywords

Kubernetes admission webhooks, MutatingWebhookConfiguration, ValidatingWebhookConfiguration, AdmissionReview, JSON Patch, Kubebuilder, simple-kubernetes-webhook, kind

## Related posts

- [Rejecting Invalid Ingress Routes at Apply Time](https://swe.quest/articles/rejecting-invalid-ingress-routes-at-apply-time-a3740f5f524b0b3f.md): Zalando Engineering · 2026-04-08 · Medium · 5 min read · Kubernetes, Load balancing, Deployment, Configuration management
  Zalando moved validation of Skipper routing configuration onto the Kubernetes admission path, so a validating webhook now rejects Ingress and RouteGroup objects with unknown predicates, bad filter parameters or unparseable backends during kubectl apply.
- [Building Overexposed: understanding application exposure](https://swe.quest/articles/building-overexposed-understanding-application-exposure-db7e9a3ccc65fc14.md): Shopify Engineering · 2026-10-19 · Medium · 9 min read · Security, Identity & auth, Cloud platforms, Kubernetes, Application security
  Overexposed is Shopify's scheduled scanner for finding GKE Ingresses and Cloud Run services reachable without authentication.
- [How we build containerized services at GitHub using GitHub](https://swe.quest/articles/how-we-build-containerized-services-at-github-using-github-fb75069d884e4f71.md): GitHub Engineering · 2023-08-02 · Easy · 6 min read · Kubernetes, Developer productivity, Deployment, Containers, CI/CD
  GitHub runs hundreds of internal and production services on a "paved path": a Kubernetes-based, multi-cluster, multi-region platform plus conventions and custom tooling layered on top.
- [Docker Security Advisory: AuthZ Plugin Bypass Regression in Docker Engine](https://swe.quest/articles/docker-security-advisory-authz-plugin-bypass-regression-in-docker-engine-a88edacc9440d46e.md): Docker · 2024-07-23 · Medium · 3 min read · Containers, Identity & auth, Vulnerability research, Security
  Docker Engine v19.03 and later regressed on a 2018 authorization-plugin bypass (CVE-2024-41110): an API request with Content-Length set to 0 causes the daemon to forward the request to the AuthZ plugin without its body, so a plugin not set to deny by default may approve it and allow privilege escalation.
- [Docker OIDC connections for GitHub Actions available for Docker Orgs](https://swe.quest/articles/docker-oidc-connections-for-github-actions-available-for-docker-orgs-3b185b228d75b17a.md): Docker · 2026-07-31 · Medium · 4 min read · Identity & auth, CI/CD, Supply chain security, Containers
  Docker Hub now accepts GitHub Actions OIDC tokens, letting workflows exchange a signed per-run JWT for a short-lived, scoped Docker access token instead of storing long-lived PATs or OATs as secrets.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
