charts

CronSchedules Charts

This repository contains Helm charts for various CronJob and scheduling-related Kubernetes operators and applications.

Charts

CronJob Scale Down Operator

This chart installs the CronJob Scale Down Operator on a Kubernetes cluster using the Helm package manager.

The operator provides two main features:

  1. Automatic Scaling: Scale down Deployments and StatefulSets during specific time windows
  2. Resource Cleanup: Automatically clean up test resources based on annotations and schedules

Prerequisites

Installation

Add Helm Repository

helm repo add cronschedules https://cronschedules.github.io/charts
helm repo update

Install Chart

# Install the chart
helm install cronjob-scale-down-operator cronschedules/cronjob-scale-down-operator

Install from Local Chart

# Clone the repository
git clone https://github.com/cronschedules/charts.git
cd charts

# Install the chart
helm install cronjob-scale-down-operator ./cronjob-scale-down-operator

Install with Custom Values

helm install cronjob-scale-down-operator cronschedules/cronjob-scale-down-operator \
  --set image.tag=0.3.0 \
  --set resources.requests.memory=128Mi

Configuration

The following table lists the configurable parameters and their default values:

Parameter Description Default
replicaCount Number of operator replicas 1
image.repository Container image repository cronschedules/z4ck404/cronjob-scale-down-operator
image.tag Container image tag 0.3.0
image.pullPolicy Image pull policy IfNotPresent
serviceAccount.create Create service account true
rbac.create Create RBAC resources true
resources.limits.cpu CPU limit 500m
resources.limits.memory Memory limit 128Mi
resources.requests.cpu CPU request 10m
resources.requests.memory Memory request 64Mi
metrics.enabled Enable metrics service true
leaderElection.enabled Enable leader election true

Usage

After installation, you can create CronJobScaleDown resources for different use cases:

Automatic Scaling

Scale down resources during specific time windows:

apiVersion: cronschedules.elbazi.co/v1
kind: CronJobScaleDown
metadata:
  name: my-scaler
  namespace: default
spec:
  targetRef:
    name: my-deployment
    namespace: default
    kind: Deployment
    apiVersion: apps/v1
  scaleDownSchedule: "0 0 22 * * *"  # 10 PM daily
  scaleUpSchedule: "0 0 6 * * *"     # 6 AM daily
  timeZone: "UTC"

Resource Cleanup Only

Clean up test resources based on annotations:

apiVersion: cronschedules.elbazi.co/v1
kind: CronJobScaleDown
metadata:
  name: cleanup-only
  namespace: default
spec:
  cleanupSchedule: "0 0 */6 * * *"    # Every 6 hours
  cleanupConfig:
    annotationKey: "test.elbazi.co/cleanup-after"
    resourceTypes:
      - "Deployment"
      - "Service"
      - "ConfigMap"
    labelSelector:
      app.kubernetes.io/created-by: "test"
    dryRun: true  # Set to false to actually delete resources
  timeZone: "UTC"

Combined Scaling and Cleanup

Use both features in one resource:

apiVersion: cronschedules.elbazi.co/v1
kind: CronJobScaleDown
metadata:
  name: combined-example
  namespace: default
spec:
  targetRef:
    name: my-deployment
    namespace: default
    kind: Deployment
  scaleDownSchedule: "0 0 22 * * *"  # 10 PM daily
  scaleUpSchedule: "0 0 6 * * *"     # 6 AM daily
  cleanupSchedule: "0 0 2 * * *"     # 2 AM daily
  cleanupConfig:
    annotationKey: "test.elbazi.co/cleanup-after"
    resourceTypes: ["ConfigMap", "Secret"]
    dryRun: false
  timeZone: "UTC"

Uninstallation

helm uninstall cronjob-scale-down-operator

Development

To render templates locally:

helm template cronjob-scale-down-operator ./cronjob-scale-down-operator

To validate the chart:

helm lint ./cronjob-scale-down-operator