@@ -62,7 +62,8 @@ type ContainerIdentity struct {
6262// ArangoDIdentity helps to resolve the ArangoD identity, e.g.: image ID, version of the entrypoint.
6363type ArangoDIdentity struct {
6464 interfaces.ContainerCreator
65- License api.LicenseSpec
65+ License api.LicenseSpec
66+ ipAddress string
6667}
6768
6869// ArangoSyncIdentity helps to resolve the ArangoSync identity, e.g.: image ID, version of the entrypoint.
@@ -209,13 +210,6 @@ func (ib *imagesBuilder) fetchArangoDBImageIDAndVersion(ctx context.Context, cac
209210 Msg ("Found image ID and ArangoDB version" )
210211 return false , nil
211212 }
212- // Pod cannot be fetched, ensure it is created
213- args := []string {
214- "--server.authentication=false" ,
215- fmt .Sprintf ("--server.endpoint=tcp://%s:%d" , ib .Spec .GetListenAddr (), k8sutil .ArangoPort ),
216- "--database.directory=" + k8sutil .ArangodVolumeMountDir ,
217- "--log.output=+" ,
218- }
219213
220214 imagePod := ImageUpdatePod {
221215 spec : ib .Spec ,
@@ -226,11 +220,12 @@ func (ib *imagesBuilder) fetchArangoDBImageIDAndVersion(ctx context.Context, cac
226220 image : image ,
227221 imagePullPolicy : ib .Spec .GetImagePullPolicy (),
228222 },
229- License : ib .Spec .License ,
223+ License : ib .Spec .License ,
224+ ipAddress : ib .Spec .GetListenAddr (),
230225 },
231226 }
232227
233- pod , err = resources .RenderArangoPod (cachedStatus , ib .APIObject , role , id , podName , args , & imagePod )
228+ pod , err = resources .RenderArangoPod (cachedStatus , ib .APIObject , role , id , podName , & imagePod )
234229 if err != nil {
235230 log .Debug ().Err (err ).Msg ("Failed to render image ID pod" )
236231 return true , errors .WithStack (err )
@@ -282,14 +277,8 @@ func (i *ImageUpdatePod) GetAffinityRole() string {
282277 return ""
283278}
284279
285- func (i * ImageUpdatePod ) GetVolumes () ([]core.Volume , []core.VolumeMount ) {
286- var volumes []core.Volume
287- var volumeMounts []core.VolumeMount
288-
289- volumes = append (volumes , k8sutil .CreateVolumeEmptyDir (k8sutil .ArangodVolumeName ))
290- volumeMounts = append (volumeMounts , k8sutil .ArangodVolumeMount ())
291-
292- return volumes , volumeMounts
280+ func (i * ImageUpdatePod ) GetVolumes () []core.Volume {
281+ return getVolumes ().Volumes ()
293282}
294283
295284func (i * ImageUpdatePod ) GetSidecars (* core.Pod ) error {
@@ -376,6 +365,10 @@ func (i *ImageUpdatePod) ApplyPodSpec(_ *core.PodSpec) error {
376365 return nil
377366}
378367
368+ func (a * ContainerIdentity ) GetArgs () ([]string , error ) {
369+ return nil , nil
370+ }
371+
379372func (a * ContainerIdentity ) GetEnvs () []core.EnvVar {
380373 return nil
381374}
@@ -396,10 +389,14 @@ func (a *ContainerIdentity) GetLifecycle() (*core.Lifecycle, error) {
396389 return nil , nil
397390}
398391
392+ func (a * ContainerIdentity ) GetName () string {
393+ return k8sutil .ServerContainerName
394+ }
395+
399396func (a * ContainerIdentity ) GetPorts () []core.ContainerPort {
400397 return []core.ContainerPort {
401398 {
402- Name : "server" ,
399+ Name : k8sutil . ServerContainerName ,
403400 ContainerPort : int32 (k8sutil .ArangoPort ),
404401 Protocol : core .ProtocolTCP ,
405402 },
@@ -418,6 +415,21 @@ func (a *ContainerIdentity) GetSecurityContext() *core.SecurityContext {
418415 return a .ID .Get ().SecurityContext .NewSecurityContext ()
419416}
420417
418+ // GetVolumeMounts returns nil for the basic container identity.
419+ func (a * ContainerIdentity ) GetVolumeMounts () []core.VolumeMount {
420+ return nil
421+ }
422+
423+ // GetArgs returns the list of arguments for the ArangoD container identification.
424+ func (a * ArangoDIdentity ) GetArgs () ([]string , error ) {
425+ return []string {
426+ "--server.authentication=false" ,
427+ fmt .Sprintf ("--server.endpoint=tcp://%s:%d" , a .ipAddress , k8sutil .ArangoPort ),
428+ "--database.directory=" + k8sutil .ArangodVolumeMountDir ,
429+ "--log.output=+" ,
430+ }, nil
431+ }
432+
421433func (a * ArangoDIdentity ) GetEnvs () []core.EnvVar {
422434 env := make ([]core.EnvVar , 0 )
423435
@@ -433,7 +445,20 @@ func (a *ArangoDIdentity) GetEnvs() []core.EnvVar {
433445 return nil
434446}
435447
448+ // GetVolumeMounts returns volume mount for the ArangoD data.
449+ func (a * ArangoDIdentity ) GetVolumeMounts () []core.VolumeMount {
450+ return getVolumes ().VolumeMounts ()
451+ }
452+
436453// GetExecutor returns the fixed path to the ArangoSync binary in the container.
437454func (a * ArangoSyncIdentity ) GetExecutor () string {
438455 return resources .ArangoSyncExecutor
439456}
457+
458+ func getVolumes () pod.Volumes {
459+ volumes := pod .NewVolumes ()
460+ volumes .AddVolume (k8sutil .CreateVolumeEmptyDir (k8sutil .ArangodVolumeName ))
461+ volumes .AddVolumeMount (k8sutil .ArangodVolumeMount ())
462+
463+ return volumes
464+ }
0 commit comments