//TODO: refactor elasticsearchHost to get from cluster
refactor elasticsearchHost to get from cluster
// TODO : refactor elasticsearchHost to get from cluster
func (cluster *ClusterLogging) newCuratorCronJob(curatorName string, elasticsearchHost string) *batch.CronJob {
	var resources = cluster.Spec.Curation.Resources
	if resources == nil {
		resources = &v1.ResourceRequirements{
			Limits: v1.ResourceList{v1.ResourceMemory: defaultCuratorMemory},
			Requests: v1.ResourceList{
				v1.ResourceMemory: defaultCuratorMemory,
				v1.ResourceCPU:    defaultCuratorCpuRequest,
			},
		}
	}
	curatorContainer := utils.NewContainer("curator", v1.PullIfNotPresent, *resources)
	curatorContainer.Env = []v1.EnvVar{
		{Name: "K8S_HOST_URL", Value: "https://kubernetes.default.svc.cluster.local"},
		{Name: "ES_HOST", Value: elasticsearchHost},
		{Name: "ES_PORT", Value: "9200"},
		{Name: "ES_CLIENT_CERT", Value: "/etc/curator/keys/cert"},
		{Name: "ES_CLIENT_KEY", Value: "/etc/curator/keys/key"},
		{Name: "ES_CA", Value: "/etc/curator/keys/ca"},
		{Name: "CURATOR_DEFAULT_DAYS", Value: "30"},
		{Name: "CURATOR_SCRIPT_LOG_LEVEL", Value: "INFO"},
		{Name: "CURATOR_LOG_LEVEL", Value: "ERROR"},
		{Name: "CURATOR_TIMEOUT", Value: "300"},
	}
	curatorContainer.VolumeMounts = []v1.VolumeMount{
		{Name: "certs", ReadOnly: true, MountPath: "/etc/curator/keys"},
		{Name: "config", ReadOnly: true, MountPath: "/etc/curator/settings"},
	}
	curatorPodSpec := utils.NewPodSpec(
		"curator",
		[]v1.Container{curatorContainer},
		[]v1.Volume{
			{Name: "config", VolumeSource: v1.VolumeSource{ConfigMap: &v1.ConfigMapVolumeSource{LocalObjectReference: v1.LocalObjectReference{Name: "curator"}}}},
			{Name: "certs", VolumeSource: v1.VolumeSource{Secret: &v1.SecretVolumeSource{SecretName: "curator"}}},
		},
		cluster.Spec.Curation.NodeSelector,
	)
	curatorPodSpec.RestartPolicy = v1.RestartPolicyNever
	curatorPodSpec.TerminationGracePeriodSeconds = utils.GetInt64(600)
	schedule := cluster.Spec.Curation.CuratorSpec.Schedule
	if schedule == "" {
		schedule = defaultSchedule
	}
	curatorCronJob := utils.NewCronJob(
		curatorName,
		cluster.Namespace,
		"curator",
		curatorName,
		batch.CronJobSpec{
			SuccessfulJobsHistoryLimit: utils.GetInt32(1),
			FailedJobsHistoryLimit:     utils.GetInt32(1),
			Schedule:                   schedule,
			JobTemplate: batch.JobTemplateSpec{
				Spec: batchv1.JobSpec{
					BackoffLimit: utils.GetInt32(0),
					Parallelism:  utils.GetInt32(1),
					Template: v1.PodTemplateSpec{
						ObjectMeta: metav1.ObjectMeta{
							Name:      curatorName,
							Namespace: cluster.Namespace,
							Labels: map[string]string{
								"provider":      "openshift",
								"component":     curatorName,
								"logging-infra": "curator",
							},
						},
						Spec: curatorPodSpec,
					},
				},
			},
		},
	)
	cluster.AddOwnerRefTo(curatorCronJob)
	return curatorCronJob
}
func ( cluster * ClusterLogging ) newCuratorCronJob ( curatorName string , elasticsearchHost string ) * batch . CronJob { var resources = cluster . Spec . Curation . Resources if resources == nil { resources = & v1 . ResourceRequirements { Limits : v1 . ResourceList { v1 . ResourceMemory : defaultCuratorMemory } , Requests : v1 . ResourceList { v1 . ResourceMemory : defaultCuratorMemory , v1 . ResourceCPU : defaultCuratorCpuRequest , } , } } curatorContainer := utils . NewContainer ( " " , v1 . PullIfNotPresent , * resources ) curatorContainer . Env = [ ] v1 . EnvVar { { Name : " " , Value : " " } , { Name : " " , Value : elasticsearchHost } , { Name : " " , Value : " " } , { Name : " " , Value : " " } , { Name : " " , Value : " " } , { Name : " " , Value : " " } , { Name : " " , Value : " " } , { Name : " " , Value : " " } , { Name : " " , Value : " " } , { Name : " " , Value : " " } , } curatorContainer . VolumeMounts = [ ] v1 . VolumeMount { { Name : " " , ReadOnly : true , MountPath : " " } , { Name : " " , ReadOnly : true , MountPath : " " } , } curatorPodSpec := utils . NewPodSpec ( " " , [ ] v1 . Container { curatorContainer } , [ ] v1 . Volume { { Name : " " , VolumeSource : v1 . VolumeSource { ConfigMap : & v1 . ConfigMapVolumeSource { LocalObjectReference : v1 . LocalObjectReference { Name : " " } } } } , { Name : " " , VolumeSource : v1 . VolumeSource { Secret : & v1 . SecretVolumeSource { SecretName : " " } } } , } , cluster . Spec . Curation . NodeSelector , ) curatorPodSpec . RestartPolicy = v1 . RestartPolicyNever curatorPodSpec . TerminationGracePeriodSeconds = utils . GetInt64 ( 600 ) schedule := cluster . Spec . Curation . CuratorSpec . Schedule if schedule == " " { schedule = defaultSchedule } curatorCronJob := utils . NewCronJob ( curatorName , cluster . Namespace , " " , curatorName , batch . CronJobSpec { SuccessfulJobsHistoryLimit : utils . GetInt32 ( 1 ) , FailedJobsHistoryLimit : utils . GetInt32 ( 1 ) , Schedule : schedule , JobTemplate : batch . JobTemplateSpec { Spec : batchv1 . JobSpec { BackoffLimit : utils . GetInt32 ( 0 ) , Parallelism : utils . GetInt32 ( 1 ) , Template : v1 . PodTemplateSpec { ObjectMeta : metav1 . ObjectMeta { Name : curatorName , Namespace : cluster . Namespace , Labels : map [ string ] string { " " : " " , " " : curatorName , " " : " " , } , } , Spec : curatorPodSpec , } , } , } , } , ) cluster . AddOwnerRefTo ( curatorCronJob ) return curatorCronJob }
refactor elasticsearchHost to get from cluster
refactor elasticsearchHost to get from cluster