Skip to content

Commit 0dc9317

Browse files
author
Jelle Dijkstra
committed
Changes for deployment of the operator
1 parent 80ec57c commit 0dc9317

File tree

7 files changed

+56
-130
lines changed

7 files changed

+56
-130
lines changed

cmd/main.go

Lines changed: 22 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,13 @@ import (
2020
"crypto/tls"
2121
"errors"
2222
"flag"
23+
"github.com/peterbourgon/ff"
2324
"os"
24-
"path/filepath"
25+
"sigs.k8s.io/controller-runtime/pkg/log/zap"
2526

26-
"github.com/go-logr/zapr"
2727
"github.com/pdok/mapserver-operator/internal/controller/mapfilegenerator"
2828
smoothoperator "github.com/pdok/smooth-operator/api/v1"
29-
"github.com/pdok/smooth-operator/pkg/integrations/logging"
3029
traefikiov1alpha1 "github.com/traefik/traefik/v3/pkg/provider/kubernetes/crd/traefikio/v1alpha1"
31-
"go.uber.org/zap/zapcore"
32-
3330
// Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.)
3431
// to ensure that exec-entrypoint and run can make use of them.
3532
_ "k8s.io/client-go/plugin/pkg/client/auth"
@@ -38,9 +35,7 @@ import (
3835
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
3936
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
4037
ctrl "sigs.k8s.io/controller-runtime"
41-
"sigs.k8s.io/controller-runtime/pkg/certwatcher"
4238
"sigs.k8s.io/controller-runtime/pkg/healthz"
43-
"sigs.k8s.io/controller-runtime/pkg/metrics/filters"
4439
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"
4540
"sigs.k8s.io/controller-runtime/pkg/webhook"
4641

@@ -81,8 +76,7 @@ func init() {
8176
//nolint:gocyclo
8277
func main() {
8378
var metricsAddr string
84-
var metricsCertPath, metricsCertName, metricsCertKey string
85-
var webhookCertPath, webhookCertName, webhookCertKey string
79+
var certDir string
8680
var enableLeaderElection bool
8781
var probeAddr string
8882
var secureMetrics bool
@@ -93,21 +87,15 @@ func main() {
9387
var multitoolImage, mapfileGeneratorImage, mapserverImage, capabilitiesGeneratorImage, featureinfoGeneratorImage, ogcWebserviceProxyImage, apacheExporterImage string
9488
var slackWebhookURL string
9589
var logLevel int
96-
flag.StringVar(&metricsAddr, "metrics-bind-address", "0", "The address the metrics endpoint binds to. "+
90+
flag.StringVar(&metricsAddr, "metrics-bind-address", ":8080", "The address the metrics endpoint binds to. "+
9791
"Use :8443 for HTTPS or :8080 for HTTP, or leave as 0 to disable the metrics service.")
9892
flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.")
9993
flag.BoolVar(&enableLeaderElection, "leader-elect", false,
10094
"Enable leader election for controller manager. "+
10195
"Enabling this will ensure there is only one active controller manager.")
10296
flag.BoolVar(&secureMetrics, "metrics-secure", true,
10397
"If set, the metrics endpoint is served securely via HTTPS. Use --metrics-secure=false to use HTTP instead.")
104-
flag.StringVar(&webhookCertPath, "webhook-cert-path", "", "The directory that contains the webhook certificate.")
105-
flag.StringVar(&webhookCertName, "webhook-cert-name", "tls.crt", "The name of the webhook certificate file.")
106-
flag.StringVar(&webhookCertKey, "webhook-cert-key", "tls.key", "The name of the webhook key file.")
107-
flag.StringVar(&metricsCertPath, "metrics-cert-path", "",
108-
"The directory that contains the metrics server certificate.")
109-
flag.StringVar(&metricsCertName, "metrics-cert-name", "tls.crt", "The name of the metrics server certificate file.")
110-
flag.StringVar(&metricsCertKey, "metrics-cert-key", "tls.key", "The name of the metrics server key file.")
98+
flag.StringVar(&certDir, "cert-dir", "", "CertDir contains the webhook server key and certificate. Defaults to <temp-dir>/k8s-webhook-server/serving-certs.")
11199
flag.BoolVar(&enableHTTP2, "enable-http2", false,
112100
"If set, HTTP/2 will be enabled for the metrics and webhook servers")
113101
flag.StringVar(&host, "baseurl", "", "The host which is used in the mapserver service.")
@@ -122,13 +110,17 @@ func main() {
122110
flag.StringVar(&slackWebhookURL, "slack-webhook-url", "", "The webhook url for sending slack messages. Disabled if left empty")
123111
flag.IntVar(&logLevel, "log-level", 0, "The zapcore loglevel. 0 = info, 1 = warn, 2 = error")
124112

125-
flag.Parse()
113+
opts := zap.Options{
114+
Development: true,
115+
}
116+
opts.BindFlags(flag.CommandLine)
126117

127-
//nolint:gosec
128-
levelEnabler := zapcore.Level(logLevel)
129-
zapLogger, _ := logging.SetupLogger("atom-operator", slackWebhookURL, levelEnabler)
118+
if err := ff.Parse(flag.CommandLine, os.Args[1:], ff.WithEnvVarNoPrefix()); err != nil {
119+
setupLog.Error(err, "unable to parse flags")
120+
os.Exit(1)
121+
}
130122

131-
ctrl.SetLogger(zapr.NewLogger(zapLogger))
123+
ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts)))
132124

133125
if host == "" {
134126
setupLog.Error(errors.New("baseURL is required"), "A value for baseURL must be specified.")
@@ -152,83 +144,18 @@ func main() {
152144
tlsOpts = append(tlsOpts, disableHTTP2)
153145
}
154146

155-
// Create watchers for metrics and webhooks certificates
156-
var metricsCertWatcher, webhookCertWatcher *certwatcher.CertWatcher
157-
158-
// Initial webhook TLS options
159-
webhookTLSOpts := tlsOpts
160-
161-
if len(webhookCertPath) > 0 {
162-
setupLog.Info("Initializing webhook certificate watcher using provided certificates",
163-
"webhook-cert-path", webhookCertPath, "webhook-cert-name", webhookCertName, "webhook-cert-key", webhookCertKey)
164-
165-
var err error
166-
webhookCertWatcher, err = certwatcher.New(
167-
filepath.Join(webhookCertPath, webhookCertName),
168-
filepath.Join(webhookCertPath, webhookCertKey),
169-
)
170-
if err != nil {
171-
setupLog.Error(err, "Failed to initialize webhook certificate watcher")
172-
os.Exit(1)
173-
}
174-
175-
webhookTLSOpts = append(webhookTLSOpts, func(config *tls.Config) {
176-
config.GetCertificate = webhookCertWatcher.GetCertificate
177-
})
178-
}
179-
180147
webhookServer := webhook.NewServer(webhook.Options{
181-
TLSOpts: webhookTLSOpts,
148+
CertDir: certDir,
149+
TLSOpts: tlsOpts,
182150
})
183151

184-
// Metrics endpoint is enabled in 'config/default/kustomization.yaml'. The Metrics options configure the server.
185-
// More info:
186-
// - https://pkg.go.dev/sigs.k8s.io/[email protected]/pkg/metrics/server
187-
// - https://book.kubebuilder.io/reference/metrics.html
188-
metricsServerOptions := metricsserver.Options{
189-
BindAddress: metricsAddr,
190-
SecureServing: secureMetrics,
191-
TLSOpts: tlsOpts,
192-
}
193-
194-
if secureMetrics {
195-
// FilterProvider is used to protect the metrics endpoint with authn/authz.
196-
// These configurations ensure that only authorized users and service accounts
197-
// can access the metrics endpoint. The RBAC are configured in 'config/rbac/kustomization.yaml'. More info:
198-
// https://pkg.go.dev/sigs.k8s.io/[email protected]/pkg/metrics/filters#WithAuthenticationAndAuthorization
199-
metricsServerOptions.FilterProvider = filters.WithAuthenticationAndAuthorization
200-
}
201-
202-
// If the certificate is not specified, controller-runtime will automatically
203-
// generate self-signed certificates for the metrics server. While convenient for development and testing,
204-
// this setup is not recommended for production.
205-
//
206-
// TODO(user): If you enable certManager, uncomment the following lines:
207-
// - [METRICS-WITH-CERTS] at config/default/kustomization.yaml to generate and use certificates
208-
// managed by cert-manager for the metrics server.
209-
// - [PROMETHEUS-WITH-CERTS] at config/prometheus/kustomization.yaml for TLS certification.
210-
if len(metricsCertPath) > 0 {
211-
setupLog.Info("Initializing metrics certificate watcher using provided certificates",
212-
"metrics-cert-path", metricsCertPath, "metrics-cert-name", metricsCertName, "metrics-cert-key", metricsCertKey)
213-
214-
var err error
215-
metricsCertWatcher, err = certwatcher.New(
216-
filepath.Join(metricsCertPath, metricsCertName),
217-
filepath.Join(metricsCertPath, metricsCertKey),
218-
)
219-
if err != nil {
220-
setupLog.Error(err, "to initialize metrics certificate watcher", "error", err)
221-
os.Exit(1)
222-
}
223-
224-
metricsServerOptions.TLSOpts = append(metricsServerOptions.TLSOpts, func(config *tls.Config) {
225-
config.GetCertificate = metricsCertWatcher.GetCertificate
226-
})
227-
}
228-
229152
mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
230-
Scheme: scheme,
231-
Metrics: metricsServerOptions,
153+
Scheme: scheme,
154+
Metrics: metricsserver.Options{
155+
BindAddress: metricsAddr,
156+
SecureServing: secureMetrics,
157+
TLSOpts: tlsOpts,
158+
},
232159
WebhookServer: webhookServer,
233160
HealthProbeBindAddress: probeAddr,
234161
LeaderElection: enableLeaderElection,
@@ -303,22 +230,6 @@ func main() {
303230
}
304231
// +kubebuilder:scaffold:builder
305232

306-
if metricsCertWatcher != nil {
307-
setupLog.Info("Adding metrics certificate watcher to manager")
308-
if err := mgr.Add(metricsCertWatcher); err != nil {
309-
setupLog.Error(err, "unable to add metrics certificate watcher to manager")
310-
os.Exit(1)
311-
}
312-
}
313-
314-
if webhookCertWatcher != nil {
315-
setupLog.Info("Adding webhook certificate watcher to manager")
316-
if err := mgr.Add(webhookCertWatcher); err != nil {
317-
setupLog.Error(err, "unable to add webhook certificate watcher to manager")
318-
os.Exit(1)
319-
}
320-
}
321-
322233
if err := mgr.AddHealthzCheck("healthz", healthz.Ping); err != nil {
323234
setupLog.Error(err, "unable to set up health check")
324235
os.Exit(1)

config/crd/bases/pdok.nl_wms.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1862,7 +1862,7 @@ spec:
18621862
type: object
18631863
x-kubernetes-validations:
18641864
- message: A layer should have keywords when visible
1865-
rule: self.visible == false || has(self.keywords)
1865+
rule: '!self.visible || has(self.keywords)'
18661866
- message: A layer should have a title when visible
18671867
rule: '!self.visible || has(self.title)'
18681868
- message: A layer should have an abstract when visible
@@ -1935,7 +1935,7 @@ spec:
19351935
- message: A layer should have sublayers or data, not both
19361936
rule: (has(self.data) || has(self.layers)) && !(has(self.data) && has(self.layers))
19371937
- message: A layer should have keywords when visible
1938-
rule: self.visible == false || has(self.keywords)
1938+
rule: '!self.visible || has(self.keywords)'
19391939
- message: A layer should have a title when visible
19401940
rule: '!self.visible || has(self.title)'
19411941
- message: A layer should have an abstract when visible
@@ -2007,7 +2007,7 @@ spec:
20072007
- message: A layer should have sublayers or data, not both
20082008
rule: (has(self.data) || has(self.layers)) && !(has(self.data) && has(self.layers))
20092009
- message: A layer should have keywords when visible
2010-
rule: self.visible == false || has(self.keywords)
2010+
rule: '!self.visible || has(self.keywords)'
20112011
- message: A layer should have a title when visible
20122012
rule: '!self.visible || has(self.title)'
20132013
- message: A layer should have an abstract when visible

go.mod

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ require (
1414
github.com/pdok/ogc-capabilities-generator v1.0.0-beta7
1515
github.com/pdok/ogc-specifications v1.0.0-beta7
1616
github.com/pdok/smooth-operator v0.0.18
17+
github.com/peterbourgon/ff v1.7.1
1718
github.com/stretchr/testify v1.10.0
1819
github.com/traefik/traefik/v3 v3.3.4
1920
k8s.io/api v0.32.3
@@ -74,7 +75,7 @@ require (
7475
github.com/go-errors/errors v1.5.1 // indirect
7576
github.com/go-logr/logr v1.4.2 // indirect
7677
github.com/go-logr/stdr v1.2.2 // indirect
77-
github.com/go-logr/zapr v1.3.0
78+
github.com/go-logr/zapr v1.3.0 // indirect
7879
github.com/go-openapi/jsonpointer v0.21.0 // indirect
7980
github.com/go-openapi/jsonreference v0.21.0 // indirect
8081
github.com/go-openapi/swag v0.23.0 // indirect
@@ -114,7 +115,7 @@ require (
114115
go.opentelemetry.io/otel/trace v1.35.0 // indirect
115116
go.opentelemetry.io/proto/otlp v1.5.0 // indirect
116117
go.uber.org/multierr v1.11.0 // indirect
117-
go.uber.org/zap v1.27.0
118+
go.uber.org/zap v1.27.0 // indirect
118119
golang.org/x/exp v0.0.0-20241215155358-4a5509556b9e // indirect
119120
golang.org/x/net v0.38.0 // indirect
120121
golang.org/x/oauth2 v0.28.0 // indirect

go.sum

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
cel.dev/expr v0.19.1 h1:NciYrtDRIR0lNCnH1LFJegdjspNx9fI59O7TWcua/W4=
22
cel.dev/expr v0.19.1/go.mod h1:MrpN08Q+lEBs+bGYdLxxHkZoUSsCp0nSKTs0nTymJgw=
3+
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
34
github.com/BurntSushi/toml v1.4.1-0.20240526193622-a339e1f7089c h1:pxW6RcqyfI9/kWtOwnv/G+AzdKuy2ZrqINhenH4HyNs=
45
github.com/BurntSushi/toml v1.4.1-0.20240526193622-a339e1f7089c/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
56
github.com/antlr4-go/antlr/v4 v4.13.1 h1:SqQKkuVZ+zWkMMNkjy5FZe5mr5WURWnlpmOuzYWrPrQ=
@@ -134,6 +135,7 @@ github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWE
134135
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
135136
github.com/miekg/dns v1.1.62 h1:cN8OuEF1/x5Rq6Np+h1epln8OiyPWV+lROx9LxcGgIQ=
136137
github.com/miekg/dns v1.1.62/go.mod h1:mvDlcItzm+br7MToIKqkglaGhlFMHJ9DTNNWONWXbNQ=
138+
github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo=
137139
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
138140
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
139141
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
@@ -155,6 +157,9 @@ github.com/pdok/ogc-specifications v1.0.0-beta7 h1:AFSO8iCYbD1MrjOS2q+PGp2PmSqAH
155157
github.com/pdok/ogc-specifications v1.0.0-beta7/go.mod h1:YDngwkwrWOfc5MYnEYseiv97K1Y9bZXlVzwi/8EaIl8=
156158
github.com/pdok/smooth-operator v0.0.18 h1:cwgfNdnDSQgwgYBcoXszdaCIEdCU/d66VMqpCmv24qQ=
157159
github.com/pdok/smooth-operator v0.0.18/go.mod h1:ohDqrUnmS7wK8TrNHJnFS/mDgf26Yhb8mtRBX3ixdr4=
160+
github.com/pelletier/go-toml v1.6.0/go.mod h1:5N711Q9dKgbdkxHL+MEfF31hpT7l0S0s/t2kKREewys=
161+
github.com/peterbourgon/ff v1.7.1 h1:xt1lxTG+Nr2+tFtysY7abFgPoH3Lug8CwYJMOmJRXhk=
162+
github.com/peterbourgon/ff v1.7.1/go.mod h1:fYI5YA+3RDqQRExmFbHnBjEeWzh9TrS8rnRpEq7XIg0=
158163
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
159164
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
160165
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
@@ -315,6 +320,7 @@ golang.org/x/tools v0.31.0/go.mod h1:naFTU+Cev749tSJRXJlna0T3WxKvb1kWEx15xA4SdmQ
315320
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
316321
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
317322
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
323+
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
318324
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
319325
gomodules.xyz/jsonpatch/v2 v2.5.0 h1:JELs8RLM12qJGXU4u/TO3V25KW8GreMKl9pdkk14RM0=
320326
gomodules.xyz/jsonpatch/v2 v2.5.0/go.mod h1:AH3dM2RI6uoBZxn3LVrfvJ3E0/9dG4cSrbuBJT4moAY=
@@ -334,6 +340,7 @@ gopkg.in/evanphx/json-patch.v4 v4.12.0 h1:n6jtcsulIzXPJaxegRbvFNNrZDjbij7ny3gmSP
334340
gopkg.in/evanphx/json-patch.v4 v4.12.0/go.mod h1:p8EYWUEYMpynmqDbY58zCKCFZw8pRWMG4EsWvDvM72M=
335341
gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc=
336342
gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
343+
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
337344
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
338345
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
339346
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=

internal/controller/mapserver/deployment.go

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -217,11 +217,9 @@ func GetEnvVarsForDeployment[O pdoknlv3.WMSWFS](obj O, blobsSecretName string) [
217217

218218
// Resources for mapserver container
219219
func GetResourcesForDeployment[O pdoknlv3.WMSWFS](obj O) v1.ResourceRequirements {
220-
minimumEphemeralStorageLimit := resource.MustParse("200M")
221220
resources := v1.ResourceRequirements{
222221
Limits: v1.ResourceList{
223-
v1.ResourceMemory: resource.MustParse("800M"),
224-
v1.ResourceEphemeralStorage: minimumEphemeralStorageLimit,
222+
v1.ResourceMemory: resource.MustParse("800M"),
225223
},
226224
Requests: v1.ResourceList{
227225
v1.ResourceCPU: resource.MustParse("0.15"),
@@ -258,16 +256,25 @@ func GetResourcesForDeployment[O pdoknlv3.WMSWFS](obj O) v1.ResourceRequirements
258256
}
259257

260258
if use, _ := mapperutils.UseEphemeralVolume(obj); !use {
261-
value := mapperutils.EphemeralStorageLimit(obj)
259+
minimumEphemeralStorageLimit := resource.MustParse("200M")
260+
ephemeralStorageRequest := mapperutils.EphemeralStorageRequest(obj)
261+
ephemeralStorageLimit := mapperutils.EphemeralStorageLimit(obj)
262262

263-
if objResources.Limits.StorageEphemeral() != nil && objResources.Limits.StorageEphemeral().Value() > minimumEphemeralStorageLimit.Value() {
264-
resources.Limits[v1.ResourceEphemeralStorage] = *value
263+
if ephemeralStorageRequest != nil {
264+
resources.Requests[v1.ResourceEphemeralStorage] = *ephemeralStorageRequest
265265
}
266-
}
267266

268-
ephemeralStorageRequest := mapperutils.EphemeralStorageRequest(obj)
269-
if ephemeralStorageRequest != nil {
270-
resources.Requests[v1.ResourceEphemeralStorage] = *ephemeralStorageRequest
267+
if ephemeralStorageLimit != nil && ephemeralStorageLimit.Value() > minimumEphemeralStorageLimit.Value() {
268+
// Request higher than limit, use request as limit
269+
if ephemeralStorageRequest != nil && ephemeralStorageRequest.Value() > ephemeralStorageLimit.Value() {
270+
resources.Limits[v1.ResourceEphemeralStorage] = *ephemeralStorageRequest
271+
} else {
272+
resources.Limits[v1.ResourceEphemeralStorage] = *ephemeralStorageLimit
273+
}
274+
} else {
275+
// No limit given or the given limit is lower than the default, use default
276+
resources.Limits[v1.ResourceEphemeralStorage] = minimumEphemeralStorageLimit
277+
}
271278
}
272279

273280
return resources

internal/controller/mapserver/deployment_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ func TestGetResourcesForDeployment(t *testing.T) {
5050
expectedRequest := v1.ResourceList{}
5151

5252
expectedLimits[v1.ResourceMemory] = resource.MustParse("800M")
53-
expectedLimits[v1.ResourceEphemeralStorage] = resource.MustParse("1505Mi")
53+
expectedLimits[v1.ResourceEphemeralStorage] = resource.MustParse("505Mi")
5454

5555
expectedRequest[v1.ResourceCPU] = resource.MustParse("0.15")
56-
expectedRequest[v1.ResourceEphemeralStorage] = resource.MustParse("1505Mi")
56+
expectedRequest[v1.ResourceEphemeralStorage] = resource.MustParse("255Mi")
5757

5858
var expected = v1.ResourceRequirements{
5959
Limits: expectedLimits,

internal/controller/mapserver/test_data/v2_input.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ spec:
2121
querystring: SERVICE=WFS&VERSION=2.0.0&REQUEST=GetCapabilities
2222
resources:
2323
limits:
24-
ephemeralStorage: 1505Mi
24+
ephemeralStorage: 505Mi
2525
requests:
26-
ephemeralStorage: 1505Mi
26+
ephemeralStorage: 255Mi
2727
service:
2828
title: NWB - Wegen WFS
2929
abstract:

0 commit comments

Comments
 (0)