-
Notifications
You must be signed in to change notification settings - Fork 274
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrate the cron container from sidecar to K8s CronJob #703
Open
MartinKirchner
wants to merge
10
commits into
nextcloud:main
Choose a base branch
from
MartinKirchner:feature/cronjob
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
bc048eb
Migrate the cron container from sidecar to K8s CronJob
a874bc4
Extract labels and metainfo blocks of deployment and cronjob to helpers
0ba5f81
Move definition of volumes for deployment and cronjob to helpers
d432abe
Group identical definitions of deployment and cronJob
eef3eb5
Extract common pod definitions of deployment and cronjob to helpers
fbb261e
Move imagePullSecret to helper template "nextcloud.pod.commons"
ffff26c
Extract cronjob command to values.yaml
69d1c6d
Extract the nextcloud container definition to a helper template
fe88c1a
Add suffix "-cron" to cronJob so that the pods can be distinguished
fbc0286
Make sure matchLables of Deployment and Cronjob are different
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Large diffs are not rendered by default.
Oops, something went wrong.
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,25 @@ | ||
--- | ||
{{- if .Values.cronjob.enabled }} | ||
|
||
apiVersion: batch/v1 | ||
kind: CronJob | ||
metadata: | ||
name: {{ template "nextcloud.fullname" . }}-cron | ||
labels: | ||
{{- include "nextcloud.pods.labels" ( dict "component" "cronjob" "rootContext" $ ) | nindent 4 }} | ||
spec: | ||
schedule: "*/5 * * * *" | ||
concurrencyPolicy: Forbid | ||
failedJobsHistoryLimit: 5 | ||
jobTemplate: | ||
{{- include "nextcloud.deployment.template.metadata" ( dict "component" "cronjob" "rootContext" $ ) | nindent 4 }} | ||
spec: | ||
template: | ||
{{- include "nextcloud.deployment.template.metadata" ( dict "component" "cronjob" "rootContext" $ ) | nindent 8 }} | ||
spec: | ||
containers: | ||
{{- $containerName := printf "%s-cron" .Chart.Name }} | ||
{{- include "nextcloud.container" ( dict "containerName" $containerName "rootContext" $ "context" .Values.cronjob ) | nindent 10 }} | ||
{{- include "nextcloud.pod.commons" . | nindent 10 }} | ||
restartPolicy: OnFailure | ||
{{- end }}{{/* end-if cronjob.enabled */}} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The following is more common in helm-charts.
Where you have to add
app.kubernetes.io/component: app
manuelle.PS: Maybe you should move such changes into smaller PRs for easiert review (and merge)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wrenix
Thanks for your comment.
To make the review easier I used a commit for every step of the refactoring over smaller PRs as it makes only sense to me if get everything merged in. In commit a874bc4 you can see that I simply moved the labels as they were from the deployment.yaml
to
helpers.tpl`. So I guess someone had good reasoning to define the labels like this.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you must differentiate the labels used by the deployment to select its pod vs the labels on the cronjob pods, otherwise cronjob pods would show up as pods of a deployment and might get controlled by the replicaset controller, right? So
app
inapp.kubernetes.io/component: app
should probably becronjob
for cronjob pods or so.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pschichtel Good that you noticed this! Thank you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MartinKirchner as a Co-Maintainer i could easier merge such single changes / small PRs.
For the change from sidecar to cronjob itself, i believe we need a longer discussion, see #683
PS: i like to have an
_helper
for the labels and that could be in this week if i got a easy to review.