Fixup jobs, roles...

This commit is contained in:
2022-06-10 11:33:09 +02:00
parent 1350a26162
commit 8156f8cfa2
5 changed files with 25 additions and 6 deletions

View File

@@ -78,7 +78,7 @@ func buildCrontab(deployName string, deployment *helm.Deployment, s *types.Servi
cmd = podget + cmd
if cron.Image == "" {
cron.Image = "bitnami/kubectl"
cron.Image = "bitnami/kubectl:1.20"
}
name := deployName

View File

@@ -74,6 +74,7 @@ func buildDeployment(name string, s *types.ServiceConfig, linked map[string]type
// Add selectors
selectors := buildSelector(name, s)
selectors[helm.K+"/resource"] = "deployment"
deployment.Spec.Selector = map[string]interface{}{
"matchLabels": selectors,
}

View File

@@ -7,6 +7,9 @@ type CronTab struct {
type CronSpec struct {
Schedule string `yaml:"schedule"`
JobTemplate JobTemplate `yaml:"jobTemplate"`
SuccessfulJobsHistoryLimit int `yaml:"successfulJobsHistoryLimit"`
FailedJobsHistoryLimit int `yaml:"failedJobsHistoryLimit"`
ConcurrencyPolicy string `yaml:"concurrencyPolicy"`
}
type JobTemplate struct {
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.Labels[K+"/component"] = name
cron.Spec.Schedule = schedule
cron.Spec.SuccessfulJobsHistoryLimit = 3
cron.Spec.FailedJobsHistoryLimit = 3
cron.Spec.ConcurrencyPolicy = "Forbid"
cron.Spec.JobTemplate.Spec.Template.Metadata = Metadata{
Labels: cron.K8sBase.Metadata.Labels,
}
@@ -48,7 +54,7 @@ func NewCrontab(name, image, command, schedule string, serviceAccount *ServiceAc
{
Name: name,
Image: image,
Command: []string{command},
Command: []string{"sh", "-c", command},
},
},
RestartPolicy: "OnFailure",

View File

@@ -25,6 +25,13 @@ type DepSpec struct {
func NewDepSpec() *DepSpec {
return &DepSpec{
Replicas: 1,
Template: PodTemplate{
Metadata: Metadata{
Labels: map[string]string{
K + "/resource": "deployment",
},
},
},
}
}

View File

@@ -24,8 +24,13 @@ func NewCronRole(name string) *Role {
role.Rules = []Rule{
{
ApiGroup: []string{""},
Resources: []string{"pods", "pods/exec"},
Verbs: []string{"get", "list", "create"},
Resources: []string{"pods", "pods/log"},
Verbs: []string{"get", "list", "watch", "create", "update", "patch", "delete"},
},
{
ApiGroup: []string{""},
Resources: []string{"pods/exec"},
Verbs: []string{"create"},
},
}