From 25dfc15196ae3bd9ff00465776116357f6842615 Mon Sep 17 00:00:00 2001 From: Timo Hankamer Date: Thu, 26 Oct 2023 08:07:03 +0200 Subject: [PATCH] fix: Change from nodeLocations to regions to reflect current StatusCake API Issue: #540 --- api/v1alpha1/endpointmonitor_types.go | 2 +- .../endpointmonitor.stakater.com_endpointmonitors.yaml | 4 ++-- charts/ingressmonitorcontroller/Chart.yaml | 4 ++-- .../endpointmonitor.stakater.com_endpointmonitors.yaml | 4 ++-- charts/ingressmonitorcontroller/values.yaml | 6 +++--- .../endpointmonitor.stakater.com_endpointmonitors.yaml | 6 +++--- config/manager/kustomization.yaml | 2 +- docs/statuscake-configuration.md | 7 ++++--- examples/endpointMonitor/statuscake-config.yaml | 1 + pkg/monitors/statuscake/statuscake-monitor.go | 7 +++++++ 10 files changed, 26 insertions(+), 17 deletions(-) diff --git a/api/v1alpha1/endpointmonitor_types.go b/api/v1alpha1/endpointmonitor_types.go index 48f241f3..fa3700d2 100644 --- a/api/v1alpha1/endpointmonitor_types.go +++ b/api/v1alpha1/endpointmonitor_types.go @@ -197,7 +197,7 @@ type StatusCakeConfig struct { // Comma separated list of Node Location IDs // +optional - NodeLocations string `json:"nodeLocations,omitempty"` + Regions string `json:"regions,omitempty"` // Comma separated list of HTTP codes to trigger error on // +optional diff --git a/bundle/manifests/endpointmonitor.stakater.com_endpointmonitors.yaml b/bundle/manifests/endpointmonitor.stakater.com_endpointmonitors.yaml index a014cb9c..11ecdf06 100644 --- a/bundle/manifests/endpointmonitor.stakater.com_endpointmonitors.yaml +++ b/bundle/manifests/endpointmonitor.stakater.com_endpointmonitors.yaml @@ -152,8 +152,8 @@ spec: followRedirect: description: Enable ingress redirects type: boolean - nodeLocations: - description: Comma separated list of Node Location IDs + regions: + description: Comma separated list of regions. type: string paused: description: Pause the service diff --git a/charts/ingressmonitorcontroller/Chart.yaml b/charts/ingressmonitorcontroller/Chart.yaml index 3a765362..913cefd0 100644 --- a/charts/ingressmonitorcontroller/Chart.yaml +++ b/charts/ingressmonitorcontroller/Chart.yaml @@ -3,10 +3,10 @@ name: ingressmonitorcontroller description: IngressMonitorController Operator chart that runs on kubernetes # Helm chart Version -version: 2.1.44 +version: 2.1.45 # Application version to be deployed -appVersion: 2.1.44 +appVersion: 2.1.45 keywords: - IngressMonitorController diff --git a/charts/ingressmonitorcontroller/crds/endpointmonitor.stakater.com_endpointmonitors.yaml b/charts/ingressmonitorcontroller/crds/endpointmonitor.stakater.com_endpointmonitors.yaml index 42d9e73c..fda61543 100644 --- a/charts/ingressmonitorcontroller/crds/endpointmonitor.stakater.com_endpointmonitors.yaml +++ b/charts/ingressmonitorcontroller/crds/endpointmonitor.stakater.com_endpointmonitors.yaml @@ -153,8 +153,8 @@ spec: followRedirect: description: Enable ingress redirects type: boolean - nodeLocations: - description: Comma separated list of Node Location IDs + regions: + description: Comma separated list of regions. type: string paused: description: Pause the service diff --git a/charts/ingressmonitorcontroller/values.yaml b/charts/ingressmonitorcontroller/values.yaml index e3cf72e7..2fc57017 100644 --- a/charts/ingressmonitorcontroller/values.yaml +++ b/charts/ingressmonitorcontroller/values.yaml @@ -8,7 +8,7 @@ replicaCount: 1 image: repository: stakater/ingressmonitorcontroller - tag: v2.1.44 + tag: v2.1.45 pullPolicy: IfNotPresent imagePullSecrets: [] @@ -17,7 +17,7 @@ kube-rbac-proxy: repository: gcr.io/kubebuilder/kube-rbac-proxy tag: v0.8.0 pullPolicy: IfNotPresent - resources: + resources: {} securityContext: {} @@ -100,4 +100,4 @@ env: [] envFrom: [] -serviceManagedBy: helm \ No newline at end of file +serviceManagedBy: helm diff --git a/config/crd/bases/endpointmonitor.stakater.com_endpointmonitors.yaml b/config/crd/bases/endpointmonitor.stakater.com_endpointmonitors.yaml index 42d9e73c..9b920f70 100644 --- a/config/crd/bases/endpointmonitor.stakater.com_endpointmonitors.yaml +++ b/config/crd/bases/endpointmonitor.stakater.com_endpointmonitors.yaml @@ -153,9 +153,6 @@ spec: followRedirect: description: Enable ingress redirects type: boolean - nodeLocations: - description: Comma separated list of Node Location IDs - type: string paused: description: Pause the service type: boolean @@ -168,6 +165,9 @@ spec: realBrowser: description: Enable Real Browser type: boolean + regions: + description: Comma separated list of Node Location IDs + type: string statusCodes: description: Comma separated list of HTTP codes to trigger error on diff --git a/config/manager/kustomization.yaml b/config/manager/kustomization.yaml index 2b83c753..e17468fa 100644 --- a/config/manager/kustomization.yaml +++ b/config/manager/kustomization.yaml @@ -13,4 +13,4 @@ kind: Kustomization images: - name: controller newName: stakater/ingressmonitorcontroller - newTag: v2.1.44 + newTag: v2.1.45 diff --git a/docs/statuscake-configuration.md b/docs/statuscake-configuration.md index 3e319617..bd0c62bf 100644 --- a/docs/statuscake-configuration.md +++ b/docs/statuscake-configuration.md @@ -1,7 +1,7 @@ # StatusCake Configuration ## Basic -The following properties need to be configured for Statuscake, in addition to the general properties listed +The following properties need to be configured for Statuscake, in addition to the general properties listed in the [Configuration section of the README](../README.md#configuration): | Key | Description | @@ -25,15 +25,16 @@ Currently additional Statuscake configurations can be added through these fields | TestTags | Comma separated list of tags | | FindString | String to look for within the response | | BasicAuthUser | Required for [basic-authenticationchecks](#basic-auth-checks) | +| Regions | Regions to execute the check from | ### Basic Auth checks Statuscake supports checks completing basic auth requirements. In `EndpointMonitor` the field `basicAuthUser` can be used to trigger the Ingress Monitor attempting to configure this setting. The value of the field should be the *username* to be configured. The Ingress Monitor Controller will then attempt to access an OS env variable of the same name which will return the *password* that should be used. The env variable can be mounted within the Ingress Monitor Controller container via a secret. -For example; setting the field like `basic-auth-user: 'my-service-username'` will set the username field to the value `my-service-username` and will retrieve the password via `os.Getenv('my-service-username')` and set this appropriately. +For example; setting the field like `basic-auth-user: 'my-service-username'` will set the username field to the value `my-service-username` and will retrieve the password via `os.Getenv('my-service-username')` and set this appropriately. -## Example: +## Example: ```yaml apiVersion: endpointmonitor.stakater.com/v1alpha1 diff --git a/examples/endpointMonitor/statuscake-config.yaml b/examples/endpointMonitor/statuscake-config.yaml index 84ed75ac..bf4f64eb 100644 --- a/examples/endpointMonitor/statuscake-config.yaml +++ b/examples/endpointMonitor/statuscake-config.yaml @@ -19,4 +19,5 @@ spec: triggerRate: 1 pingUrl: 'https://stakater2.com/' contactGroup: '123456,654321' + regions: amsterdam, stockholm url: 'https://stakater1.com/' diff --git a/pkg/monitors/statuscake/statuscake-monitor.go b/pkg/monitors/statuscake/statuscake-monitor.go index 9bc95e67..0ed9b13e 100644 --- a/pkg/monitors/statuscake/statuscake-monitor.go +++ b/pkg/monitors/statuscake/statuscake-monitor.go @@ -79,6 +79,13 @@ func buildUpsertForm(m models.Monitor, cgroup string) url.Values { } } + if providerConfig != nil && len(providerConfig.Regions) > 0 { + regions := convertStringToArray(providerConfig.Regions) + for _, region := range regions { + f.Add("regions[]", region) + } + } + if providerConfig != nil && len(providerConfig.BasicAuthUser) > 0 { // This value is mandatory // Environment variable should define the password