diff --git a/.gitignore b/.gitignore index 9f0f3a1..77ab95f 100644 --- a/.gitignore +++ b/.gitignore @@ -15,6 +15,7 @@ Dockerfile.cross # Go workspace file go.work +go.work.sum # Kubernetes Generated files - skip generated files, except for vendored files !vendor/**/zz_generated.* diff --git a/README.md b/README.md index 3e1e678..9bacf54 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # mapserver-operator + _Kubernetes controller/operator to serve WFS and WMS instances._ [![Build](https://github.com/PDOK/mapserver-operator/actions/workflows/build-and-publish-image.yml/badge.svg)](https://github.com/PDOK/mapserver-operator/actions/workflows/build-and-publish-image.yml) @@ -6,6 +7,7 @@ _Kubernetes controller/operator to serve WFS and WMS instances._ [![GitHub license](https://img.shields.io/github/license/PDOK/mapserver-operator)](https://github.com/PDOK/mapserver-operator/blob/master/LICENSE) ## Description + This Kubernetes controller cq operator (an operator could be described as a specialized controller) ensures that the necessary resources are created or kept up-to-date in a cluster to deploy instances of the [Web Map Service](https://www.ogc.org/standards/wms/)(WMS) and [Web Features Service](https://www.ogc.org/standards/wfs/)(WFS). This repository is a complete solution to deploy WMS and WFS services according to CR schemas. @@ -14,12 +16,14 @@ This operator uses two Custom Resources(CR) called _WMS_ and _WFS_ as the input ## Getting Started ### Prerequisites + - go version v1.26.0+ - docker version 17.03+. - kubectl version v1.11.3+. - Access to a Kubernetes v1.11.3+ cluster. ### To Deploy on the cluster + **Build and push your image to the location specified by `IMG`:** ```sh @@ -55,6 +59,7 @@ kubectl apply -k config/samples/ >**NOTE**: Ensure that the samples has default values to test it out. ### To Uninstall + **Delete the instances (CRs) from the cluster:** ```sh @@ -73,6 +78,17 @@ make uninstall make undeploy ``` +## Command-line flags + +### Reloader annotations + +Use `--set-reloader-annotations=search` to set `reloader.stakater.com/search=true` on Deployments. +Search mode requires `reloader.stakater.com/match=true` on the referenced ConfigMaps or Secrets. +Use `=auto` to set `reloader.stakater.com/auto=true` instead. +For backwards compatibility, the bare flag and `=true` still select auto mode. +The default (`=false`) disables both annotations; switching modes removes the other annotation. +The equivalent environment variable is `SET_RELOADER_ANNOTATIONS`. + ## Develop The project is written in Go and scaffolded with [kubebuilder](https://kubebuilder.io). @@ -83,6 +99,7 @@ Read the manual when you want/need to make changes. E.g. run `make test` before committing. To update the scaffolding: + - Install the latest version of kubebuilder globally on your machine; - Run: `kubebuilder alpha update --from-branch master` @@ -92,13 +109,16 @@ Install [golangci-lint](https://golangci-lint.run/usage/install/) and run `golan from the root. (Don't run `make lint`, it uses an old version of golangci-lint.) -# Contributing +## Contributing ### How to contribute + Mapserver-operator is solely developed by PDOK. Contributions are however always welcome. If you have any questions or suggestions you can create an issue in the issue tracker. ### Contact + The maintainers can be contacted through the issue tracker. -# Authors +## Authors + This project is developed by [PDOK](https://www.pdok.nl/), a platform for publication of geographic datasets of Dutch governmental institutions. diff --git a/go.mod b/go.mod index 9b870e3..e9142fc 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/pdok/featureinfo-generator v1.5.0 github.com/pdok/ogc-capabilities-generator v1.0.4 github.com/pdok/ogc-specifications v1.0.7 - github.com/pdok/smooth-operator v1.3.0 + github.com/pdok/smooth-operator v1.3.1 github.com/peterbourgon/ff v1.7.1 github.com/stretchr/testify v1.12.1 github.com/traefik/traefik/v3 v3.7.16 diff --git a/go.sum b/go.sum index c002d2d..8033ccf 100644 --- a/go.sum +++ b/go.sum @@ -189,8 +189,8 @@ github.com/pdok/ogc-capabilities-generator v1.0.4 h1:SPTQjlITPK7xrOU6Y6bLK4I1MSk github.com/pdok/ogc-capabilities-generator v1.0.4/go.mod h1:/ryq2/xD1ulgop21OwPVtXYHgKEcRQQ+64HYo20ZHWs= github.com/pdok/ogc-specifications v1.0.7 h1:ZWmDr7mjfhvCT5okKYNl7MqSm9k2zkJRnPLj/bnbMUY= github.com/pdok/ogc-specifications v1.0.7/go.mod h1:GYFKRtWDDKS/elBRXQvGoMLL97yrtdRqyCFmnb4iPTA= -github.com/pdok/smooth-operator v1.3.0 h1:STIrzo1n3mY38RxD899sfzFiYkeyWHuIpQ6jcdQVtzI= -github.com/pdok/smooth-operator v1.3.0/go.mod h1:Z87CdfxCKTvb7lkd19w1q+bGK0XaqHfa/ppDD8Zpnq0= +github.com/pdok/smooth-operator v1.3.1 h1:ycmKM77RcYz2XJdr+NQwvbkYDMzbeFgWt5In5W7Zj7I= +github.com/pdok/smooth-operator v1.3.1/go.mod h1:Z87CdfxCKTvb7lkd19w1q+bGK0XaqHfa/ppDD8Zpnq0= github.com/pelletier/go-toml v1.6.0/go.mod h1:5N711Q9dKgbdkxHL+MEfF31hpT7l0S0s/t2kKREewys= github.com/peterbourgon/ff v1.7.1 h1:xt1lxTG+Nr2+tFtysY7abFgPoH3Lug8CwYJMOmJRXhk= github.com/peterbourgon/ff v1.7.1/go.mod h1:fYI5YA+3RDqQRExmFbHnBjEeWzh9TrS8rnRpEq7XIg0= diff --git a/internal/controller/shared_controller_test.go b/internal/controller/shared_controller_test.go index 3ee6db0..7eec16a 100644 --- a/internal/controller/shared_controller_test.go +++ b/internal/controller/shared_controller_test.go @@ -2,6 +2,7 @@ package controller import ( "context" + "flag" "fmt" "os" "slices" @@ -331,18 +332,26 @@ func testMutates[R Reconciler, O pdoknlv3.WMSWFS](reconcilerFn func() R, resourc DeferCleanup(func() { reloader.SetReloaderAnnotations(originalEnabled) }) + flags := flag.NewFlagSet("reloader", flag.ContinueOnError) + reloader.BindFlag(flags) deployment := getBareDeployment(resource) - for _, enabled := range []bool{false, true, false} { - By(fmt.Sprintf("Mutating the Deployment with Reloader annotations enabled: %t", enabled)) - reloader.SetReloaderAnnotations(enabled) + const legacyAutoMode = "true" + for _, mode := range []string{"false", legacyAutoMode, "search", "auto", "false"} { + By("Mutating the Deployment with Reloader annotation mode: " + mode) + Expect(flags.Parse([]string{"--" + reloader.FlagName + "=" + mode})).To(Succeed()) Expect(mutateDeployment(reconcilerFn(), resource, deployment, configMapNames)).To(Succeed()) - if enabled { + if mode == legacyAutoMode || mode == "auto" { Expect(deployment.Annotations).To(HaveKeyWithValue(reloader.AutoAnnotation, reloader.AutoAnnotationValue)) } else { Expect(deployment.Annotations).NotTo(HaveKey(reloader.AutoAnnotation)) } + if mode == "search" { + Expect(deployment.Annotations).To(HaveKeyWithValue(reloader.SearchAnnotation, reloader.SearchAnnotationValue)) + } else { + Expect(deployment.Annotations).NotTo(HaveKey(reloader.SearchAnnotation)) + } } })