etcd-manager

by VNG Cloud

Helm chartv1.0.0App 1.0.0Verified publisher

A Helm chart for managing ETCD certificate lifecycle and health monitoring in Kamaji environments

About this chart

ETCD Manager Helm Chart

A Helm chart for managing ETCD certificate lifecycle and health monitoring in Kamaji tenant control plane environments.

Overview

This Helm chart deploys two CronJobs that automate ETCD certificate management and health monitoring:

  1. Certificate Expiry Checker - Scans ETCD certificates and identifies those expiring soon
  2. Certificate Renewal - Automatically renews expiring certificates and configures health checks

Features

  • 🔍 Automatic Certificate Monitoring - Daily scans of all ETCD certificates
  • 🔄 Automated Certificate Renewal - Renews certificates before expiration
  • 💚 Health Check Configuration - Ensures proper liveness and readiness probes
  • 📊 ConfigMap-based Communication - Checker stores results for renewal job
  • 📱 Telegram Notifications - Real-time alerts on renewal status
  • 🔒 RBAC Compliant - Minimal required permissions
  • ⚙️ Highly Configurable - Extensive customization via values.yaml

Prerequisites

  • Kubernetes 1.19+
  • Helm 3.0+
  • ETCD instances running in Kamaji environment
  • kubectl access to the cluster
  • (Optional) Telegram bot for notifications

Installation

Quick Start

# Add the Helm repository (if applicable)
helm repo add etcd-manager https://your-repo-url
helm repo update

# Install with default values
helm install etcd-manager etcd-manager/etcd-manager -n datastore --create-namespace

# Or install from local chart
helm install etcd-manager ./etcd-manager -n datastore --create-namespace

Custom Installation

# Create a custom values file
cat > my-values.yaml <<EOF
namespace: datastore

certChecker:
  schedule: "0 3 * * *"  # Run at 3 AM
  checkDays: 30          # Check 30 days before expiry

certRenewal:
  schedule: "0 11 * * *" # Run at 11 AM
  config:
    zone: "PRODUCTION"
    proxyUrl: "proxy.example.com:3128"
  secrets:
    telegramBotToken: "your-bot-token"
    telegramChatId: "your-chat-id"
EOF

# Install with custom values
helm install etcd-manager ./etcd-manager -n datastore -f my-values.yaml

Configuration

Global Parameters

ParameterDescriptionDefault
namespaceNamespace where ETCD instances are runningdatastore
commonLabelsAdditional labels to add to all resources{}
commonAnnotationsAdditional annotations to add to all resources{}

Certificate Checker Parameters

ParameterDescriptionDefault
certChecker.enabledEnable certificate checker CronJobtrue
certChecker.scheduleCronJob schedule"0 2 * * *"
certChecker.checkDaysDays before expiration to trigger renewal40
certChecker.configMapNameConfigMap to store check resultsetcd-renewal
certChecker.image.repositoryImage repositoryvcr.vngcloud.vn/81-vks-public/etcd-cert-manager
certChecker.image.tagImage taglatest
certChecker.resources.requests.memoryMemory request64Mi
certChecker.resources.requests.cpuCPU request100m

Certificate Renewal Parameters

ParameterDescriptionDefault
certRenewal.enabledEnable certificate renewal CronJobtrue
certRenewal.scheduleCronJob schedule"0 10 * * *"
certRenewal.image.repositoryImage repositoryvcr.vngcloud.vn/81-vks-public/etcd-cert-renewal
certRenewal.image.tagImage taglatest
certRenewal.config.zoneEnvironment zone identifierDEV
certRenewal.config.proxyUrlProxy URL for external communication172.28.4.4:3128
certRenewal.secrets.telegramBotTokenTelegram bot token(required)
certRenewal.secrets.telegramChatIdTelegram chat ID(required)
certRenewal.resources.requests.memoryMemory request128Mi
certRenewal.resources.requests.cpuCPU request200m

RBAC Parameters

ParameterDescriptionDefault
certChecker.serviceAccount.createCreate service account for checkertrue
certChecker.rbac.createCreate RBAC resources for checkertrue
certRenewal.serviceAccount.createCreate service account for renewaltrue
certRenewal.rbac.createCreate RBAC resources for renewaltrue
certRenewal.rbac.createClusterRoleCreate ClusterRole for Kamaji resourcestrue

Usage

Manual Trigger

Trigger Certificate Check

kubectl create job --from=cronjob/cert-expiry-checker \
  -n datastore manual-cert-check-$(date +%s)

Trigger Certificate Renewal

kubectl create job --from=cronjob/etcd-cert-renewal \
  -n datastore manual-cert-renewal-$(date +%s)

View Results

Check ConfigMap Results

# View instances needing renewal
kubectl get configmap etcd-renewal -n datastore -o yaml

# Extract specific information
kubectl get configmap etcd-renewal -n datastore \
  -o jsonpath='{.data.instances}' | tr ',' '\n'

