crashloop-operator

by slauger

Helm chartv0.1.0App 0.1.0Apache-2.0Verified publisher

Kubernetes operator that scales down workloads stuck in CrashLoopBackOff and similar terminal failure states

About this chart

crashloop-operator

Kubernetes operator that scales down workloads stuck in CrashLoopBackOff and similar terminal failure states

Homepage: https://github.com/slauger/crashloop-operator

Prerequisites

  • Kubernetes 1.29 or newer
  • Helm 3.8 or newer, for OCI registry support

Installation

helm install crashloop-operator \
  oci://ghcr.io/slauger/charts/crashloop-operator \
  --namespace crashloop-system \
  --create-namespace

The chart installs the CrashLoopPolicy CRD from its crds/ directory. Helm does not upgrade or delete CRDs installed that way, so a chart upgrade that changes the CRD needs it applied manually:

kubectl apply -f https://raw.githubusercontent.com/slauger/crashloop-operator/main/config/crd/bases/crashloop-operator.lauger.de_crashlooppolicies.yaml

No policy is created by the chart. The operator does nothing until you create a CrashLoopPolicy; see the project README for an example.

Scope

CrashLoopPolicy is cluster-scoped, so access to it is always granted through a ClusterRole. scope.mode controls how far the operator's workload access reaches:

  • cluster (default) grants workload access across all namespaces.
  • namespace confines workload access to scope.watchNamespace, defaulting to the release namespace, and passes --watch-namespace to the operator.

Uninstalling

helm uninstall crashloop-operator --namespace crashloop-system

Workloads the operator scaled down stay at zero replicas. Scale them back up using the recorded previous replica count:

kubectl scale deployment my-app \
  --replicas="$(kubectl get deployment my-app \
    -o jsonpath='{.metadata.annotations.crashloop-operator\.lauger\.de/previous-replicas}')"

The CRD is not removed by helm uninstall. Delete it explicitly if you want the policies gone too.

Maintainers

NameEmailUrl
Simon Lauger[email protected]https://lauger.de

Requirements

Kubernetes: >=1.29.0-0

Values

KeyTypeDefaultDescription
affinityobject{}Affinity rules for the operator pod.
automountServiceAccountTokenbooltrueMount the ServiceAccount token. The operator talks to the API server, so it needs this; the value exists for policies that require it to be explicit.
extraArgslist[]Extra command line arguments for the operator.
extraEnvlist[]Extra environment variables for the operator container.
fullnameOverridestring""Override the full resource name prefix.
image.digeststring""Image digest. Takes precedence over tag when set, for example sha256:abc....
image.pullPolicystring"IfNotPresent"Image pull policy. IfNotPresent is safe now that the default tag is the immutable appVersion rather than a floating latest.
image.repositorystring"ghcr.io/slauger/crashloop-operator"Operator image repository.
image.tagstring""Image tag. Defaults to the chart appVersion, which pins each chart release to the operator build it was tested with.
imagePullSecretslist[]Image pull secrets for private registries.
leaderElectbooltrueEnable leader election so that only one replica reconciles at a time.
metrics.service.annotationsobject{}Annotations to add to the metrics Service.
metrics.service.enabledboolfalseExpose the controller-runtime metrics endpoint through a Service.
metrics.service.portint8080Service port for metrics.
metrics.serviceMonitor.enabledboolfalseCreate a Prometheus Operator ServiceMonitor. Requires metrics.service.enabled and the monitoring.coreos.com CRDs.
metrics.serviceMonitor.intervalstring"30s"Scrape interval.
metrics.serviceMonitor.labelsobject{}Extra labels for the ServiceMonitor, for Prometheus selector matching.
nameOverridestring""Override the chart name used in resource names.
nodeSelectorobject{}Node selector for the operator pod.
podAnnotationsobject{}Annotations to add to the operator pod.
podDisruptionBudget.enabledboolfalseCreate a PodDisruptionBudget. Only meaningful with replicaCount above 1, since leader election already keeps a single replica from being active twice.
podDisruptionBudget.maxUnavailablestring""Maximum unavailable pods. Mutually exclusive with minAvailable.
podDisruptionBudget.minAvailableint1Minimum available pods. Mutually exclusive with maxUnavailable.
podLabelsobject{}Extra labels to add to the operator pod.
priorityClassNamestring""PriorityClass for the operator pod.
replicaCountint1Number of operator replicas. Leader election makes only one of them active.
resourcesobject{"limits":{"cpu":"500m","memory":"128Mi"},"requests":{"cpu":"10m","memory":"64Mi"}}Resource requests and limits for the operator container.
revisionHistoryLimitint3How many old ReplicaSets to retain for the operator Deployment.
scope.modestring"cluster"Operator scope. cluster watches all namespaces via ClusterRole. namespace confines workload access to a single namespace via Role. CrashLoopPolicy itself is cluster-scoped either way, so policy access is always granted through a ClusterRole.
scope.watchNamespacestring""Namespace to watch when mode is namespace. Defaults to the release namespace when empty.
serviceAccount.annotationsobject{}Annotations to add to the ServiceAccount.
serviceAccount.createbooltrueCreate a ServiceAccount for the operator.
serviceAccount.namestring""Name of the ServiceAccount. Generated from the release name when empty.
tolerationslist[]Tolerations for the operator pod.
topologySpreadConstraintslist[]Topology spread constraints for the operator pod.

Autogenerated from chart metadata using helm-docs v1.14.2

Deploy crashloop-operator with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has crashloop-operator 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 chartcrashloop-operator is pinned at v0.1.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