Submit hello world cron job
This commit is contained in:
		
							parent
							
								
									68755ffff5
								
							
						
					
					
						commit
						11019f557e
					
				| 
						 | 
				
			
			@ -23,3 +23,5 @@ spec:
 | 
			
		|||
    foo: zalando
 | 
			
		||||
  postgresql:
 | 
			
		||||
    version: "10"
 | 
			
		||||
 | 
			
		||||
  enableLogicalBackup: true
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -18,6 +18,7 @@ import (
 | 
			
		|||
	"k8s.io/apimachinery/pkg/types"
 | 
			
		||||
	"k8s.io/client-go/rest"
 | 
			
		||||
	"k8s.io/client-go/tools/cache"
 | 
			
		||||
	batchv1beta1 "k8s.io/api/batch/v1beta1"
 | 
			
		||||
 | 
			
		||||
	"encoding/json"
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -82,6 +83,8 @@ type Cluster struct {
 | 
			
		|||
	currentProcess   Process
 | 
			
		||||
	processMu        sync.RWMutex // protects the current operation for reporting, no need to hold the master mutex
 | 
			
		||||
	specMu           sync.RWMutex // protects the spec for reporting, no need to hold the master mutex
 | 
			
		||||
 | 
			
		||||
	backupJob        *batchv1beta1.CronJob  // periodical logical backups independent from WAL archiving
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type compareStatefulsetResult struct {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -20,9 +20,10 @@ import (
 | 
			
		|||
	"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/constants"
 | 
			
		||||
	batchv1beta1 "k8s.io/api/batch/v1beta1"
 | 
			
		||||
	"k8s.io/apimachinery/pkg/labels"
 | 
			
		||||
	batchv1 "k8s.io/api/batch/v1"
 | 
			
		||||
	batchv1beta1 "k8s.io/api/batch/v1beta1"
 | 
			
		||||
	corev1 "k8s.io/api/core/v1"
 | 
			
		||||
	"k8s.io/apimachinery/pkg/labels"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
const (
 | 
			
		||||
| 
						 | 
				
			
			@ -1200,15 +1201,29 @@ func (c *Cluster) getClusterServiceConnectionParameters(clusterName string) (hos
 | 
			
		|||
 | 
			
		||||
func (c *Cluster) generateCronJob() *batchv1beta1.CronJob {
 | 
			
		||||
 | 
			
		||||
	jobSpec := batchv1.JobSpec{}
 | 
			
		||||
	jobSpec := batchv1.JobSpec{Template : v1.PodTemplateSpec{
 | 
			
		||||
		Spec: corev1.PodSpec{
 | 
			
		||||
			Containers: []corev1.Container{
 | 
			
		||||
				corev1.Container {
 | 
			
		||||
					Name: "Hello world",
 | 
			
		||||
					Image: "hello-world",
 | 
			
		||||
					Command: []string{"date", "echo Hello from the Kubernetes cluster"},
 | 
			
		||||
 | 
			
		||||
				},
 | 
			
		||||
 | 
			
		||||
			},
 | 
			
		||||
		},
 | 
			
		||||
	},
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	jobTemplateSpec := batchv1beta1.JobTemplateSpec{
 | 
			
		||||
		Spec: jobSpec,
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	cronJob := &batchv1beta1.CronJob{
 | 
			
		||||
		ObjectMeta: metav1.ObjectMeta{
 | 
			
		||||
			Name:      c.podDisruptionBudgetName(),
 | 
			
		||||
			Name:      "Dummy cron job",
 | 
			
		||||
			Namespace: c.Namespace,
 | 
			
		||||
			Labels:    c.labelsSet(true),
 | 
			
		||||
		},
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -614,6 +614,7 @@ func (c *Cluster) createBackupCronJob() (err error) {
 | 
			
		|||
	if err != nil {
 | 
			
		||||
		return fmt.Errorf("could not create k8s cron job: %v", err)
 | 
			
		||||
	}
 | 
			
		||||
	c.backupJob = cronJob
 | 
			
		||||
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue