This directory contains all Kubernetes manifests needed to deploy kubechronicle.
namespace.yaml- Creates the kubechronicle namespaceserviceaccount.yaml- Service account for the webhook podrbac.yaml- ClusterRole and ClusterRoleBinding (minimal permissions)deployment.yaml- Webhook deployment with 2 replicasservice.yaml- ClusterIP service exposing the webhookwebhook.yaml- ValidatingWebhookConfiguration for admission controlcertificate.yaml- Optional cert-manager certificate (for TLS)kustomization.yaml- Kustomize configuration for easy deployment
-
TLS Certificates: The webhook requires TLS certificates. Self-signed certificates are the default and recommended approach (no cert-manager or CA required).
Option A: Self-Signed Certificates (Recommended - No Dependencies)
Self-signed certificates work perfectly for internal cluster communication. Kubernetes will accept them as long as the certificate is valid for the service DNS name (which our script ensures).
Using the provided script (easiest):
# Generate self-signed certificate and create Kubernetes secret ./generate-certs.shOr using Makefile:
make generate-certs
Or manually:
# Generate self-signed certificate with proper Subject Alternative Names openssl req -x509 -newkey rsa:4096 -keyout tls.key -out tls.crt -days 365 -nodes \ -subj "/CN=kubechronicle-webhook.kubechronicle.svc" \ -addext "subjectAltName=DNS:kubechronicle-webhook.kubechronicle.svc,DNS:kubechronicle-webhook.kubechronicle.svc.cluster.local,DNS:kubechronicle-webhook,DNS:localhost" # Create Kubernetes secret kubectl create namespace kubechronicle --dry-run=client -o yaml | kubectl apply -f - kubectl create secret tls kubechronicle-webhook-tls \ --cert=tls.crt \ --key=tls.key \ -n kubechronicle # Clean up local files (optional) rm tls.crt tls.key
Note: No CA bundle configuration needed! When using a service reference (not URL), Kubernetes automatically trusts certificates that are valid for the service DNS name.
Option B: Using cert-manager (Optional - Only if you have cert-manager installed)
# Install cert-manager if not already installed kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.13.0/cert-manager.yaml # Deploy with certificate.yaml kubectl apply -f certificate.yaml
-
Database Secret (Optional): If using PostgreSQL, create a secret with the database URL:
kubectl create secret generic kubechronicle-database \ --from-literal=url="postgres://user:password@host:port/database?sslmode=disable" \ -n kubechronicle
# 1. Generate self-signed certificates
./generate-certs.sh
# 2. Deploy kubechronicle
make deploy1. Generate TLS certificates:
./generate-certs.sh
# or
make generate-certs2. (Optional) Create database secret:
make create-db-secret
# or manually:
kubectl create secret generic kubechronicle-database \
--from-literal=url="postgres://user:password@host:port/database?sslmode=disable" \
-n kubechronicle3. Deploy kubechronicle:
# Using Makefile (recommended)
make deploy
# Or using kubectl directly
kubectl apply -f namespace.yaml
kubectl apply -f serviceaccount.yaml
kubectl apply -f rbac.yaml
kubectl apply -f deployment.yaml
kubectl apply -f service.yaml
kubectl apply -f webhook.yaml
# Or using kustomize
kubectl apply -k .-
Check webhook pod status:
kubectl get pods -n kubechronicle kubectl logs -n kubechronicle -l app.kubernetes.io/name=kubechronicle
-
Check webhook configuration:
kubectl get validatingwebhookconfiguration kubechronicle-webhook
-
Test webhook:
# Create a test deployment kubectl create deployment test --image=nginx # Check if event was recorded (if database is configured) # The webhook should allow the request and log the change
DATABASE_URL: PostgreSQL connection string (optional, from secret)TLS_CERT_PATH: Path to TLS certificate (default:/etc/webhook/certs/tls.crt)TLS_KEY_PATH: Path to TLS private key (default:/etc/webhook/certs/tls.key)LOG_LEVEL: Logging level (default:info)
The deployment sets:
- Requests: 100m CPU, 128Mi memory
- Limits: 500m CPU, 512Mi memory
Adjust in deployment.yaml as needed.
- Security Context: Pods run as non-root (UID 65534)
- Least Privilege: RBAC grants minimal permissions (observe-only)
- TLS: All webhook communication is TLS-encrypted
- Fail-Open: Webhook uses
failurePolicy: Ignoreto never block API server
-
Webhook not receiving requests:
- Check webhook configuration:
kubectl get validatingwebhookconfiguration kubechronicle-webhook -o yaml - Verify service is accessible:
kubectl get svc -n kubechronicle - Check pod logs for errors
- Check webhook configuration:
-
Certificate issues:
- Verify TLS secret exists:
kubectl get secret kubechronicle-webhook-tls -n kubechronicle - Check secret contains both tls.crt and tls.key:
kubectl describe secret kubechronicle-webhook-tls -n kubechronicle - If secret is missing, regenerate:
./generate-certs.sh - For cert-manager users: Check certificate validity:
kubectl get certificate -n kubechronicle
- Verify TLS secret exists:
-
Database connection issues:
- Verify secret exists:
kubectl get secret kubechronicle-database -n kubechronicle - Check pod logs for connection errors
- Webhook will continue without database (events logged only)
- Verify secret exists: