Fixup jobs, roles...
This commit is contained in:
@@ -78,7 +78,7 @@ func buildCrontab(deployName string, deployment *helm.Deployment, s *types.Servi
|
|||||||
cmd = podget + cmd
|
cmd = podget + cmd
|
||||||
|
|
||||||
if cron.Image == "" {
|
if cron.Image == "" {
|
||||||
cron.Image = "bitnami/kubectl"
|
cron.Image = "bitnami/kubectl:1.20"
|
||||||
}
|
}
|
||||||
|
|
||||||
name := deployName
|
name := deployName
|
||||||
|
@@ -74,6 +74,7 @@ func buildDeployment(name string, s *types.ServiceConfig, linked map[string]type
|
|||||||
|
|
||||||
// Add selectors
|
// Add selectors
|
||||||
selectors := buildSelector(name, s)
|
selectors := buildSelector(name, s)
|
||||||
|
selectors[helm.K+"/resource"] = "deployment"
|
||||||
deployment.Spec.Selector = map[string]interface{}{
|
deployment.Spec.Selector = map[string]interface{}{
|
||||||
"matchLabels": selectors,
|
"matchLabels": selectors,
|
||||||
}
|
}
|
||||||
|
@@ -5,8 +5,11 @@ type CronTab struct {
|
|||||||
Spec CronSpec `yaml:"spec"`
|
Spec CronSpec `yaml:"spec"`
|
||||||
}
|
}
|
||||||
type CronSpec struct {
|
type CronSpec struct {
|
||||||
Schedule string `yaml:"schedule"`
|
Schedule string `yaml:"schedule"`
|
||||||
JobTemplate JobTemplate `yaml:"jobTemplate"`
|
JobTemplate JobTemplate `yaml:"jobTemplate"`
|
||||||
|
SuccessfulJobsHistoryLimit int `yaml:"successfulJobsHistoryLimit"`
|
||||||
|
FailedJobsHistoryLimit int `yaml:"failedJobsHistoryLimit"`
|
||||||
|
ConcurrencyPolicy string `yaml:"concurrencyPolicy"`
|
||||||
}
|
}
|
||||||
type JobTemplate struct {
|
type JobTemplate struct {
|
||||||
Spec JobSpecDescription `yaml:"spec"`
|
Spec JobSpecDescription `yaml:"spec"`
|
||||||
@@ -38,6 +41,9 @@ func NewCrontab(name, image, command, schedule string, serviceAccount *ServiceAc
|
|||||||
cron.K8sBase.Metadata.Name = ReleaseNameTpl + "-" + name
|
cron.K8sBase.Metadata.Name = ReleaseNameTpl + "-" + name
|
||||||
cron.K8sBase.Metadata.Labels[K+"/component"] = name
|
cron.K8sBase.Metadata.Labels[K+"/component"] = name
|
||||||
cron.Spec.Schedule = schedule
|
cron.Spec.Schedule = schedule
|
||||||
|
cron.Spec.SuccessfulJobsHistoryLimit = 3
|
||||||
|
cron.Spec.FailedJobsHistoryLimit = 3
|
||||||
|
cron.Spec.ConcurrencyPolicy = "Forbid"
|
||||||
cron.Spec.JobTemplate.Spec.Template.Metadata = Metadata{
|
cron.Spec.JobTemplate.Spec.Template.Metadata = Metadata{
|
||||||
Labels: cron.K8sBase.Metadata.Labels,
|
Labels: cron.K8sBase.Metadata.Labels,
|
||||||
}
|
}
|
||||||
@@ -48,7 +54,7 @@ func NewCrontab(name, image, command, schedule string, serviceAccount *ServiceAc
|
|||||||
{
|
{
|
||||||
Name: name,
|
Name: name,
|
||||||
Image: image,
|
Image: image,
|
||||||
Command: []string{command},
|
Command: []string{"sh", "-c", command},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
RestartPolicy: "OnFailure",
|
RestartPolicy: "OnFailure",
|
||||||
|
@@ -25,6 +25,13 @@ type DepSpec struct {
|
|||||||
func NewDepSpec() *DepSpec {
|
func NewDepSpec() *DepSpec {
|
||||||
return &DepSpec{
|
return &DepSpec{
|
||||||
Replicas: 1,
|
Replicas: 1,
|
||||||
|
Template: PodTemplate{
|
||||||
|
Metadata: Metadata{
|
||||||
|
Labels: map[string]string{
|
||||||
|
K + "/resource": "deployment",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -24,8 +24,13 @@ func NewCronRole(name string) *Role {
|
|||||||
role.Rules = []Rule{
|
role.Rules = []Rule{
|
||||||
{
|
{
|
||||||
ApiGroup: []string{""},
|
ApiGroup: []string{""},
|
||||||
Resources: []string{"pods", "pods/exec"},
|
Resources: []string{"pods", "pods/log"},
|
||||||
Verbs: []string{"get", "list", "create"},
|
Verbs: []string{"get", "list", "watch", "create", "update", "patch", "delete"},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ApiGroup: []string{""},
|
||||||
|
Resources: []string{"pods/exec"},
|
||||||
|
Verbs: []string{"create"},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user