@@ -52,8 +52,9 @@ var _ interfaces.ContainerCreator = &ContainerIdentity{}
5252// ImageUpdatePod describes how to launch the ID ArangoD POD.
5353type ImageUpdatePod struct {
5454 spec api.DeploymentSpec
55+ status api.DeploymentStatus
5556 apiObject k8sutil.APIObject
56- containerCreator interfaces. ContainerCreator
57+ containerCreator * ArangoDIdentity
5758}
5859
5960// ContainerIdentity helps to resolve the container identity, e.g.: image ID, version of the entrypoint.
@@ -66,6 +67,7 @@ type ContainerIdentity struct {
6667// ArangoDIdentity helps to resolve the ArangoD identity, e.g.: image ID, version of the entrypoint.
6768type ArangoDIdentity struct {
6869 interfaces.ContainerCreator
70+ input pod.Input
6971 License * string
7072 ipAddress string
7173}
@@ -226,6 +228,7 @@ func (ib *imagesBuilder) fetchArangoDBImageIDAndVersion(ctx context.Context, cac
226228
227229 imagePod := ImageUpdatePod {
228230 spec : ib .Spec ,
231+ status : ib .Status ,
229232 apiObject : ib .APIObject ,
230233 containerCreator : & ArangoDIdentity {
231234 ContainerCreator : & ContainerIdentity {
@@ -237,6 +240,7 @@ func (ib *imagesBuilder) fetchArangoDBImageIDAndVersion(ctx context.Context, cac
237240 ipAddress : ib .Spec .GetListenAddr (),
238241 },
239242 }
243+ imagePod .containerCreator .input = imagePod .AsInput ()
240244
241245 pod , err = resources .RenderArangoPod (ctx , cachedStatus , ib .APIObject , role , id , podName , & imagePod )
242246 if err != nil {
@@ -297,7 +301,7 @@ func (i *ImageUpdatePod) GetAffinityRole() string {
297301}
298302
299303func (i * ImageUpdatePod ) GetVolumes () []core.Volume {
300- return getVolumes ().Volumes ()
304+ return getVolumes (i . AsInput () ).Volumes ()
301305}
302306
303307func (i * ImageUpdatePod ) GetSidecars (* core.Pod ) error {
@@ -381,7 +385,10 @@ func (i *ImageUpdatePod) Validate(_ interfaces.Inspector) error {
381385 return nil
382386}
383387
384- func (i * ImageUpdatePod ) ApplyPodSpec (_ * core.PodSpec ) error {
388+ func (i * ImageUpdatePod ) ApplyPodSpec (p * core.PodSpec ) error {
389+ if id := i .spec .ID ; id != nil {
390+ p .SecurityContext = i .spec .ID .SecurityContext .NewPodSecurityContext ()
391+ }
385392 return nil
386393}
387394
@@ -442,12 +449,16 @@ func (a *ContainerIdentity) GetVolumeMounts() []core.VolumeMount {
442449
443450// GetArgs returns the list of arguments for the ArangoD container identification.
444451func (a * ArangoDIdentity ) GetArgs () ([]string , error ) {
445- return []string {
446- "--server.authentication=false" ,
447- fmt .Sprintf ("--server.endpoint=tcp://%s:%d" , a .ipAddress , shared .ArangoPort ),
448- "--database.directory=" + shared .ArangodVolumeMountDir ,
449- "--log.output=+" ,
450- }, nil
452+ options := k8sutil .CreateOptionPairs (64 )
453+ options .Add ("--server.authentication" , "false" )
454+ options .Addf ("--server.endpoint" , "tcp://%s:%d" , a .ipAddress , shared .ArangoPort )
455+ options .Add ("--database.directory" , shared .ArangodVolumeMountDir )
456+ options .Add ("--log.output" , "+" )
457+
458+ // Security
459+ options .Merge (pod .Security ().Args (a .input ))
460+
461+ return options .Copy ().Sort ().AsArgs (), nil
451462}
452463
453464func (a * ArangoDIdentity ) GetEnvs () []core.EnvVar {
@@ -468,18 +479,30 @@ func (a *ArangoDIdentity) GetEnvs() []core.EnvVar {
468479
469480// GetVolumeMounts returns volume mount for the ArangoD data.
470481func (a * ArangoDIdentity ) GetVolumeMounts () []core.VolumeMount {
471- return getVolumes ().VolumeMounts ()
482+ return getVolumes (a .input ).VolumeMounts ()
483+ }
484+
485+ func (a * ImageUpdatePod ) AsInput () pod.Input {
486+ return pod.Input {
487+ ApiObject : a .apiObject ,
488+ Deployment : a .spec ,
489+ Status : a .status ,
490+ Group : api .ServerGroupImageDiscovery ,
491+ }
472492}
473493
474494// GetExecutor returns the fixed path to the ArangoSync binary in the container.
475495func (a * ArangoSyncIdentity ) GetExecutor () string {
476496 return resources .ArangoSyncExecutor
477497}
478498
479- func getVolumes () pod.Volumes {
499+ func getVolumes (input pod. Input ) pod.Volumes {
480500 volumes := pod .NewVolumes ()
481501 volumes .AddVolume (k8sutil .CreateVolumeEmptyDir (shared .ArangodVolumeName ))
482502 volumes .AddVolumeMount (k8sutil .ArangodVolumeMount ())
483503
504+ // Security
505+ volumes .Append (pod .Security (), input )
506+
484507 return volumes
485508}
0 commit comments