-
-
Notifications
You must be signed in to change notification settings - Fork 182
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
474: Bugfix/cronjob restartpolicy check r=zegl a=kmarteaux ``` RELNOTE: Implement New Rule: CronJob resource requires Pod restartPolicy set to Never or OnFailure #471 ``` Co-authored-by: Kenneth Martau <kenneth.martau@gmail.com>
- Loading branch information
Showing
9 changed files
with
185 additions
and
0 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
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,28 @@ | ||
kind: CronJob | ||
apiVersion: batch/v1 | ||
metadata: | ||
namespace: cronjobs | ||
name: pwsh-test | ||
spec: | ||
jobTemplate: | ||
spec: | ||
template: | ||
spec: | ||
containers: | ||
- name: pwsh | ||
imagePullPolicy: Always | ||
image: mcr.microsoft.com/powershell:7 | ||
command: | ||
- pwsh | ||
- -Command | ||
- Start-Sleep -Seconds 5 | ||
securityContext: | ||
readOnlyRootFilesystem: true | ||
resources: | ||
limits: | ||
ephemeral-storage: 50Mi | ||
requests: | ||
ephemeral-storage: 50Mi | ||
RestartPolicy: Once | ||
schedule: '0/1 * * * *' | ||
startingDeadlineSeconds: 5 |
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,18 @@ | ||
apiVersion: batch/v1 | ||
kind: CronJob | ||
metadata: | ||
name: hello | ||
spec: | ||
schedule: "* * * * *" | ||
jobTemplate: | ||
spec: | ||
template: | ||
spec: | ||
containers: | ||
- name: hello | ||
image: busybox:1.28 | ||
imagePullPolicy: IfNotPresent | ||
command: | ||
- /bin/sh | ||
- -c | ||
- date; echo Hello from the Kubernetes cluster |
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 @@ | ||
apiVersion: batch/v1 | ||
kind: CronJob | ||
metadata: | ||
name: hello | ||
spec: | ||
schedule: "* * * * *" | ||
jobTemplate: | ||
spec: | ||
template: | ||
spec: | ||
containers: | ||
- name: hello | ||
image: busybox:1.28 | ||
imagePullPolicy: IfNotPresent | ||
command: | ||
- /bin/sh | ||
- -c | ||
- date; echo Hello from the Kubernetes cluster | ||
restartPolicy: OnFailure |
28 changes: 28 additions & 0 deletions
28
score/testdata/cronjob-batchv1beta1-restartpolicy-invalid.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,28 @@ | ||
kind: CronJob | ||
apiVersion: batch/v1beta1 | ||
metadata: | ||
namespace: cronjobs | ||
name: pwsh-test | ||
spec: | ||
jobTemplate: | ||
spec: | ||
template: | ||
spec: | ||
containers: | ||
- name: pwsh | ||
imagePullPolicy: Always | ||
image: mcr.microsoft.com/powershell:7 | ||
command: | ||
- pwsh | ||
- -Command | ||
- Start-Sleep -Seconds 5 | ||
securityContext: | ||
readOnlyRootFilesystem: true | ||
resources: | ||
limits: | ||
ephemeral-storage: 50Mi | ||
requests: | ||
ephemeral-storage: 50Mi | ||
RestartPolicy: OnFailure | ||
schedule: '0/1 * * * *' | ||
startingDeadlineSeconds: 5 |
18 changes: 18 additions & 0 deletions
18
score/testdata/cronjob-batchv1beta1-restartpolicy-not-set.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,18 @@ | ||
apiVersion: batch/v1beta1 | ||
kind: CronJob | ||
metadata: | ||
name: hello | ||
spec: | ||
schedule: "* * * * *" | ||
jobTemplate: | ||
spec: | ||
template: | ||
spec: | ||
containers: | ||
- name: hello | ||
image: busybox:1.28 | ||
imagePullPolicy: IfNotPresent | ||
command: | ||
- /bin/sh | ||
- -c | ||
- date; echo Hello from the Kubernetes cluster |
19 changes: 19 additions & 0 deletions
19
score/testdata/cronjob-batchv1beta1-restartpolicy-valid.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,19 @@ | ||
apiVersion: batch/v1beta1 | ||
kind: CronJob | ||
metadata: | ||
name: hello | ||
spec: | ||
schedule: "* * * * *" | ||
jobTemplate: | ||
spec: | ||
template: | ||
spec: | ||
containers: | ||
- name: hello | ||
image: busybox:1.28 | ||
imagePullPolicy: IfNotPresent | ||
command: | ||
- /bin/sh | ||
- -c | ||
- date; echo Hello from the Kubernetes cluster | ||
restartPolicy: OnFailure |