Webhooks
This document describes the webhook functionality in the Dynamo Operator, including validation webhooks, certificate management, and troubleshooting.
Table of Contents
- Overview
- Architecture
- Configuration
- Certificate Management
- Multi-Operator Deployments
- Troubleshooting
Overview
The Dynamo Operator uses Kubernetes admission webhooks to provide real-time validation and mutation of custom resources. Currently, the operator implements validation webhooks that ensure invalid configurations are rejected immediately at the API server level, providing faster feedback to users compared to controller-based validation.
All webhook types (validating, mutating, conversion, etc.) share the same webhook server and TLS certificate infrastructure, making certificate management consistent across all webhook operations.
Key Features
- ✅ Enabled by default - Zero-touch validation out of the box
- ✅ Shared certificate infrastructure - All webhook types use the same TLS certificates
- ✅ Automatic certificate generation - No manual certificate management required
- ✅ Defense in depth - Controllers validate when webhooks are disabled
- ✅ cert-manager integration - Optional integration for automated certificate lifecycle
- ✅ Multi-operator support - Lease-based coordination for cluster-wide and namespace-restricted deployments
- ✅ Immutability enforcement - Critical fields protected via CEL validation rules
Current Webhook Types
- Validating Webhooks: Validate custom resource specifications before persistence
DynamoComponentDeploymentvalidationDynamoGraphDeploymentvalidationDynamoModelvalidation
Note: Future releases may add mutating webhooks (for defaults/transformations) and conversion webhooks (for CRD version migrations). All will use the same certificate infrastructure described in this document.
Architecture
Validation Flow
- Webhook validation (if enabled): Validates at API server level
- CEL validation: Kubernetes-native immutability checks (always active)
- Controller validation (if webhooks disabled): Defense-in-depth validation during reconciliation
Configuration
Enabling/Disabling Webhooks
Webhooks are enabled by default. To disable them:
When to disable webhooks:
- During development/testing when rapid iteration is needed
- In environments where admission webhooks are not supported
- When troubleshooting validation issues
Note: When webhooks are disabled, controllers perform validation during reconciliation (defense in depth).
Certificate Management Options
The operator supports three certificate management modes:
Advanced Configuration
Complete Configuration Reference
Failure Policy
Recommendation: Use Fail in production to ensure validation is always enforced. Only use Ignore if you need high availability and can tolerate occasional invalid resources.
Namespace Filtering
Control which namespaces are validated (applies to cluster-wide operator only):
Note: For namespace-restricted operators, the namespace selector is automatically set to validate only the operator’s namespace. This configuration is ignored in namespace-restricted mode.
Certificate Management
Automatic Certificates (Default)
Zero configuration required! Certificates are automatically generated during helm install and helm upgrade.
How It Works
-
Pre-install/pre-upgrade hook: Generates self-signed TLS certificates
- Root CA (valid 10 years)
- Server certificate (valid 10 years)
- Stores in Secret:
<release>-webhook-server-cert
-
Post-install/post-upgrade hook: Injects CA bundle into
ValidatingWebhookConfiguration- Reads
ca.crtfrom Secret - Patches
ValidatingWebhookConfigurationwith base64-encoded CA bundle
- Reads
-
Operator pod: Mounts certificate secret and serves webhook on port 9443
Certificate Validity
- Root CA: 10 years
- Server Certificate: 10 years (same as Root CA)
- Automatic rotation: Certificates are re-generated on every
helm upgrade
Smart Certificate Generation
The certificate generation hook is intelligent:
- ✅ Checks existing certificates before generating new ones
- ✅ Skips generation if valid certificates exist (valid for 30+ days with correct SANs)
- ✅ Regenerates only when needed (missing, expiring soon, or incorrect SANs)
This means:
- Fast
helm upgradeoperations (no unnecessary cert generation) - Safe to run
helm upgradefrequently - Certificates persist across reinstalls (stored in Secret)
Manual Certificate Rotation
If you need to rotate certificates manually:
cert-manager Integration
For clusters with cert-manager installed, you can enable automated certificate lifecycle management.
Prerequisites
- cert-manager installed (v1.0+)
- CA issuer configured (e.g.,
selfsigned-issuer)
Configuration
How It Works
- Helm creates Certificate resource: Requests TLS certificate from cert-manager
- cert-manager generates certificate: Based on configured issuer
- cert-manager stores in Secret:
<release>-webhook-server-cert - cert-manager ca-injector: Automatically injects CA bundle into
ValidatingWebhookConfiguration - Operator pod: Mounts certificate secret and serves webhook
Benefits Over Automatic Mode
- ✅ Automated rotation: cert-manager renews certificates before expiration
- ✅ Custom validity periods: Configure certificate lifetime
- ✅ CA rotation support: ca-injector handles CA updates automatically
- ✅ Integration with existing PKI: Use your organization’s certificate infrastructure
Certificate Rotation
With cert-manager, certificate rotation is fully automated:
-
Leaf certificate rotation (default: every year)
- cert-manager auto-renews before expiration
- controller-runtime auto-reloads new certificate
- No pod restart required
- No caBundle update required (same Root CA)
-
Root CA rotation (every 10 years)
- cert-manager rotates Root CA
- ca-injector auto-updates caBundle in
ValidatingWebhookConfiguration - No manual intervention required
Example: Self-Signed Issuer
External Certificates
Bring your own certificates for custom PKI requirements.
Steps
- Create certificate secret manually:
- Configure operator to use external secret:
- Deploy operator:
Certificate Requirements
- Secret name: Must match
webhook.certificateSecret.name(default:webhook-server-cert) - Secret keys:
tls.crt,tls.key,ca.crt - Certificate SAN: Must include
<service-name>.<namespace>.svc- Example:
dynamo-platform-dynamo-operator-webhook-service.dynamo-system.svc
- Example:
Multi-Operator Deployments
The operator supports running both cluster-wide and namespace-restricted instances simultaneously using a lease-based coordination mechanism.
Scenario
How It Works
- Namespace-restricted operator creates a Lease in its namespace
- Cluster-wide operator watches for Leases named
dynamo-operator-ns-lock - Cluster-wide operator skips validation for namespaces with active Leases
- Namespace-restricted operator validates resources in its namespace
Lease Configuration
The lease mechanism is automatically configured based on deployment mode:
Deployment Example
ValidatingWebhookConfiguration Naming
The webhook configuration name reflects the deployment mode:
- Cluster-wide:
<release>-validating - Namespace-restricted:
<release>-validating-<namespace>
Example:
This allows multiple webhook configurations to coexist without conflicts.
Lease Health
If the namespace-restricted operator is deleted or becomes unhealthy:
- Lease expires after
leaseDuration + gracePeriod(default: ~30 seconds) - Cluster-wide operator automatically resumes validation for that namespace
Troubleshooting
Webhook Not Called
Symptoms:
- Invalid resources are accepted
- No validation errors in logs
Checks:
- Verify webhook is enabled:
- Check webhook configuration:
- Verify webhook service exists:
- Check operator logs for webhook startup:
Connection Refused Errors
Symptoms:
Checks:
- Verify operator pod is running:
- Check webhook server is listening:
- Verify webhook port in deployment:
- Check for webhook initialization errors:
Certificate Errors
Symptoms:
Checks:
- Verify caBundle is present:
- Verify certificate secret exists:
- Check certificate validity:
- Check CA injection job logs:
Helm Hook Job Failures
Symptoms:
helm installorhelm upgradehangs or fails- Certificate generation errors
Checks:
- List hook jobs:
- Check job logs:
- Check RBAC permissions:
- Manual cleanup:
Validation Errors Not Clear
Symptoms:
- Webhook rejects resource but error message is unclear
Solution:
Check operator logs for detailed validation errors:
Webhook logs include:
- Resource name and namespace
- Validation errors with context
- Warnings for immutable field changes
Stuck Deleting Resources
Symptoms:
- Resource stuck in “Terminating” state
- Webhook blocks finalizer removal
Solution:
The webhook automatically skips validation for resources being deleted. If stuck:
- Check if webhook is blocking:
- Temporarily disable webhook:
- Delete resource again:
- Re-enable webhook:
Best Practices
Production Deployments
- ✅ Keep webhooks enabled (default) for real-time validation
- ✅ Use
failurePolicy: Fail(default) to ensure validation is enforced - ✅ Monitor webhook latency - Validation adds ~10-50ms per resource operation
- ✅ Use cert-manager for automated certificate lifecycle in large deployments
- ✅ Test webhook configuration in staging before production
Development Deployments
- ✅ Disable webhooks for rapid iteration if needed
- ✅ Use
failurePolicy: Ignoreif webhook availability is problematic - ✅ Keep automatic certificates (simpler than cert-manager for dev)
Multi-Tenant Deployments
- ✅ Deploy one cluster-wide operator for platform-wide validation
- ✅ Deploy namespace-restricted operators for tenant-specific namespaces
- ✅ Monitor lease health to ensure coordination works correctly
- ✅ Use unique release names per namespace to avoid naming conflicts
Additional Resources
- Kubernetes Admission Webhooks
- cert-manager Documentation
- Kubebuilder Webhook Tutorial
- CEL Validation Rules
Support
For issues or questions:
- Check Troubleshooting section
- Review operator logs:
kubectl logs -n <namespace> deployment/<release>-dynamo-operator - Open an issue on GitHub