Skip to content

Commit

Permalink
Merge pull request #54 from target/cron
Browse files Browse the repository at this point in the history
address cron job confusion and update dependencies
  • Loading branch information
brianberzins authored Mar 27, 2020
2 parents 58025dc + b364db3 commit 8b54fd1
Show file tree
Hide file tree
Showing 19 changed files with 230 additions and 227 deletions.
18 changes: 12 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,36 @@
# pod-reaper: kills pods dead

### 2.6.0
- adjusted cron `SCHEDULE` for optional seconds, non optional day of week

### 2.5.0
- added multiple logging formats

### 2.4.1
- added configurable `LOG_LEVEL`

### 2.4.0
- added `UNREADY` rule to kill pods based on duration of time not passing readiness checks

### 2.3.0
- added `POD_STATUSES` rule (can now filter/kill `Evicted` pods)

### 2.2.0

- added configurable `GRACE_PERIOD` to control soft vs hard pod kills

### 2.1.0

- Added logging via [logrus](https://github.com/sirupsen/logrus)

## 2.0.0

- removed `POLL_INTERVAL` environment variable in favor of cron schedule
- added `SCHEDULE` environment variable to control when pods are inspected for reaping
- makes use of https://godoc.org/github.com/robfig/cron
- refactored packages for clarity
- testing refactor for clarity

### 1.1.0

- added ability to only reap pods with specified labels

## 1.0.0

- redesign of the reaper to be built on modular rules
- rules must implement two methods `load()` and `shouldReap(pod)`
- rules determine whether or not they get loaded at runtime via environment variables
Expand Down
14 changes: 6 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
# Build
FROM golang:1.9 AS build
FROM golang:1.14 AS build
WORKDIR /go/src/github.com/target/pod-reaper
ENV CGO_ENABLED=0 GOOS=linux
RUN go get github.com/Masterminds/glide
COPY glide.* ./
RUN glide install --strip-vendor
COPY reaper/*.go ./reaper/
COPY rules/*.go ./rules/
RUN go test $(glide nv)
RUN go build -o pod-reaper -a -installsuffix go ./reaper
COPY ./ ./
RUN go get github.com/Masterminds/glide \
&& glide install --strip-vendor \
&& go test $(glide nv) \
&& go build -o pod-reaper -a -installsuffix go ./reaper

# Application
FROM scratch
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Controls the grace period between a soft pod termination and a hard termination.

Default value: "@every 1m"

Controls how frequently pod-reaper queries kubernetes for pods. The format follows the upstream cron library https://godoc.org/github.com/robfig/cron. For most use cases, the interval format `@every 1h2m3s` is sufficient. But more complex use cases can make use of the `* * * * *` notation.
Controls how frequently pod-reaper queries kubernetes for pods. The format follows the upstream cron library https://godoc.org/github.com/robfig/cron. For most use cases, the interval format `@every 1h2m3s` is sufficient. But more complex use cases can make use of the `* * * * *` notation. The cron parser used can optionally support seconds if a sixth parameter is add. `12 * * * * *` for example will run on the 12th second of every minute.

### `RUN_DURATION`

Expand Down
15 changes: 12 additions & 3 deletions examples/complex-deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ spec:
# randomly flag 30% of pods whenever they are checked
- name: CHAOS_CHANCE
value: ".3"
# increase logging
- name: LOG_LEVEL
value: debug

- name: chaos # reaper 2
image: target/pod-reaper
Expand All @@ -110,12 +113,15 @@ spec:
cpu: 20m
memory: 20Mi
env:
# cron job based schedule
# cron job based schedule (with seconds)
- name: SCHEDULE
value: "0/5 * * * *"
value: "15 * * * * *"
# randomly flag 5% of pods whenever they are checked
- name: CHAOS_CHANCE
value: ".05"
# increase logging
- name: LOG_LEVEL
value: debug

- name: error # reaper 3
image: target/pod-reaper
Expand All @@ -130,7 +136,10 @@ spec:
env:
# check pods every 3 min
- name: SCHEDULE
value: "@every 3m"
value: "0/3 * * * *"
# check if container status is in the set { Error, ErrImagePull, ImagePullBackOff }
- name: CONTAINER_STATUSES
value: "Error,ErrImagePull,ImagePullBackOff"
# increase logging
- name: LOG_LEVEL
value: debug
Loading

0 comments on commit 8b54fd1

Please sign in to comment.