kubectl get configmap etcd-renewal -n datastore \
  -o jsonpath='{.data.last-check}'

View Job Logs

# Certificate checker logs
kubectl logs -n datastore -l app.kubernetes.io/component=cert-checker --tail=100

# Certificate renewal logs
kubectl logs -n datastore -l app.kubernetes.io/component=cert-renewal --tail=100

# Specific job logs
kubectl logs -n datastore job/<job-name>

Monitor CronJobs

# View CronJob status
kubectl get cronjob -n datastore

# View recent jobs
kubectl get jobs -n datastore --sort-by=.metadata.creationTimestamp

# View job history
kubectl get jobs -n datastore -l app.kubernetes.io/name=etcd-manager

Troubleshooting

Check RBAC Permissions

# Verify cert-checker permissions
kubectl auth can-i get secrets -n datastore \
  --as=system:serviceaccount:datastore:cert-checker-sa

# Verify cert-renewal permissions
kubectl auth can-i patch statefulsets -n datastore \
  --as=system:serviceaccount:datastore:cert-renewal-sa

Debug Failed Jobs

# Get failed job details
kubectl get jobs -n datastore --field-selector status.successful=0

# View pod logs from failed job
kubectl logs -n datastore -l job-name=<failed-job-name>

# Describe job for events
kubectl describe job <failed-job-name> -n datastore

Common Issues

1. No ETCD Instances Found

Symptom: Certificate checker reports "No ETCD statefulsets found"

Solution: Verify ETCD StatefulSets exist and match the naming pattern:

kubectl get statefulsets -n datastore | grep -E "ds-|datastore"

2. Certificate Reading Failures

Symptom: "Failed to read certificate" errors in logs

Solution: Check that secrets exist and contain the expected certificate keys:

kubectl get secret <etcd-name>-certs -n datastore -o yaml

3. Telegram Notification Failures

Symptom: Renewal completes but no notifications

Solution: Verify Telegram credentials:

kubectl get secret cert-renewal-secrets -n datastore -o yaml

4. Permission Denied Errors

Symptom: "forbidden" errors in job logs

Solution: Check RBAC configuration:

helm get values etcd-manager -n datastore
kubectl describe role cert-renewal-role -n datastore

Upgrading

# Upgrade with new values
helm upgrade etcd-manager ./etcd-manager -n datastore -f my-values.yaml

# Upgrade specific parameters
helm upgrade etcd-manager ./etcd-manager -n datastore \
  --set certChecker.checkDays=30 \
  --set certRenewal.config.zone=PROD

Uninstallation

# Uninstall the chart
helm uninstall etcd-manager -n datastore

# Optionally remove ConfigMaps
kubectl delete configmap etcd-renewal -n datastore

Architecture

Certificate Check Flow

┌─────────────────────┐
│  CronJob Trigger    │
│  (Daily at 2:00 AM) │
└──────────┬──────────┘
           │
           ▼
┌─────────────────────┐
│  Scan ETCD          │
│  StatefulSets       │
└──────────┬──────────┘
           │
           ▼
┌─────────────────────┐
│  Check Certificate  │
│  Expiration Dates   │
└──────────┬──────────┘
           │
           ▼
┌─────────────────────┐
│  Check Health       │
│  Probe Config       │
└──────────┬──────────┘
           │
           ▼
┌─────────────────────┐
│  Update ConfigMap   │
│  with Results       │
└─────────────────────┘

Certificate Renewal Flow

┌─────────────────────┐
│  CronJob Trigger    │
│  (Daily at 10:00 AM)│
└──────────┬──────────┘
           │
           ▼
┌─────────────────────┐
│  Read ConfigMap     │
│  for Instance List  │
└──────────┬──────────┘
           │
           ▼
┌─────────────────────┐
│  For Each Instance: │
│  - Renew Certs      │
│  - Update Secrets   │
│  - Configure Health │
│  - Restart Pods     │
└──────────┬──────────┘
           │
           ▼
┌─────────────────────┐
│  Send Telegram      │
│  Notification       │
└─────────────────────┘

Security Considerations

  • Secrets are stored in Kubernetes Secrets (base64 encoded)
  • Service accounts use minimal required RBAC permissions
  • CronJobs run with restartPolicy: OnFailure to prevent resource exhaustion
  • Consider using sealed secrets or external secret managers for production

Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Test thoroughly
  5. Submit a pull request

License

[Your License Here]

Support

For issues and questions:

  • GitHub Issues: https://github.com/your-org/etcd-manager/issues
  • Documentation: https://github.com/your-org/etcd-manager/docs
  • Runbook: See ETCD-Leader-Change-Runbook.md

Related Documentation

Deploy etcd-manager with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has etcd-manager on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the chartetcd-manager is pinned at v1.0.0 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below
opentenant validate opentenant.yaml
terraform init && terraform apply