Перейти к файлу
Michael Grosser 825dd75347
Merge pull request #58 from a7i/grosser/mod3
bump go to 1.17
2022-01-20 16:50:41 -08:00
.github/workflows bump go to 1.17 2022-01-20 15:39:25 -08:00
cmd/remediator Introduce option to control disabling remediators 2021-08-20 15:20:33 -04:00
config Introduce option to control disabling remediators 2021-08-20 15:20:33 -04:00
examples move examples into their own folder to avoid confusion 2019-12-13 14:34:44 -08:00
kubernetes add docker-for-mac support 2020-05-07 15:14:53 -07:00
pkg bump go to 1.17 2022-01-20 15:39:25 -08:00
.gitignore temp 5 mins 2020-10-20 15:31:45 -07:00
.go-version bump go to 1.17 2022-01-20 15:39:25 -08:00
Dockerfile bump go to 1.17 2022-01-20 15:39:25 -08:00
LICENSE Create LICENSE 2019-08-29 18:51:43 -07:00
Makefile remove caller from logs since it always points to shared library anyway 2019-12-17 14:51:46 -06:00
README.md Introduce option to control disabling remediators 2021-08-20 15:20:33 -04:00
Rakefile.rb add docker-for-mac support 2020-05-07 15:14:53 -07:00
go.mod bump go to 1.17 2022-01-20 15:39:25 -08:00
go.sum run go mod tidy for github actions diff 2022-01-20 18:53:32 -05:00

README.md

Kube Remediator Test

Remediators

CrashLoopBackOff Rescheduler

Reschedules CrashLoopBackOff Pod to fix permanent crashes caused by stale init-container/sidecar/configmap

  • Listens to Pod update events and does a Pod list
  • Looks for containers in CrashLoopBackOff with restartCount > 5 (failureThreshold config)
  • Ignores Pods with annotation kube-remediator/CrashLoopBackOffRemediator: "false"
  • Can work in a single namespace, default is all namespaces "" (namespace config)
  • Ignores Pods without ownerReferences (Avoid deleting something which does not come back)

Old Pod Deleter

Deletes Pods with label kube-remediator/OldPodDeleter=true older than 24h

Failed Pods Rescheduler

Reschedules Failed Pods by deleting them, since they are not automatically cleaned up.

  • Listens to Pod update events and does a Pod list
  • Finds pods in Failed status with reason OutOfCpu, OutofMemory.
  • Ignores Pods without ownerReferences (Avoid deleting something which does not come back)
  • Ignores Pods for Jobs because they can be automatically cleaned up.
  • Deletes the pods in failed status after 5 mins to have time to debug

Completed Pods Deleter

Deletes Pods that in Completed status for more than 24h.

Unbound PersistentVolumeClaim cleaner TODO

Deletes PersistentVolumeClaim left behind by deleted StatefulSet, that are not automatically cleaned up otherwise

  • Waits for 7 days(configurable) before deleting
  • Ignores if PersistentVolume has persistentVolumeReclaimPolicy set to Retain

Remediator Policy

You can define a remediator policy to control the following options:

  • disabled_remediators: All remediators are enabled by default unless listed in this option. example:
      {
        "disabled_remediators": ["FailedPodRescheduler"]
      }
    
    This can also be set via an environment variable: DISABLED_REMEDIATORS=OldPodDeleter,FailedPodRescheduler

Deploy

kubectl apply -f kubernetes/rbac.yaml
kubectl apply -f kubernetes/app-server.yml

Configuration options:

  • Deploy provided image to use defaults under config/*
  • Make a new image FROM the provided image and add/remove config/*
  • Overwrite config/* with a mounted ConfigMap

Development

Boot Option A:

Run in local kubernetes with docker-for-mac

rake server

Boot Option B:

Run against local kubernetes cluster with go:

unset GOPATH
go mod vendor # install into local directory instead of global path
make dev # run on cluster from $KUBECONFIG (defaults to ~/.kube/config)

Test

  • Run unit tests: make test
  • Run a single suite: go test -run TestSuiteFailedPodRescheduler github.com/aksgithub/kube_remediator/pkg/remediator
  • Run a single test: comment out all other test in the suite and run the suite. TODO: improve.
# CrashLoopBackOffRemediator: pod is rescheduled after restarting 5 times ?
kubectl apply -f examples/crashloop_pod.yml

# OldPodDeleter: pod is deleted when it gets 24h old ? (best change the 24h in the code to 1min)
kubectl apply -f examples/old_pod.yml

Note: failed expectation in one test can lead to other tests failing. Only run one test when debugging.