Generate empty cron job spec
This commit is contained in:
parent
144a7cec0c
commit
68755ffff5
|
|
@ -20,7 +20,9 @@ import (
|
||||||
"github.com/zalando-incubator/postgres-operator/pkg/util"
|
"github.com/zalando-incubator/postgres-operator/pkg/util"
|
||||||
"github.com/zalando-incubator/postgres-operator/pkg/util/config"
|
"github.com/zalando-incubator/postgres-operator/pkg/util/config"
|
||||||
"github.com/zalando-incubator/postgres-operator/pkg/util/constants"
|
"github.com/zalando-incubator/postgres-operator/pkg/util/constants"
|
||||||
|
batchv1beta1 "k8s.io/api/batch/v1beta1"
|
||||||
"k8s.io/apimachinery/pkg/labels"
|
"k8s.io/apimachinery/pkg/labels"
|
||||||
|
batchv1 "k8s.io/api/batch/v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
@ -1195,3 +1197,26 @@ func (c *Cluster) getClusterServiceConnectionParameters(clusterName string) (hos
|
||||||
port = "5432"
|
port = "5432"
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Cluster) generateCronJob() *batchv1beta1.CronJob {
|
||||||
|
|
||||||
|
jobSpec := batchv1.JobSpec{}
|
||||||
|
|
||||||
|
jobTemplateSpec := batchv1beta1.JobTemplateSpec{
|
||||||
|
Spec: jobSpec,
|
||||||
|
}
|
||||||
|
|
||||||
|
cronJob := &batchv1beta1.CronJob{
|
||||||
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
Name: c.podDisruptionBudgetName(),
|
||||||
|
Namespace: c.Namespace,
|
||||||
|
Labels: c.labelsSet(true),
|
||||||
|
},
|
||||||
|
Spec: batchv1beta1.CronJobSpec{
|
||||||
|
Schedule: "*/1 * * * *",
|
||||||
|
JobTemplate: jobTemplateSpec,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
return cronJob
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -606,8 +606,15 @@ func (c *Cluster) createRoles() (err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Cluster) createBackupCronJob() (err error) {
|
func (c *Cluster) createBackupCronJob() (err error) {
|
||||||
|
|
||||||
c.setProcessName("creating a k8s cron job for backups")
|
c.setProcessName("creating a k8s cron job for backups")
|
||||||
|
|
||||||
|
cronJobSpec := c.generateCronJob()
|
||||||
|
cronJob, err := c.KubeClient.CronJobsGetter.CronJobs(c.Namespace).Create(cronJobSpec)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("could not create k8s cron job: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue