Skip to content

Commit

Permalink
Added script to update the prometheus-to-sd library.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
cheftako committed Oct 4, 2024
1 parent bac1bde commit bfbe60c
Show file tree
Hide file tree
Showing 13 changed files with 39 additions and 15 deletions.
24 changes: 24 additions & 0 deletions hack/update-images.sh
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion operator/config/gke-addon/image_configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit bfbe60c

Please sign in to comment.