-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace oldest default-backend hourly
- Loading branch information
1 parent
0b49755
commit df7746a
Showing
11 changed files
with
104 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
dependencies: | ||
- name: cron-jobs | ||
repository: https://helm.wyrihaximus.net/ | ||
version: 0.1.2 | ||
digest: sha256:b2f8a780f27427de0b317c3a6d816e404a2b375bfc9d0110f7091849113db031 | ||
generated: "2020-10-16T20:22:03.626863683+02:00" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,8 +4,12 @@ description: A Helm chart for Kubernetes | |
home: https://github.com/wyrihaximusnet/docker-default-backend | ||
icon: https://helm.wyrihaximus.net/images/charts/default-backend.png | ||
type: application | ||
version: 0.1.1 | ||
version: 0.2.0 | ||
appVersion: random | ||
maintainers: | ||
- name: WyriHaximus | ||
email: [email protected] | ||
dependencies: | ||
- name: cron-jobs | ||
version: ^0.1 | ||
repository: https://helm.wyrihaximus.net/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
charts/default-backend/templates/cronjob-role-binding.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{{- if .Values.cron.replaceOldestPodHourly -}} | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: RoleBinding | ||
metadata: | ||
name: {{ include "default-backend.fullname" . }}-recycle-cronjob | ||
namespace: {{ .Release.Namespace }} | ||
labels: | ||
app: {{ include "default-backend.fullname" . }} | ||
appRevision: {{ template "default-backend.nameRevision" . }} | ||
release: {{ include "default-backend.fullname" . }} | ||
releaseRevision: {{ .Release.Revision | quote }} | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: Role | ||
name: {{ include "default-backend.fullname" . }}-recycle-cronjob | ||
subjects: | ||
- kind: ServiceAccount | ||
name: {{ include "default-backend.fullname" . }}-recycle-cronjob | ||
namespace: {{ .Release.Namespace }} | ||
{{ end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{{- if .Values.cron.replaceOldestPodHourly -}} | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: Role | ||
metadata: | ||
name: {{ include "default-backend.fullname" . }}-recycle-cronjob | ||
namespace: {{ .Release.Namespace }} | ||
labels: | ||
app: {{ include "default-backend.fullname" . }} | ||
appRevision: {{ template "default-backend.nameRevision" . }} | ||
release: {{ include "default-backend.fullname" . }} | ||
releaseRevision: {{ .Release.Revision | quote }} | ||
rules: | ||
- apiGroups: [""] | ||
resources: ["pods"] | ||
verbs: ["list", "delete"] | ||
{{ end }} |
13 changes: 13 additions & 0 deletions
13
charts/default-backend/templates/cronjob-service-account.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{{- if .Values.cron.replaceOldestPodHourly -}} | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: {{ include "default-backend.fullname" . }}-recycle-cronjob | ||
namespace: {{ .Release.Namespace }} | ||
labels: | ||
app: {{ include "default-backend.fullname" . }} | ||
appRevision: {{ template "default-backend.nameRevision" . }} | ||
release: {{ include "default-backend.fullname" . }} | ||
releaseRevision: {{ .Release.Revision | quote }} | ||
{{- include "default-backend.labels" . | nindent 4 }} | ||
{{ end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{{- if .Values.cron.replaceOldestPodHourly -}} | ||
{{- include "cron-jobs.cronjob" (fromYaml (.Files.Get "values/cronjob.yaml" | replace "[[fullname]]" (include "default-backend.fullname" .) | replace "[[app]]" (include "default-backend.name" .) | replace "[[release]]" .Release.Name | replace "[[namespace]]" .Release.Namespace)) -}} | ||
{{ end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,9 @@ ingress: | |
|
||
replicas: 2 | ||
|
||
cron: | ||
replaceOldestPodHourly: false | ||
|
||
resources: | ||
limits: | ||
cpu: 75m | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
name: replace-oldest-pod-in-deployment | ||
schedule: "3 * * * *" | ||
container: | ||
command: | ||
- /bin/sh | ||
args: | ||
- -c | ||
- kubectl delete pod $(kubectl get pods --selector=app=[[app]] --selector=release=[[release]] -n [[namespace]] --sort-by=.status.startTime --template '{{range .items}}{{.metadata.name}}{{"\n"}}{{end}}' | head -n 1) -n [[namespace]] | ||
image: | ||
repository: bitnami/kubectl | ||
tag: 1.19 | ||
pullPolicy: IfNotPresent | ||
spec: | ||
serviceAccountName: [[fullname]]-recycle-cronjob | ||
labels: | ||
cronjob: | ||
purpose: housekeeping | ||
jobTemplate: | ||
purpose: housekeeping |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
remote: origin | ||
target-branch: master | ||
chart-dirs: | ||
- charts | ||
chart-repos: | ||
- "WyriHaximusNet=https://helm.wyrihaximus.net" | ||
debug: true |