From bfbe60c0c10d22021506992b25f37fbc284710be Mon Sep 17 00:00:00 2001 From: Walter Fender Date: Fri, 4 Oct 2024 21:02:06 +0000 Subject: [PATCH] Added script to update the prometheus-to-sd library. Need to have gcrane installed. However the script finds the new version and will fix yaml files to use that. Expect to extend this to update other images as well. Formatted script. --- hack/update-images.sh | 24 +++++++++++++++++++ .../workload-identity/0-cnrm-system.yaml | 4 ++-- .../1.121.0/namespaced/0-cnrm-system.yaml | 2 +- .../namespaced/per-namespace-components.yaml | 2 +- .../workload-identity/0-cnrm-system.yaml | 4 ++-- .../1.122.0/namespaced/0-cnrm-system.yaml | 2 +- .../namespaced/per-namespace-components.yaml | 2 +- .../workload-identity/0-cnrm-system.yaml | 4 ++-- .../1.123.1/namespaced/0-cnrm-system.yaml | 2 +- .../namespaced/per-namespace-components.yaml | 2 +- .../config/gke-addon/image_configmap.yaml | 2 +- .../manager_sidecar_patch.yaml | 2 +- .../recorder_sidecar_patch.yaml | 2 +- 13 files changed, 39 insertions(+), 15 deletions(-) create mode 100755 hack/update-images.sh diff --git a/hack/update-images.sh b/hack/update-images.sh new file mode 100755 index 00000000000..006ec1531b7 --- /dev/null +++ b/hack/update-images.sh @@ -0,0 +1,24 @@ +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#/bin/bash +export PROM_2_SD_VERSION="$(gcrane ls gcr.io/gke-release/prometheus-to-sd | egrep "prometheus-to-sd:v" | sort -r --version-sort | head -1)" +echo "Switching to use the $PROM_2_SD_VERSION image" +for file in `find . -name '*.yaml'` +do + if grep -q "gke.gcr.io/prometheus-to-sd" $file + then + sed -i -E "s|gcr.io/gke-release/prometheus-to-sd:.*|$PROM_2_SD_VERSION|g" $file + fi +done diff --git a/operator/channels/packages/configconnector/1.121.0/cluster/workload-identity/0-cnrm-system.yaml b/operator/channels/packages/configconnector/1.121.0/cluster/workload-identity/0-cnrm-system.yaml index e0aea758bd8..d802f61b065 100644 --- a/operator/channels/packages/configconnector/1.121.0/cluster/workload-identity/0-cnrm-system.yaml +++ b/operator/channels/packages/configconnector/1.121.0/cluster/workload-identity/0-cnrm-system.yaml @@ -2559,7 +2559,7 @@ spec: valueFrom: fieldRef: fieldPath: metadata.namespace - image: gke.gcr.io/prometheus-to-sd:v0.11.12-gke.11 + image: gcr.io/gke-release/prometheus-to-sd:v0.11.12-gke.11 name: prom-to-sd securityContext: allowPrivilegeEscalation: false @@ -2693,7 +2693,7 @@ spec: valueFrom: fieldRef: fieldPath: metadata.namespace - image: gke.gcr.io/prometheus-to-sd:v0.11.12-gke.11 + image: gcr.io/gke-release/prometheus-to-sd:v0.11.12-gke.11 name: prom-to-sd securityContext: allowPrivilegeEscalation: false diff --git a/operator/channels/packages/configconnector/1.121.0/namespaced/0-cnrm-system.yaml b/operator/channels/packages/configconnector/1.121.0/namespaced/0-cnrm-system.yaml index b147e7f7835..e7748094e13 100644 --- a/operator/channels/packages/configconnector/1.121.0/namespaced/0-cnrm-system.yaml +++ b/operator/channels/packages/configconnector/1.121.0/namespaced/0-cnrm-system.yaml @@ -2550,7 +2550,7 @@ spec: valueFrom: fieldRef: fieldPath: metadata.namespace - image: gke.gcr.io/prometheus-to-sd:v0.11.12-gke.11 + image: gcr.io/gke-release/prometheus-to-sd:v0.11.12-gke.11 name: prom-to-sd securityContext: allowPrivilegeEscalation: false diff --git a/operator/channels/packages/configconnector/1.121.0/namespaced/per-namespace-components.yaml b/operator/channels/packages/configconnector/1.121.0/namespaced/per-namespace-components.yaml index 8fc4c27bad7..15084e325de 100644 --- a/operator/channels/packages/configconnector/1.121.0/namespaced/per-namespace-components.yaml +++ b/operator/channels/packages/configconnector/1.121.0/namespaced/per-namespace-components.yaml @@ -181,7 +181,7 @@ spec: valueFrom: fieldRef: fieldPath: metadata.namespace - image: gke.gcr.io/prometheus-to-sd:v0.11.12-gke.11 + image: gcr.io/gke-release/prometheus-to-sd:v0.11.12-gke.11 name: prom-to-sd securityContext: allowPrivilegeEscalation: false diff --git a/operator/channels/packages/configconnector/1.122.0/cluster/workload-identity/0-cnrm-system.yaml b/operator/channels/packages/configconnector/1.122.0/cluster/workload-identity/0-cnrm-system.yaml index 0417211715f..4ebd27a790e 100644 --- a/operator/channels/packages/configconnector/1.122.0/cluster/workload-identity/0-cnrm-system.yaml +++ b/operator/channels/packages/configconnector/1.122.0/cluster/workload-identity/0-cnrm-system.yaml @@ -2559,7 +2559,7 @@ spec: valueFrom: fieldRef: fieldPath: metadata.namespace - image: gke.gcr.io/prometheus-to-sd:v0.11.12-gke.11 + image: gcr.io/gke-release/prometheus-to-sd:v0.11.12-gke.11 name: prom-to-sd securityContext: allowPrivilegeEscalation: false @@ -2693,7 +2693,7 @@ spec: valueFrom: fieldRef: fieldPath: metadata.namespace - image: gke.gcr.io/prometheus-to-sd:v0.11.12-gke.11 + image: gcr.io/gke-release/prometheus-to-sd:v0.11.12-gke.11 name: prom-to-sd securityContext: allowPrivilegeEscalation: false diff --git a/operator/channels/packages/configconnector/1.122.0/namespaced/0-cnrm-system.yaml b/operator/channels/packages/configconnector/1.122.0/namespaced/0-cnrm-system.yaml index 3c79a854942..c8ea9ec36c4 100644 --- a/operator/channels/packages/configconnector/1.122.0/namespaced/0-cnrm-system.yaml +++ b/operator/channels/packages/configconnector/1.122.0/namespaced/0-cnrm-system.yaml @@ -2550,7 +2550,7 @@ spec: valueFrom: fieldRef: fieldPath: metadata.namespace - image: gke.gcr.io/prometheus-to-sd:v0.11.12-gke.11 + image: gcr.io/gke-release/prometheus-to-sd:v0.11.12-gke.11 name: prom-to-sd securityContext: allowPrivilegeEscalation: false diff --git a/operator/channels/packages/configconnector/1.122.0/namespaced/per-namespace-components.yaml b/operator/channels/packages/configconnector/1.122.0/namespaced/per-namespace-components.yaml index 9a25a582831..5f636b54430 100644 --- a/operator/channels/packages/configconnector/1.122.0/namespaced/per-namespace-components.yaml +++ b/operator/channels/packages/configconnector/1.122.0/namespaced/per-namespace-components.yaml @@ -181,7 +181,7 @@ spec: valueFrom: fieldRef: fieldPath: metadata.namespace - image: gke.gcr.io/prometheus-to-sd:v0.11.12-gke.11 + image: gcr.io/gke-release/prometheus-to-sd:v0.11.12-gke.11 name: prom-to-sd securityContext: allowPrivilegeEscalation: false diff --git a/operator/channels/packages/configconnector/1.123.1/cluster/workload-identity/0-cnrm-system.yaml b/operator/channels/packages/configconnector/1.123.1/cluster/workload-identity/0-cnrm-system.yaml index 41e18c4a01e..e6882b910b1 100644 --- a/operator/channels/packages/configconnector/1.123.1/cluster/workload-identity/0-cnrm-system.yaml +++ b/operator/channels/packages/configconnector/1.123.1/cluster/workload-identity/0-cnrm-system.yaml @@ -2559,7 +2559,7 @@ spec: valueFrom: fieldRef: fieldPath: metadata.namespace - image: gke.gcr.io/prometheus-to-sd:v0.11.12-gke.11 + image: gcr.io/gke-release/prometheus-to-sd:v0.11.12-gke.11 name: prom-to-sd securityContext: allowPrivilegeEscalation: false @@ -2693,7 +2693,7 @@ spec: valueFrom: fieldRef: fieldPath: metadata.namespace - image: gke.gcr.io/prometheus-to-sd:v0.11.12-gke.11 + image: gcr.io/gke-release/prometheus-to-sd:v0.11.12-gke.11 name: prom-to-sd securityContext: allowPrivilegeEscalation: false diff --git a/operator/channels/packages/configconnector/1.123.1/namespaced/0-cnrm-system.yaml b/operator/channels/packages/configconnector/1.123.1/namespaced/0-cnrm-system.yaml index 35ddc895bf6..18ef765e8dd 100644 --- a/operator/channels/packages/configconnector/1.123.1/namespaced/0-cnrm-system.yaml +++ b/operator/channels/packages/configconnector/1.123.1/namespaced/0-cnrm-system.yaml @@ -2550,7 +2550,7 @@ spec: valueFrom: fieldRef: fieldPath: metadata.namespace - image: gke.gcr.io/prometheus-to-sd:v0.11.12-gke.11 + image: gcr.io/gke-release/prometheus-to-sd:v0.11.12-gke.11 name: prom-to-sd securityContext: allowPrivilegeEscalation: false diff --git a/operator/channels/packages/configconnector/1.123.1/namespaced/per-namespace-components.yaml b/operator/channels/packages/configconnector/1.123.1/namespaced/per-namespace-components.yaml index 3b4e86c0a8e..6bf9114bb64 100644 --- a/operator/channels/packages/configconnector/1.123.1/namespaced/per-namespace-components.yaml +++ b/operator/channels/packages/configconnector/1.123.1/namespaced/per-namespace-components.yaml @@ -181,7 +181,7 @@ spec: valueFrom: fieldRef: fieldPath: metadata.namespace - image: gke.gcr.io/prometheus-to-sd:v0.11.12-gke.11 + image: gcr.io/gke-release/prometheus-to-sd:v0.11.12-gke.11 name: prom-to-sd securityContext: allowPrivilegeEscalation: false diff --git a/operator/config/gke-addon/image_configmap.yaml b/operator/config/gke-addon/image_configmap.yaml index 4600b867f58..287d568ca18 100644 --- a/operator/config/gke-addon/image_configmap.yaml +++ b/operator/config/gke-addon/image_configmap.yaml @@ -5,7 +5,7 @@ data: cnrm.recorder: gcr.io/gke-release/cnrm/recorder:826b049 cnrm.unmanageddetector: gcr.io/gke-release/cnrm/unmanageddetector:826b049 cnrm.webhook: gcr.io/gke-release/cnrm/webhook:826b049 - prom-to-sd: gke.gcr.io/prometheus-to-sd:v0.11.12-gke.11 + prom-to-sd: gcr.io/gke-release/prometheus-to-sd:v0.11.12-gke.11 kind: ConfigMap metadata: annotations: diff --git a/operator/scripts/update-kcc-manifest/manager_sidecar_patch.yaml b/operator/scripts/update-kcc-manifest/manager_sidecar_patch.yaml index e8898b3fabc..c3039c50adf 100644 --- a/operator/scripts/update-kcc-manifest/manager_sidecar_patch.yaml +++ b/operator/scripts/update-kcc-manifest/manager_sidecar_patch.yaml @@ -19,7 +19,7 @@ - /monitor - --source=configconnector:http://localhost:8888?whitelisted=reconcile_requests_total,reconcile_request_duration_seconds,reconcile_workers_total,reconcile_occupied_workers_total,internal_errors_total&customResourceType=k8s_container&customLabels[container_name]&customLabels[project_id]&customLabels[location]&customLabels[cluster_name]&customLabels[namespace_name]=$(POD_NAMESPACE)&customLabels[pod_name]=$(POD_NAME) - --stackdriver-prefix=kubernetes.io/internal/addons - image: gke.gcr.io/prometheus-to-sd:v0.11.12-gke.11 + image: gcr.io/gke-release/prometheus-to-sd:v0.11.12-gke.11 name: prom-to-sd env: - name: POD_NAME diff --git a/operator/scripts/update-kcc-manifest/recorder_sidecar_patch.yaml b/operator/scripts/update-kcc-manifest/recorder_sidecar_patch.yaml index 034d2f13667..0ade3836aac 100644 --- a/operator/scripts/update-kcc-manifest/recorder_sidecar_patch.yaml +++ b/operator/scripts/update-kcc-manifest/recorder_sidecar_patch.yaml @@ -19,7 +19,7 @@ - /monitor - --source=configconnector:http://localhost:48797?whitelisted=applied_resources_total&customResourceType=k8s_container&customLabels[container_name]&customLabels[project_id]&customLabels[location]&customLabels[cluster_name]&customLabels[namespace_name]=$(POD_NAMESPACE)&customLabels[pod_name]=$(POD_NAME) - --stackdriver-prefix=kubernetes.io/internal/addons - image: gke.gcr.io/prometheus-to-sd:v0.11.12-gke.11 + image: gcr.io/gke-release/prometheus-to-sd:v0.11.12-gke.11 name: prom-to-sd env: - name: POD_NAME