Webhooks
This document describes the webhook functionality in the Dynamo Operator, including validation webhooks, certificate management, and 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 and rotation - Built-in cert-controller, no manual management required
- ✅ cert-manager integration - Optional integration for custom PKI or organizational certificate policies
- ✅ 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, the operator’s built-in cert-controller generates and rotates self-signed certificates automatically at startup — 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
User-configured webhook namespace filtering is not supported. Helm rejects a non-empty
webhook.namespaceSelector value. The cluster-wide webhook configurations cover every namespace,
while namespace-restricted webhook configurations use a Helm-generated selector for their target
namespace. The cluster-wide handlers skip namespaces claimed by an active ownership Lease.
Certificate Management
Automatic Certificates (Default)
Zero configuration required! The operator’s built-in cert-controller generates and rotates certificates automatically at startup.
How It Works
-
Operator starts: The
CertManagerchecks for an existing certificate Secret (configured viawebhook.certificateSecret.name, default:webhook-server-cert). If missing or invalid, it generates a self-signed Root CA and server certificate and writes them to the Secret. -
CA bundle injection: The
CABundleInjectorreadsca.crtfrom the Secret and patches both theValidatingWebhookConfigurationandMutatingWebhookConfigurationwith the base64-encoded CA bundle. -
Certificate rotation: The cert-controller monitors certificate validity and regenerates certificates before they expire.
-
Webhook server starts: The webhook server only begins serving after certificates are confirmed ready, preventing startup races.
Certificate Validity
- Root CA: 10 years
- Server Certificate: 10 years (same as Root CA)
- Automatic rotation: The cert-controller monitors validity and regenerates before expiration
Smart Certificate Management
The cert-controller is intelligent about certificate lifecycle:
- ✅ Checks existing certificates at startup before generating new ones
- ✅ Skips generation if valid certificates already exist in the Secret
- ✅ Regenerates only when needed (missing, expiring soon, or incorrect SANs)
This means:
- Fast operator restarts (no unnecessary cert generation)
- No dependency on Helm hooks or external Jobs
- Certificates persist across pod restarts (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
When to Use cert-manager
- ✅ Custom validity periods: Configure certificate lifetime to match organizational policy
- ✅ Integration with existing PKI: Use your organization’s certificate infrastructure
- ✅ Centralized certificate management: Manage all cluster certificates through cert-manager
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:
Development and Test Multi-Operator Deployments
Namespace-restricted and multi-operator configurations are only for development and testing. They are not supported for production. Use one cluster-wide operator in production.
The operator can run one cluster-wide instance and namespace-restricted instances using a Lease-based ownership mechanism.
Scenario
How It Works
- The namespace-restricted operator creates a Lease named
dynamo-operator-namespace-scope. - The cluster-wide operator skips reconciliation, validation, and mutation for that namespace.
- The namespace-restricted operator’s webhook configurations select only its target namespace.
- Each operator manages the certificate and CA bundles for its own admission configurations.
- Only the cluster-wide operator updates CRDs, conversion service references, and conversion CA bundles.
Deployment Example
ValidatingWebhookConfiguration Naming
The webhook configuration name reflects the deployment mode:
- Cluster-wide:
<release>-validating - Namespace-restricted:
<release>-validating-<namespace>
Example:
Helm fixes every webhook in the namespace-restricted configurations to the target namespace. Do not
set webhook.namespaceSelector manually.
Lease Health
After you uninstall the namespace-restricted release, its webhook configurations are removed and
its Lease expires. Cluster-wide reconciliation and admission then resume for the namespace. If only
the operator Pod is unhealthy, its webhook configurations remain and can block admission according
to failurePolicy until the release recovers or is uninstalled.
Run the same operator version in parallel whenever possible. The cluster-wide operator should be the same version or newer and must provide the newest APIs. A newer namespaced controller is acceptable for development when it remains compatible with the installed CRDs. Install every operator Helm release in a separate namespace so each release owns a distinct admission certificate and webhook configuration set.
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 operator logs for CA injection errors:
Certificate Controller Errors
Symptoms:
- Operator logs show cert-controller errors
- Certificate Secret is not created
- CA bundle is not injected into webhook configurations
Checks:
- Check cert-controller logs:
- Verify RBAC permissions:
- Check if the certificate Secret was created:
- Force certificate regeneration:
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
- ✅ Automatic certificates work well for production - The built-in cert-controller handles generation and rotation; use cert-manager only if you need integration with organizational PKI
- ✅ Test webhook configuration in staging before production
Development Deployments
- ✅ Use
failurePolicy: Ignoreif webhook availability is problematic during development - ✅ Keep automatic certificates (zero configuration, built into the operator)
Multi-Tenant Deployments
- ✅ Deploy one cluster-wide operator for platform-wide validation
- Use namespace-restricted operators only for development or testing, never as a production tenant-isolation mechanism
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