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
- ✅ Always enabled - Webhooks are a required component of the operator
- ✅ Shared certificate infrastructure - All webhook types use the same TLS certificates
- ✅ Automatic certificate generation - No manual certificate management required
- ✅ 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
DynamoComponentDeploymentvalidationDynamoGraphDeploymentvalidationDynamoModelvalidationDynamoGraphDeploymentRequestvalidation
- Mutating Webhooks: Apply default values to resources on creation
DynamoGraphDeploymentdefaulting
Note: All webhook types use the same certificate infrastructure described in this document.
Architecture
Admission Flow
- Mutating webhooks: Apply defaults and transformations before validation
- Validating webhooks: Validate the (possibly mutated) CR against business rules
- CEL validation: Kubernetes-native immutability checks (always active)
Upgrading from versions with webhook.enabled: false
The webhook.enabled Helm value has been removed. Webhooks are now a required component of the operator and are always active. If you previously ran with webhook.enabled: false, take the following steps before upgrading:
- Remove
webhook.enabledfrom any custom values files. Helm will ignore the unknown key, but it should be cleaned up to avoid confusion. - Ensure port 9443 is reachable from the Kubernetes API server to the operator pod. If you have
NetworkPolicyrules or firewall configurations restricting traffic, add an ingress rule allowing the API server to reach the webhook server on port 9443. - Ensure webhook TLS certificates are available. By default, Helm hooks generate self-signed certificates automatically during
helm upgrade— no action needed. If you use cert-manager or externally managed certificates, verify your configuration is in place before upgrading.
Configuration
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 configuration exists:
- 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 work around the webhook:
- Delete resource again:
- Restore webhook configuration:
Best Practices
Production Deployments
- ✅ 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
- ✅ Use
failurePolicy: Ignoreif webhook availability is problematic during development - ✅ 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