Admission Webhook'larıyla API Sunucusunu Genişletme
Küme politikasını uygulamak için doğrulayan ve değiştiren admission webhook'ları kullanarak Kubernetes API isteklerini işlem sırasında yakalayın, doğrulayın veya değiştirin.
Admission Webhook'larıyla API Sunucusunu Genişletme, CoddyKit'te ücretsiz bir Docker & Kubernetes for Developers dersidir. Bu, 4 dersinin 4. dersidir. Aşağıdan dersin tamamını ücretsiz okuyabilir, sonra tarayıcıda yerleşik kod editörü ve 7/24 yapay zeka koçu ile uygulamalı olarak pratik yapabilirsin. Bu, Docker & Kubernetes for Developers öğrenme yolunun bir parçasıdır ve ilerlemeniz web ve CoddyKit uygulaması arasında senkronize olur. Docker & Kubernetes for Developers kursu toplamda 4 dersten oluşur.
Bu dersin bazı bölümleri henüz çevrilmemiş olup İngilizce olarak gösterilmektedir.
What Is Admission Control
After authentication and authorization, requests pass through admission controllers that can validate or modify objects before they are persisted.
Two Kinds of Webhooks
Dynamic admission uses webhooks: mutating webhooks change objects, and validating webhooks accept or reject them.
Where They Sit in the Pipeline
The API server runs mutating webhooks first, then validating webhooks, so a mutation can add defaults before validation checks the final object.
A Use Case
Examples: inject a sidecar (mutating), enforce that every Pod sets resource limits (validating), or block images from untrusted registries.
The MutatingWebhookConfiguration
This resource registers your webhook endpoint with the API server.
apiVersion: admissionregistration.k8s.io/v1
kind: MutatingWebhookConfiguration
metadata:
name: add-defaults
webhooks:
- name: defaults.example.com
clientConfig:
service:
name: webhook-svc
namespace: default
path: /mutate
caBundle: <base64-ca>
rules:
- operations: ["CREATE"]
apiGroups: [""]
apiVersions: ["v1"]
resources: ["pods"]The AdmissionReview Payload
The API server sends an AdmissionReview JSON to your webhook and expects an AdmissionReview response with allowed true/false, and for mutation a JSONPatch.
Returning a JSON Patch
A mutating webhook returns a base64-encoded JSONPatch describing the changes to apply.
{"response":{"allowed":true,"patchType":"JSONPatch","patch":"<base64-patch>"}}failurePolicy Matters
failurePolicy: Fail blocks requests if the webhook is down, which is safe but can lock up the cluster; Ignore lets requests through, which is risky for security policies.
Scoping With Selectors
Use namespaceSelector and objectSelector to limit which requests hit your webhook, avoiding overhead and accidental scope creep.
Policy Engines as an Alternative
Instead of writing webhook servers, tools like OPA Gatekeeper and Kyverno provide declarative policies on top of the same admission mechanism.
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: require-limits
spec:
validationFailureAction: Enforce
rules:
- name: check-limits
match:
any:
- resources:
kinds: [Pod]
validate:
message: "CPU and memory limits are required"
pattern:
spec:
containers:
- resources:
limits:
memory: "?*"TLS Is Required
Webhook endpoints must serve HTTPS with a certificate trusted via the caBundle, since the API server only calls webhooks over TLS.
Quick Check
Test what you have learned.
Recap
You learned how admission webhooks extend the API server: mutating webhooks change objects and validating webhooks enforce policy, the AdmissionReview flow, failurePolicy and selectors, TLS requirements, and policy engines like Kyverno and Gatekeeper.
Sıkça Sorulan Sorular
“Admission Webhook'larıyla API Sunucusunu Genişletme” dersi ücretsiz mi?
Evet — “Admission Webhook'larıyla API Sunucusunu Genişletme” dersin tüm metni burada web'de ücretsiz olarak okunabilir. Etkileşimli olarak pratik yapmak (yerleşik kod editörü ve 7/24 yapay zeka koçu) ve Docker & Kubernetes for Developers kursunun geri kalanını açmak için CoddyKit PRO'ya yükselt. Docker & Kubernetes for Developers kursu toplamda 4 dersten oluşur.
“Admission Webhook'larıyla API Sunucusunu Genişletme” dersinde ne öğreneceğim?
Küme politikasını uygulamak için doğrulayan ve değiştiren admission webhook'ları kullanarak Kubernetes API isteklerini işlem sırasında yakalayın, doğrulayın veya değiştirin. Docker & Kubernetes for Developers ile uygulamalı kodu tarayıcıda doğrudan çalıştırarak pratik yaparsın ve 7/24 yapay zeka koçu dersi çalışırken sorularını yanıtlar.
Docker & Kubernetes for Developers öğrenmeye başlamak için deneyim gerekli mi?
Önceden deneyim gerekmez. CoddyKit'te Docker & Kubernetes for Developers, başlangıçtan ileri seviyeye kadar yapılandırıldığı için buradan başlayabilir veya başından başlayıp kendi hızında ilerleme yapabilirsin. Bu, 4 dersinin 4. dersidir.
“Admission Webhook'larıyla API Sunucusunu Genişletme” dersi ne kadar sürer?
Çoğu CoddyKit dersi yaklaşık 5–10 dakika sürer. Her biri kısa ve etkileşimli olduğu için sabit ilerleme yaparsın ve web ile uygulama arasında tam olarak bıraktığın yerden devam edebilirsin.
Bu Docker & Kubernetes for Developers dersinde kod yazıp çalıştırabilir miyim?
Evet. Her Docker & Kubernetes for Developers dersi yerleşik bir kod editörü içerir, bu sayede tarayıcıda gerçek kod yazıp çalıştırabilir ve anlık yapay zeka geri bildirimi alırsın — yerel kurulum gerekli değildir.
Bu kursun tüm dersleri
- Özel Kaynak Tanımları (CRD'ler)
- Kubernetes'te Operatör deseni
- Kubernetes ile sunucusuz yapı (Knative)
- Admission Webhook'larıyla API Sunucusunu Genişletme