@@ -203,7 +203,7 @@ func mutateDeployment[R Reconciler, O pdoknlv3.WMSWFS](r R, obj O, deployment *a
203203
204204 deployment .Spec .Template = corev1.PodTemplateSpec {
205205 ObjectMeta : metav1.ObjectMeta {
206- Annotations : smoothoperatorutils . CloneOrEmptyMap ( deployment . Spec . Template . GetAnnotations ()) ,
206+ Annotations : annotations ,
207207 Labels : labels ,
208208 },
209209 Spec : corev1.PodSpec {
@@ -262,21 +262,24 @@ func getInitContainerForDeployment[R Reconciler, O pdoknlv3.WMSWFS](r R, obj O)
262262 initContainers := []corev1.Container {
263263 * blobDownloadInitContainer ,
264264 * capabilitiesGeneratorInitContainer ,
265- * mapfileGeneratorInitContainer ,
265+ }
266+
267+ if obj .Mapfile () == nil {
268+ initContainers = append (initContainers , * mapfileGeneratorInitContainer )
266269 }
267270
268271 if wms , ok := any (obj ).(* pdoknlv3.WMS ); ok {
269- legendGeneratorInitContainer , err := legendgenerator . GetLegendGeneratorInitContainer ( wms , images .MapserverImage , srvDir )
272+ featureInfoInitContainer , err := featureinfogenerator . GetFeatureinfoGeneratorInitContainer ( images .FeatureinfoGeneratorImage , srvDir )
270273 if err != nil {
271274 return nil , err
272275 }
273- initContainers = append (initContainers , * legendGeneratorInitContainer )
276+ initContainers = append (initContainers , * featureInfoInitContainer )
274277
275- featureInfoInitContainer , err := featureinfogenerator . GetFeatureinfoGeneratorInitContainer ( images .FeatureinfoGeneratorImage , srvDir )
278+ legendGeneratorInitContainer , err := legendgenerator . GetLegendGeneratorInitContainer ( wms , images .MapserverImage , srvDir )
276279 if err != nil {
277280 return nil , err
278281 }
279- initContainers = append (initContainers , * featureInfoInitContainer )
282+ initContainers = append (initContainers , * legendGeneratorInitContainer )
280283
281284 if wms .Options ().RewriteGroupToDataLayers {
282285 legendFixerInitContainer := legendgenerator .GetLegendFixerInitContainer (images .MultitoolImage )
@@ -300,66 +303,70 @@ func getContainersForDeployment[R Reconciler, O pdoknlv3.WMSWFS](r R, obj O) ([]
300303 return nil , err
301304 }
302305
303- containers := []corev1.Container {
304- {
305- Name : MapserverName ,
306- Image : images .MapserverImage ,
307- ImagePullPolicy : corev1 .PullIfNotPresent ,
308- Ports : []corev1.ContainerPort {
309- {
310- ContainerPort : 80 ,
311- Protocol : corev1 .ProtocolTCP ,
312- },
306+ mapserverContainer := corev1.Container {
307+ Name : MapserverName ,
308+ Image : images .MapserverImage ,
309+ ImagePullPolicy : corev1 .PullIfNotPresent ,
310+ Ports : []corev1.ContainerPort {
311+ {
312+ ContainerPort : 80 ,
313+ Protocol : corev1 .ProtocolTCP ,
313314 },
314- Env : mapserver . GetEnvVarsForDeployment ( obj , blobsSecret . Name ) ,
315- VolumeMounts : mapserver .GetVolumeMountsForDeployment (obj , srvDir ),
316- Resources : mapserver .GetResourcesForDeployment (obj ),
317- TerminationMessagePolicy : corev1 . TerminationMessageReadFile ,
318- TerminationMessagePath : "/dev/termination-log" ,
319- LivenessProbe : livenessProbe ,
320- ReadinessProbe : readinessProbe ,
321- StartupProbe : startupProbe ,
322- Lifecycle : & corev1. Lifecycle {
323- PreStop : & corev1.LifecycleHandler {
324- Exec : & corev1.ExecAction {
325- Command : [] string { "sleep" , "15" },
326- },
315+ } ,
316+ Env : mapserver .GetEnvVarsForDeployment (obj , blobsSecret . Name ),
317+ VolumeMounts : mapserver .GetVolumeMountsForDeployment (obj , srvDir ),
318+ Resources : mapserver . GetResourcesForDeployment ( obj ) ,
319+ TerminationMessagePolicy : corev1 . TerminationMessageReadFile ,
320+ TerminationMessagePath : "/dev/termination-log" ,
321+ LivenessProbe : livenessProbe ,
322+ ReadinessProbe : readinessProbe ,
323+ StartupProbe : startupProbe ,
324+ Lifecycle : & corev1.Lifecycle {
325+ PreStop : & corev1.LifecycleHandler {
326+ Exec : & corev1. ExecAction {
327+ Command : [] string { "sleep" , "15" },
327328 },
328329 },
329330 },
330- {
331- Name : "apache-exporter" ,
332- Image : images .ApacheExporterImage ,
333- ImagePullPolicy : corev1 .PullIfNotPresent ,
334- TerminationMessagePolicy : corev1 .TerminationMessageReadFile ,
335- TerminationMessagePath : "/dev/termination-log" ,
336- Ports : []corev1.ContainerPort {
337- {
338- ContainerPort : 9117 ,
339- Protocol : corev1 .ProtocolTCP ,
340- },
331+ }
332+
333+ apacheContainer := corev1.Container {
334+ Name : "apache-exporter" ,
335+ Image : images .ApacheExporterImage ,
336+ ImagePullPolicy : corev1 .PullIfNotPresent ,
337+ TerminationMessagePolicy : corev1 .TerminationMessageReadFile ,
338+ TerminationMessagePath : "/dev/termination-log" ,
339+ Ports : []corev1.ContainerPort {
340+ {
341+ ContainerPort : 9117 ,
342+ Protocol : corev1 .ProtocolTCP ,
341343 },
342- Args : []string {
343- "--scrape_uri=http://localhost/server-status?auto" ,
344+ },
345+ Args : []string {
346+ "--scrape_uri=http://localhost/server-status?auto" ,
347+ },
348+ Resources : corev1.ResourceRequirements {
349+ Limits : corev1.ResourceList {
350+ corev1 .ResourceMemory : resource .MustParse ("48M" ),
344351 },
345- Resources : corev1.ResourceRequirements {
346- Limits : corev1.ResourceList {
347- corev1 .ResourceMemory : resource .MustParse ("48M" ),
348- },
349- Requests : corev1.ResourceList {
350- corev1 .ResourceCPU : resource .MustParse ("0.02" ),
351- },
352+ Requests : corev1.ResourceList {
353+ corev1 .ResourceCPU : resource .MustParse ("0.02" ),
352354 },
353355 },
354356 }
355357
358+ containers := []corev1.Container {
359+ mapserverContainer ,
360+ apacheContainer ,
361+ }
356362 if wms , ok := any (obj ).(* pdoknlv3.WMS ); ok {
357363 if wms .Options ().UseWebserviceProxy () {
358364 ogcWebserviceProxyContainer , err := ogcwebserviceproxy .GetOgcWebserviceProxyContainer (wms , images .OgcWebserviceProxyImage )
359365 if err != nil {
360366 return nil , err
361367 }
362- containers = append (containers , * ogcWebserviceProxyContainer )
368+
369+ return append (containers , * ogcWebserviceProxyContainer ), nil
363370 }
364371 }
365372
@@ -545,10 +552,10 @@ func getMatchRule[O pdoknlv3.WMSWFS](obj O) string {
545552func getLegendMatchRule (wms * pdoknlv3.WMS ) string {
546553 host := pdoknlv3 .GetHost (false )
547554 if strings .Contains (host , "localhost" ) {
548- return "Host(`localhost`) && Path (`/" + pdoknlv3 .GetBaseURLPath (wms ) + "/legend`)"
555+ return "Host(`localhost`) && PathPrefix (`/" + pdoknlv3 .GetBaseURLPath (wms ) + "/legend`)"
549556 }
550557
551- return "(Host(`localhost`) || Host(`" + host + "`)) && Path (`/" + pdoknlv3 .GetBaseURLPath (wms ) + "/legend`)"
558+ return "(Host(`localhost`) || Host(`" + host + "`)) && PathPrefix (`/" + pdoknlv3 .GetBaseURLPath (wms ) + "/legend`)"
552559}
553560
554561func getBareConfigMapMapfileGenerator [O pdoknlv3.WMSWFS ](obj O ) * corev1.ConfigMap {
@@ -659,8 +666,10 @@ func mutateHorizontalPodAutoscaler[R Reconciler, O pdoknlv3.WMSWFS](r R, obj O,
659666 }
660667 if len (metrics ) == 0 {
661668 var avgU int32 = 90
662- if podSpecPatch != nil && podSpecPatch .Resources != nil && podSpecPatch .Resources .Requests .Cpu () != nil {
663- avgU = 80
669+ if podSpecPatch != nil && podSpecPatch .Resources != nil {
670+ if cpu := podSpecPatch .Resources .Requests .Cpu (); cpu != nil && ! cpu .IsZero () {
671+ avgU = 80
672+ }
664673 }
665674 metrics = append (metrics , autoscalingv2.MetricSpec {
666675 Type : autoscalingv2 .ResourceMetricSourceType ,
@@ -777,12 +786,6 @@ func mutateService[R Reconciler, O pdoknlv3.WMSWFS](r R, obj O, service *corev1.
777786 TargetPort : intstr .FromInt32 (mapserverPortNr ),
778787 Protocol : corev1 .ProtocolTCP ,
779788 },
780- {
781- Name : metricPortName ,
782- Port : metricPortNr ,
783- TargetPort : intstr .FromInt32 (metricPortNr ),
784- Protocol : corev1 .ProtocolTCP ,
785- },
786789 }
787790
788791 if obj .Type () == pdoknlv3 .ServiceTypeWMS {
@@ -794,6 +797,14 @@ func mutateService[R Reconciler, O pdoknlv3.WMSWFS](r R, obj O, service *corev1.
794797 }
795798 }
796799
800+ // Add port here to get the same port order as the odl ansible operator
801+ ports = append (ports , corev1.ServicePort {
802+ Name : metricPortName ,
803+ Port : metricPortNr ,
804+ TargetPort : intstr .FromInt32 (metricPortNr ),
805+ Protocol : corev1 .ProtocolTCP ,
806+ })
807+
797808 service .Spec = corev1.ServiceSpec {
798809 Type : corev1 .ServiceTypeClusterIP ,
799810 ClusterIP : service .Spec .ClusterIP ,
@@ -1037,7 +1048,7 @@ func createOrUpdateAllForWMSWFS[R Reconciler, O pdoknlv3.WMSWFS](ctx context.Con
10371048 // end region ConfigMap
10381049
10391050 // region ConfigMap-MapfileGenerator
1040- {
1051+ if obj . Mapfile () == nil {
10411052 configMapMfg := getBareConfigMapMapfileGenerator (obj )
10421053 if err = mutateConfigMapMapfileGenerator (r , obj , configMapMfg , ownerInfo ); err != nil {
10431054 return operationResults , err
@@ -1069,7 +1080,7 @@ func createOrUpdateAllForWMSWFS[R Reconciler, O pdoknlv3.WMSWFS](ctx context.Con
10691080 // end region ConfigMap-CapabilitiesGenerator
10701081
10711082 // region ConfigMap-BlobDownload
1072- {
1083+ if obj . Options (). PrefetchData {
10731084 configMapBd := getBareConfigMapBlobDownload (obj )
10741085 if err = mutateConfigMapBlobDownload (r , obj , configMapBd ); err != nil {
10751086 return operationResults , err
@@ -1159,7 +1170,7 @@ func createOrUpdateAllForWMSWFS[R Reconciler, O pdoknlv3.WMSWFS](ctx context.Con
11591170 // end region Deployment
11601171
11611172 // region TraefikMiddleware
1162- {
1173+ if obj . Options (). IncludeIngress {
11631174 middleware := getBareCorsHeadersMiddleware (obj )
11641175 operationResults [smoothoperatorutils .GetObjectFullName (reconcilerClient , middleware )], err = controllerutil .CreateOrUpdate (ctx , reconcilerClient , middleware , func () error {
11651176 return mutateCorsHeadersMiddleware (r , obj , middleware )
@@ -1195,7 +1206,7 @@ func createOrUpdateAllForWMSWFS[R Reconciler, O pdoknlv3.WMSWFS](ctx context.Con
11951206 // end region HorizontalAutoScaler
11961207
11971208 // region IngressRoute
1198- {
1209+ if obj . Options (). IncludeIngress {
11991210 ingress := getBareIngressRoute (obj )
12001211 operationResults [smoothoperatorutils .GetObjectFullName (reconcilerClient , ingress )], err = controllerutil .CreateOrUpdate (ctx , reconcilerClient , ingress , func () error {
12011212 return mutateIngressRoute (r , obj , ingress )
0 commit comments