├── .docker └── config.json ├── install ├── namespace.yaml ├── serviceaccount.yaml ├── cronjob.yaml └── rbac.yaml ├── helm └── kubesweeper │ ├── templates │ ├── namespace.yaml │ ├── serviceaccount.yaml │ ├── service.yaml │ ├── kubesweepereventsource.yaml │ ├── rbac.yaml │ └── _helpers.tpl │ ├── Chart.yaml │ ├── values.yaml │ └── .helmignore ├── images └── cloud_native_labs.png ├── Makefile ├── .travis.yml ├── configs └── config.yaml ├── Dockerfile ├── deploy.sh ├── LICENSE ├── go.mod ├── config.go ├── .gitignore ├── README.md ├── go.sum └── main.go /.docker/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "credsStore": "pass" 3 | } 4 | -------------------------------------------------------------------------------- /install/namespace.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Namespace 3 | metadata: 4 | name: att-cloudnative-labs -------------------------------------------------------------------------------- /helm/kubesweeper/templates/namespace.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Namespace 3 | metadata: 4 | name: {{ .Values.namespace }} -------------------------------------------------------------------------------- /images/cloud_native_labs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/att-cloudnative-labs/kubesweeper/HEAD/images/cloud_native_labs.png -------------------------------------------------------------------------------- /install/serviceaccount.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ServiceAccount 3 | metadata: 4 | name: kubesweeper 5 | namespace: att-cloudnative-labs -------------------------------------------------------------------------------- /helm/kubesweeper/Chart.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | appVersion: "0.0.1" 3 | description: A Helm chart for Kubernetes 4 | name: kubesweeper 5 | version: 0.0.1 6 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | build: 2 | docker build -t kubesweeper . 3 | helm template kubesweeper --set image=kubesweeper | kubectl create -f - 4 | go-build: 5 | go build 6 | -------------------------------------------------------------------------------- /helm/kubesweeper/templates/serviceaccount.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ServiceAccount 3 | metadata: 4 | name: {{ .Values.name }} 5 | namespace: {{ .Values.namespace }} -------------------------------------------------------------------------------- /helm/kubesweeper/values.yaml: -------------------------------------------------------------------------------- 1 | # Default values for kubesweeper. 2 | # This is a YAML-formatted file. 3 | # Declare variables to be passed into your templates. 4 | 5 | name: kubesweeper 6 | image: docker.io/att-cloudnative-labs/kubesweeper:v0.0.1-alpha 7 | cron: 0 17 * * * 8 | namespace: att-cloudnative-labs 9 | -------------------------------------------------------------------------------- /helm/kubesweeper/templates/service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: serving.knative.dev/v1alpha1 2 | kind: Service 3 | metadata: 4 | namespace: {{ .Values.namespace }} 5 | name: {{ .Values.name }} 6 | spec: 7 | runLatest: 8 | configuration: 9 | revisionTemplate: 10 | spec: 11 | container: 12 | image: {{ .Values.image }} 13 | -------------------------------------------------------------------------------- /helm/kubesweeper/templates/kubesweepereventsource.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: sources.eventing.knative.dev/v1alpha1 2 | kind: CronJobSource 3 | metadata: 4 | name: {{ .Values.name }}-source 5 | namespace: {{ .Values.namespace }} 6 | spec: 7 | namespace: {{ .Values.namespace }} 8 | schedule: {{ .Values.cron }} 9 | sink: 10 | apiVersion: serving.knative.dev/v1alpha1 11 | kind: Service 12 | name: {{ .Values.name }} 13 | -------------------------------------------------------------------------------- /helm/kubesweeper/.helmignore: -------------------------------------------------------------------------------- 1 | # Patterns to ignore when building packages. 2 | # This supports shell glob matching, relative path matching, and 3 | # negation (prefixed with !). Only one pattern per line. 4 | .DS_Store 5 | # Common VCS dirs 6 | .git/ 7 | .gitignore 8 | .bzr/ 9 | .bzrignore 10 | .hg/ 11 | .hgignore 12 | .svn/ 13 | # Common backup files 14 | *.swp 15 | *.bak 16 | *.tmp 17 | *~ 18 | # Various IDEs 19 | .project 20 | .idea/ 21 | *.tmproj 22 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | addons: 3 | apt: 4 | packages: 5 | - pass 6 | 7 | go: 8 | - 1.12.x 9 | 10 | script: 11 | - env GO111MODULE=on go build 12 | - echo "$DOCKER_PASSWORD" | docker login docker.pkg.github.com -u "$DOCKER_USERNAME" --password-stdin 13 | - docker build -t docker.pkg.github.com/att-cloudnative-labs/kubesweeper/kubesweeper:latest . 14 | - docker push docker.pkg.github.com/att-cloudnative-labs/kubesweeper/kubesweeper:latest -------------------------------------------------------------------------------- /configs/config.yaml: -------------------------------------------------------------------------------- 1 | reasons: 2 | - reason: "CrashLoopBackOff" 3 | restart_threshold: 100 4 | delete_func_string: "DeleteCrash" 5 | - reason: "ImagePullBackOff" 6 | delete_func_string: "DeleteGeneric" 7 | - reason: "ErrImagePull" 8 | delete_func_string: "DeleteGeneric" 9 | - reason: "Completed" 10 | delete_func_string: "DeleteGeneric" 11 | - reason: "Failed" 12 | delete_func_string: "DeleteGeneric" 13 | day_limit: 90 14 | delete_ingresses: true 15 | delete_services: true 16 | delete_hpas: true 17 | excluded_namespaces: 18 | - exclude-me -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # First stage: Build the Go binary 2 | FROM golang:1.12.1 as builder 3 | 4 | # copy necessary files 5 | COPY /main.go /app/main.go 6 | COPY /config.go /app/config.go 7 | COPY /configs/ /app/configs/ 8 | COPY go.mod /app/go.mod 9 | COPY go.sum /app/go.sum 10 | 11 | WORKDIR /app 12 | 13 | RUN GIT_TERMINAL_PROMPT=1 GOARCH=amd64 GOOS=linux CGO_ENABLED=0 go build --installsuffix cgo --ldflags="-s" -o kubesweeper 14 | 15 | # The second stage: Just what's needed 16 | FROM alpine:3.8 17 | # copy the binary and the settings into the container 18 | COPY --from=builder /app/kubesweeper /app/kubesweeper 19 | COPY --from=builder /app/configs/ /app/configs/ 20 | 21 | WORKDIR /app 22 | 23 | # Run it 24 | ENTRYPOINT ["./kubesweeper"] -------------------------------------------------------------------------------- /deploy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | # init key for pass 6 | gpg --batch --gen-key <<-EOF ; echo $(gpg --no-auto-check-trustdb --list-secret-keys | grep ^sec | cut -d/ -f2 | cut -d" " -f1) ; pass init $(gpg --no-auto-check-trustdb --list-secret-keys | grep ^sec | cut -d/ -f2 | cut -d" " -f1) 7 | %echo Generating a standard key 8 | Key-Type: DSA 9 | Key-Length: 1024 10 | Subkey-Type: ELG-E 11 | Subkey-Length: 1024 12 | Name-Real: Meshuggah Rocks 13 | Name-Email: meshuggah@example.com 14 | Expire-Date: 0 15 | # Do a commit here, so that we can later print "done" :-) 16 | %commit 17 | %echo done 18 | EOF 19 | 20 | echo "$DOCKER_PASSWORD" | docker login docker.pkg.github.com --username "$DOCKER_USERNAME" --password-stdin 21 | 22 | if [ "$(command -v docker-credential-pass)" = "" ]; then 23 | docker run --rm -itv sh -c "cp /go/bin/docker-credential-pass /src" 24 | fi -------------------------------------------------------------------------------- /install/cronjob.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: batch/v1beta1 2 | kind: CronJob 3 | metadata: 4 | name: kubesweeper 5 | namespace: att-cloudnative-labs 6 | spec: 7 | concurrencyPolicy: Allow 8 | failedJobsHistoryLimit: 1 9 | jobTemplate: 10 | spec: 11 | template: 12 | spec: 13 | serviceAccountName: kubesweeper 14 | containers: 15 | - args: 16 | image: docker.pkg.github.com/att-cloudnative-labs/kubesweeper/kubesweeper:latest 17 | imagePullPolicy: Always 18 | name: kubesweeper 19 | resources: {} 20 | terminationMessagePath: /dev/termination-log 21 | terminationMessagePolicy: File 22 | dnsPolicy: ClusterFirst 23 | restartPolicy: OnFailure 24 | schedulerName: default-scheduler 25 | securityContext: {} 26 | terminationGracePeriodSeconds: 30 27 | schedule: '0 10 * * *' 28 | successfulJobsHistoryLimit: 3 29 | suspend: false 30 | -------------------------------------------------------------------------------- /helm/kubesweeper/templates/rbac.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: rbac.authorization.k8s.io/v1 2 | kind: ClusterRole 3 | metadata: 4 | name: {{ .Values.name }} 5 | rules: 6 | - apiGroups: 7 | - "apps" 8 | resources: 9 | - deployments 10 | - replicasets 11 | - pods 12 | verbs: 13 | - get 14 | - list 15 | - watch 16 | - update 17 | - patch 18 | - delete 19 | - apiGroups: 20 | - "" 21 | resources: 22 | - deployments 23 | - replicasets 24 | - pods 25 | verbs: 26 | - get 27 | - list 28 | - watch 29 | - update 30 | - patch 31 | - delete 32 | --- 33 | apiVersion: rbac.authorization.k8s.io/v1 34 | kind: ClusterRoleBinding 35 | metadata: 36 | name: {{ .Values.name }} 37 | roleRef: 38 | apiGroup: rbac.authorization.k8s.io 39 | kind: ClusterRole 40 | name: {{ .Values.name }} 41 | subjects: 42 | - kind: ServiceAccount 43 | name: {{ .Values.name }} 44 | namespace: {{ .Values.namespace }} -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 AT&T Intellectual Property 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /helm/kubesweeper/templates/_helpers.tpl: -------------------------------------------------------------------------------- 1 | {{/* vim: set filetype=mustache: */}} 2 | {{/* 3 | Expand the name of the chart. 4 | */}} 5 | {{- define "kubernetes-deployment-crawler.name" -}} 6 | {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} 7 | {{- end -}} 8 | 9 | {{/* 10 | Create a default fully qualified app name. 11 | We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). 12 | If release name contains chart name it will be used as a full name. 13 | */}} 14 | {{- define "kubernetes-deployment-crawler.fullname" -}} 15 | {{- if .Values.fullnameOverride -}} 16 | {{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} 17 | {{- else -}} 18 | {{- $name := default .Chart.Name .Values.nameOverride -}} 19 | {{- if contains $name .Release.Name -}} 20 | {{- .Release.Name | trunc 63 | trimSuffix "-" -}} 21 | {{- else -}} 22 | {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} 23 | {{- end -}} 24 | {{- end -}} 25 | {{- end -}} 26 | 27 | {{/* 28 | Create chart name and version as used by the chart label. 29 | */}} 30 | {{- define "kubernetes-deployment-crawler.chart" -}} 31 | {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} 32 | {{- end -}} 33 | -------------------------------------------------------------------------------- /install/rbac.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: rbac.authorization.k8s.io/v1 2 | kind: ClusterRole 3 | metadata: 4 | name: kubesweeper 5 | rules: 6 | - apiGroups: 7 | - apps 8 | resources: 9 | - deployments 10 | - replicasets 11 | - pods 12 | verbs: 13 | - get 14 | - list 15 | - watch 16 | - update 17 | - patch 18 | - delete 19 | - apiGroups: 20 | - "" 21 | resources: 22 | - deployments 23 | - replicasets 24 | - pods 25 | - ingresses 26 | - services 27 | verbs: 28 | - get 29 | - list 30 | - watch 31 | - update 32 | - patch 33 | - delete 34 | - apiGroups: 35 | - networking.k8s.io 36 | - extensions 37 | resources: 38 | - ingresses 39 | verbs: 40 | - get 41 | - list 42 | - watch 43 | - update 44 | - patch 45 | - delete 46 | - apiGroups: 47 | - autoscaling 48 | resources: 49 | - horizontalpodautoscalers 50 | verbs: 51 | - get 52 | - list 53 | - watch 54 | - update 55 | - patch 56 | - delete 57 | --- 58 | apiVersion: rbac.authorization.k8s.io/v1 59 | kind: ClusterRoleBinding 60 | metadata: 61 | name: kubesweeper 62 | roleRef: 63 | apiGroup: rbac.authorization.k8s.io 64 | kind: ClusterRole 65 | name: kubesweeper 66 | subjects: 67 | - kind: ServiceAccount 68 | name: kubesweeper 69 | namespace: att-cloudnative-labs -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/att-cloudnative-labs/kubesweeper 2 | 3 | go 1.12 4 | 5 | require ( 6 | github.com/docker/docker-credential-helpers v0.6.3 // indirect 7 | github.com/ghodss/yaml v1.0.0 // indirect 8 | github.com/gogo/protobuf v1.2.1 // indirect 9 | github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b // indirect 10 | github.com/golang/protobuf v1.3.1 // indirect 11 | github.com/google/btree v1.0.0 // indirect 12 | github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf // indirect 13 | github.com/googleapis/gnostic v0.2.0 // indirect 14 | github.com/gregjones/httpcache v0.0.0-20190212212710-3befbb6ad0cc // indirect 15 | github.com/json-iterator/go v1.1.6 // indirect 16 | github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect 17 | github.com/modern-go/reflect2 v1.0.1 // indirect 18 | github.com/peterbourgon/diskv v2.0.1+incompatible // indirect 19 | github.com/spf13/viper v1.3.2 20 | golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c // indirect 21 | golang.org/x/net v0.0.0-20190328230028-74de082e2cca // indirect 22 | golang.org/x/oauth2 v0.0.0-20190319182350-c85d3e98c914 // indirect 23 | golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 // indirect 24 | gopkg.in/inf.v0 v0.9.1 // indirect 25 | k8s.io/api v0.0.0-20190222213804-5cb15d344471 26 | k8s.io/apimachinery v0.0.0-20190221213512-86fb29eff628 27 | k8s.io/client-go v10.0.0+incompatible 28 | k8s.io/klog v0.2.0 // indirect 29 | sigs.k8s.io/yaml v1.1.0 // indirect 30 | ) 31 | -------------------------------------------------------------------------------- /config.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "github.com/spf13/viper" 5 | "log" 6 | "os" 7 | "strings" 8 | ) 9 | 10 | // make this config object available outside 11 | var ConfigObj = KleanerConfig{} 12 | 13 | // This map would need to be updated to account for any other behavior we would want to enable 14 | // The keys in this map have to map directly to the DeleteFuncString in the SweeperConfigDetails struct 15 | var funcMap = map[string]DeleteFunc{ 16 | "DeleteCrash": DeleteCrash, 17 | "DeleteGeneric": DeleteGeneric, 18 | } 19 | 20 | /** 21 | * This is the parent config object 22 | */ 23 | type KleanerConfig struct { 24 | Reasons []SweeperConfigDetails `mapstructure:"reasons"` 25 | DayLimit int `mapstructure:"day_limit"` 26 | DeleteIngresses bool `mapstructure:"delete_ingresses"` 27 | DeleteServices bool `mapstructure:"delete_services"` 28 | DeleteHpas bool `mapstructure:"delete_hpas"` 29 | ExcludedNamespaces []string `mapstructure:"excluded_namespaces"` 30 | } 31 | 32 | /** 33 | * This is the object that holds the necessary information 34 | */ 35 | type SweeperConfigDetails struct { 36 | Reason string `mapstructure:"reason"` 37 | RestartThreshold int `mapstructure:"restart_threshold,omitempty"` 38 | DeleteFuncString string `mapstructure:"delete_func_string"` 39 | DeleteFunction DeleteFunc 40 | } 41 | 42 | func (dc *KleanerConfig) SetFunctions(fnMap map[string]DeleteFunc) { 43 | for i, reason := range dc.Reasons { 44 | // get the appropriate function out of the map 45 | val, ok := fnMap[reason.DeleteFuncString] 46 | if ok { 47 | // add the appropriate function call to the referenced object 48 | dc.Reasons[i].DeleteFunction = val 49 | } 50 | } 51 | } 52 | 53 | func init() { 54 | v := viper.New() 55 | 56 | // we'll read config in from YAML 57 | v.SetConfigType("yaml") 58 | 59 | // The config file name is config.yaml 60 | v.SetConfigName("config") 61 | 62 | // Just in case we want to set another directory via an environment variable 63 | configDir := os.Getenv("GO_CONFIG_DIR") 64 | if len(configDir) > 0 { 65 | v.AddConfigPath(configDir) 66 | } 67 | 68 | v.AddConfigPath("./configs") 69 | // read the config file into memory 70 | 71 | v.AutomaticEnv() 72 | v.SetEnvKeyReplacer(strings.NewReplacer(".", "_")) 73 | 74 | err := v.ReadInConfig() 75 | if err != nil { 76 | log.Fatal(err.Error()) 77 | } 78 | 79 | // unmarshal yaml file into ConfigObj member 80 | err = v.Unmarshal(&ConfigObj) 81 | 82 | if err != nil { 83 | log.Fatal(err.Error()) 84 | } 85 | 86 | // this is necessary to assign the appropriate functions to the right objects 87 | ConfigObj.SetFunctions(funcMap) 88 | } 89 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by .ignore support plugin (hsz.mobi) 2 | ### Eclipse template 3 | 4 | .metadata 5 | bin/ 6 | tmp/ 7 | *.tmp 8 | *.bak 9 | *.swp 10 | *~.nib 11 | local.properties 12 | .settings/ 13 | .loadpath 14 | .recommenders 15 | 16 | # External tool builders 17 | .externalToolBuilders/ 18 | 19 | # Locally stored "Eclipse launch configurations" 20 | *.launch 21 | 22 | # PyDev specific (Python IDE for Eclipse) 23 | *.pydevproject 24 | 25 | # CDT-specific (C/C++ Development Tooling) 26 | .cproject 27 | 28 | # CDT- autotools 29 | .autotools 30 | 31 | # Java annotation processor (APT) 32 | .factorypath 33 | 34 | # PDT-specific (PHP Development Tools) 35 | .buildpath 36 | 37 | # sbteclipse plugin 38 | .target 39 | 40 | # Tern plugin 41 | .tern-project 42 | 43 | # TeXlipse plugin 44 | .texlipse 45 | 46 | # STS (Spring Tool Suite) 47 | .springBeans 48 | 49 | # Code Recommenders 50 | .recommenders/ 51 | 52 | # Annotation Processing 53 | .apt_generated/ 54 | 55 | # Scala IDE specific (Scala & Java development for Eclipse) 56 | .cache-main 57 | .scala_dependencies 58 | .worksheet 59 | ### Go template 60 | # Binaries for programs and plugins 61 | *.exe 62 | *.exe~ 63 | *.dll 64 | *.so 65 | *.dylib 66 | 67 | # Test binary, build with `go test -c` 68 | *.test 69 | 70 | # Output of the go coverage tool, specifically when used with LiteIDE 71 | *.out 72 | ### JetBrains template 73 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm 74 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 75 | 76 | # User-specific stuff 77 | .idea/**/workspace.xml 78 | .idea/**/tasks.xml 79 | .idea/**/usage.statistics.xml 80 | .idea/**/dictionaries 81 | .idea/**/shelf 82 | 83 | # Sensitive or high-churn files 84 | .idea/**/dataSources/ 85 | .idea/**/dataSources.ids 86 | .idea/**/dataSources.local.xml 87 | .idea/**/sqlDataSources.xml 88 | .idea/**/dynamic.xml 89 | .idea/**/uiDesigner.xml 90 | .idea/**/dbnavigator.xml 91 | 92 | # Gradle 93 | .idea/**/gradle.xml 94 | .idea/**/libraries 95 | 96 | # Gradle and Maven with auto-import 97 | # When using Gradle or Maven with auto-import, you should exclude module files, 98 | # since they will be recreated, and may cause churn. Uncomment if using 99 | # auto-import. 100 | # .idea/modules.xml 101 | # .idea/*.iml 102 | # .idea/modules 103 | 104 | # CMake 105 | cmake-build-*/ 106 | 107 | # Mongo Explorer plugin 108 | .idea/**/mongoSettings.xml 109 | 110 | # File-based project format 111 | *.iws 112 | 113 | # IntelliJ 114 | out/ 115 | 116 | # mpeltonen/sbt-idea plugin 117 | .idea_modules/ 118 | 119 | # JIRA plugin 120 | atlassian-ide-plugin.xml 121 | 122 | # Cursive Clojure plugin 123 | .idea/replstate.xml 124 | 125 | # Crashlytics plugin (for Android Studio and IntelliJ) 126 | com_crashlytics_export_strings.xml 127 | crashlytics.properties 128 | crashlytics-build.properties 129 | fabric.properties 130 | 131 | # Editor-based Rest Client 132 | .idea/httpRequests 133 | ### VisualStudioCode template 134 | .vscode/* 135 | !.vscode/settings.json 136 | !.vscode/tasks.json 137 | !.vscode/launch.json 138 | !.vscode/extensions.json 139 | 140 | /.idea/ 141 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Kubesweeper 2 | 3 | Automatically iterates through resources in a lab Kubernetes cluster and acts according to [certain conditions outlined here](#configuration-defaults). As of now, Kubesweeper will delete ```Deployments``` and their associated resources if the waiting reason and/or pod restart count and/or deployment age dictates. Additionally, you can use configurable Boolean environment variables to choose to delete associated ```Services```, ```Ingresses```, and ```HorizontalPodAutoscalers```. 4 | 5 | If your lab Kubernetes clusters are filling up with non-Running pods, then Kubesweeper's automatic deletion 6 | can assist. Future iterations of this project can involve other actions based on crawling through Kubernetes cluster resources, such as generating reports per namespace without actually deleting. 7 | 8 | Please note that Kubesweeper is intended for use in lab—not production, customer-facing—clusters. Any automated cleanup in such an environment is unadvisable, at least for Kubesweeper. 9 | 10 |
11 |
12 |
13 |
14 |
15 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
118 |
119 |
120 |
121 |