-
-
Notifications
You must be signed in to change notification settings - Fork 177
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support batch/v1/CronJob from Kubernetes 1.21
Recommending to use the batch/v1 of CronJobs from Kubernetes 1.21 and later, as controlled by the --kubernetes-version flag. Updates #360
- Loading branch information
Showing
17 changed files
with
250 additions
and
41 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,35 @@ | ||
package cronjob | ||
|
||
import ( | ||
ks "github.com/zegl/kube-score/domain" | ||
v1 "k8s.io/api/batch/v1" | ||
corev1 "k8s.io/api/core/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
type CronJobV1 struct { | ||
Obj v1.CronJob | ||
Location ks.FileLocation | ||
} | ||
|
||
func (c CronJobV1) StartingDeadlineSeconds() *int64 { | ||
return c.Obj.Spec.StartingDeadlineSeconds | ||
} | ||
|
||
func (c CronJobV1) FileLocation() ks.FileLocation { | ||
return c.Location | ||
} | ||
|
||
func (c CronJobV1) GetTypeMeta() metav1.TypeMeta { | ||
return c.Obj.TypeMeta | ||
} | ||
|
||
func (c CronJobV1) GetObjectMeta() metav1.ObjectMeta { | ||
return c.Obj.ObjectMeta | ||
} | ||
|
||
func (c CronJobV1) GetPodTemplateSpec() corev1.PodTemplateSpec { | ||
t := c.Obj.Spec.JobTemplate.Spec.Template | ||
t.ObjectMeta.Namespace = c.Obj.ObjectMeta.Namespace | ||
return t | ||
} |
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,35 @@ | ||
package cronjob | ||
|
||
import ( | ||
ks "github.com/zegl/kube-score/domain" | ||
"k8s.io/api/batch/v1beta1" | ||
corev1 "k8s.io/api/core/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
type CronJobV1beta1 struct { | ||
Obj v1beta1.CronJob | ||
Location ks.FileLocation | ||
} | ||
|
||
func (c CronJobV1beta1) StartingDeadlineSeconds() *int64 { | ||
return c.Obj.Spec.StartingDeadlineSeconds | ||
} | ||
|
||
func (c CronJobV1beta1) FileLocation() ks.FileLocation { | ||
return c.Location | ||
} | ||
|
||
func (c CronJobV1beta1) GetTypeMeta() metav1.TypeMeta { | ||
return c.Obj.TypeMeta | ||
} | ||
|
||
func (c CronJobV1beta1) GetObjectMeta() metav1.ObjectMeta { | ||
return c.Obj.ObjectMeta | ||
} | ||
|
||
func (c CronJobV1beta1) GetPodTemplateSpec() corev1.PodTemplateSpec { | ||
t := c.Obj.Spec.JobTemplate.Spec.Template | ||
t.ObjectMeta.Namespace = c.Obj.ObjectMeta.Namespace | ||
return t | ||
} |
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
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
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: "*/1 * * * *" | ||
jobTemplate: | ||
spec: | ||
template: | ||
spec: | ||
containers: | ||
- name: hello | ||
image: busybox | ||
args: | ||
- /bin/sh | ||
- -c | ||
- date; echo Hello from the Kubernetes cluster | ||
restartPolicy: OnFailure |
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: "*/1 * * * *" | ||
startingDeadlineSeconds: 100 | ||
jobTemplate: | ||
spec: | ||
template: | ||
spec: | ||
containers: | ||
- name: hello | ||
image: busybox | ||
args: | ||
- /bin/sh | ||
- -c | ||
- date; echo Hello from the Kubernetes cluster | ||
restartPolicy: OnFailure |
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 @@ | ||
apiVersion: batch/v1 | ||
kind: CronJob | ||
metadata: | ||
name: cronjob-test | ||
spec: | ||
schedule: "1 3 * * *" | ||
jobTemplate: | ||
spec: | ||
template: | ||
spec: | ||
containers: | ||
- name: foo | ||
image: bar:latest |
File renamed without changes.
File renamed without changes.