@@ -14,11 +14,12 @@ import (
1414	pgTime "github.com/cloudnative-pg/machinery/pkg/postgres/time" 
1515	batchv1 "k8s.io/api/batch/v1" 
1616	corev1 "k8s.io/api/core/v1" 
17- 	v1 "k8s.io/api/core/v1" 
1817	rbacv1 "k8s.io/api/rbac/v1" 
1918	"k8s.io/apimachinery/pkg/api/errors" 
19+ 	"k8s.io/apimachinery/pkg/api/resource" 
2020	"k8s.io/apimachinery/pkg/runtime" 
2121	"k8s.io/apimachinery/pkg/types" 
22+ 	"k8s.io/utils/ptr" 
2223	ctrl "sigs.k8s.io/controller-runtime" 
2324	"sigs.k8s.io/controller-runtime/pkg/client" 
2425	"sigs.k8s.io/controller-runtime/pkg/log" 
@@ -277,7 +278,7 @@ func Promote(ctx context.Context, cli client.Client,
277278	}
278279
279280	// Check if the Pod exist 
280- 	var  pod  v1 .Pod 
281+ 	var  pod  corev1 .Pod 
281282	err  =  cli .Get (ctx , client.ObjectKey {Namespace : namespace , Name : serverName }, & pod )
282283	if  err  !=  nil  {
283284		return  fmt .Errorf ("new primary node %s not found in namespace %s: %w" , serverName , namespace , err )
@@ -310,10 +311,10 @@ func (r *DocumentDBReconciler) executeSQLCommand(ctx context.Context, documentdb
310311			Namespace : namespace ,
311312		},
312313		Spec : batchv1.JobSpec {
313- 			Template : v1 .PodTemplateSpec {
314- 				Spec : v1 .PodSpec {
315- 					RestartPolicy : v1 .RestartPolicyNever ,
316- 					Containers : []v1 .Container {
314+ 			Template : corev1 .PodTemplateSpec {
315+ 				Spec : corev1 .PodSpec {
316+ 					RestartPolicy : corev1 .RestartPolicyNever ,
317+ 					Containers : []corev1 .Container {
317318						{
318319							Name :  "sql-executor" ,
319320							Image : documentdb .Spec .DocumentDBImage ,
@@ -324,6 +325,21 @@ func (r *DocumentDBReconciler) executeSQLCommand(ctx context.Context, documentdb
324325								"-d" , "postgres" ,
325326								"-c" , sqlCommand ,
326327							},
328+ 							Resources : corev1.ResourceRequirements {
329+ 								Requests : corev1.ResourceList {
330+ 									"cpu" :    resource .MustParse (util .SQL_JOB_REQUESTS_CPU ),
331+ 									"memory" : resource .MustParse (util .SQL_JOB_REQUESTS_MEMORY ),
332+ 								},
333+ 								Limits : corev1.ResourceList {
334+ 									"cpu" :    resource .MustParse (util .SQL_JOB_LIMITS_CPU ),
335+ 									"memory" : resource .MustParse (util .SQL_JOB_LIMITS_MEMORY ),
336+ 								},
337+ 							},
338+ 							SecurityContext : & corev1.SecurityContext {
339+ 								RunAsUser :                ptr .To (int64 (util .SQL_JOB_LINUX_UID )),
340+ 								RunAsNonRoot :             ptr .To (util .SQL_JOB_RUN_AS_NON_ROOT ),
341+ 								AllowPrivilegeEscalation : ptr .To (util .SQL_JOB_ALLOW_PRIVILEGED ),
342+ 							},
327343						},
328344					},
329345				},
0 commit comments