From 20936204e18004eb162333504fa4a6c7f049d482 Mon Sep 17 00:00:00 2001 From: ms-hujia <48512395+ms-hujia@users.noreply.github.com> Date: Fri, 27 Sep 2024 13:37:08 +0800 Subject: [PATCH] Add support to override image registry for custom environment (#983) [comment]: # (Note that your PR title should follow the conventional commit format: https://conventionalcommits.org/en/v1.0.0/#summary) # PR Description [comment]: # (The below checklist is for PRs adding new features. If a box is not checked, add a reason why it's not needed.) # New Feature Checklist - [ ] List telemetry added about the feature. - [ ] Link to the one-pager about the feature. - [ ] List any tasks necessary for release (3P docs, AKS RP chart changes, etc.) after merging the PR. - [ ] Attach results of scale and perf testing. [comment]: # (The below checklist is for code changes. Not all boxes necessarily need to be checked. Build, doc, and template changes do not need to fill out the checklist.) # Tests Checklist - [ ] Have end-to-end Ginkgo tests been run on your cluster and passed? To bootstrap your cluster to run the tests, follow [these instructions](/otelcollector/test/README.md#bootstrap-a-dev-cluster-to-run-ginkgo-tests). - Labels used when running the tests on your cluster: - [ ] `operator` - [ ] `windows` - [ ] `arm64` - [ ] `arc-extension` - [ ] `fips` - [ ] Have new tests been added? For features, have tests been added for this feature? For fixes, is there a test that could have caught this issue and could validate that the fix works? - [ ] Is a new scrape job needed? - [ ] The scrape job was added to the folder [test-cluster-yamls](/otelcollector/test/test-cluster-yamls/) in the correct configmap or as a CR. - [ ] Was a new test label added? - [ ] A string constant for the label was added to [constants.go](/otelcollector/test/utils/constants.go). - [ ] The label and description was added to the [test README](/otelcollector/test/README.md). - [ ] The label was added to this [PR checklist](/.github/pull_request_template). - [ ] The label was added as needed to [testkube-test-crs.yaml](/otelcollector/test/testkube/testkube-test-crs.yaml). - [ ] Are additional API server permissions needed for the new tests? - [ ] These permissions have been added to [api-server-permissions.yaml](/otelcollector/test/testkube/api-server-permissions.yaml). - [ ] Was a new test suite (a new folder under `/tests`) added? - [ ] The new test suite is included in [testkube-test-crs.yaml](/otelcollector/test/testkube/testkube-test-crs.yaml). Co-authored-by: Vishwanath --- .../templates/ama-metrics-daemonset.yaml | 12 ++++++------ .../templates/ama-metrics-deployment.yaml | 6 +++--- .../templates/ama-metrics-ksm-deployment.yaml | 2 +- .../templates/ama-metrics-targetallocator.yaml | 4 ++-- .../azure-monitor-metrics-addon/values-template.yaml | 3 +++ 5 files changed, 15 insertions(+), 12 deletions(-) diff --git a/otelcollector/deploy/addon-chart/azure-monitor-metrics-addon/templates/ama-metrics-daemonset.yaml b/otelcollector/deploy/addon-chart/azure-monitor-metrics-addon/templates/ama-metrics-daemonset.yaml index 591fc455a..bfb751ae2 100644 --- a/otelcollector/deploy/addon-chart/azure-monitor-metrics-addon/templates/ama-metrics-daemonset.yaml +++ b/otelcollector/deploy/addon-chart/azure-monitor-metrics-addon/templates/ama-metrics-daemonset.yaml @@ -26,7 +26,7 @@ spec: serviceAccountName: ama-metrics-serviceaccount containers: - name: prometheus-collector - image: "mcr.microsoft.com{{ .Values.AzureMonitorMetrics.ImageRepository }}:{{ .Values.AzureMonitorMetrics.ImageTag }}" + image: "{{ .Values.AzureMonitorMetrics.ImageRegistry }}{{ .Values.AzureMonitorMetrics.ImageRepository }}:{{ .Values.AzureMonitorMetrics.ImageTag }}" # image: "mcr.microsoft.com/azuremonitor/containerinsights/cidev/prometheus-collector/images:6.8.11-rashmi-upgrades-04-24-05-13-2024-9cabda9d" imagePullPolicy: IfNotPresent resources: @@ -119,7 +119,7 @@ spec: {{- if .Values.AzureMonitorMetrics }} {{- if .Values.AzureMonitorMetrics.KubeStateMetrics }} - name: KUBE_STATE_VERSION - value: "mcr.microsoft.com{{ .Values.AzureMonitorMetrics.KubeStateMetrics.ImageRepository }}:{{ .Values.AzureMonitorMetrics.KubeStateMetrics.ImageTag }}" + value: "{{ .Values.AzureMonitorMetrics.KubeStateMetrics.ImageRegistry }}{{ .Values.AzureMonitorMetrics.KubeStateMetrics.ImageRepository }}:{{ .Values.AzureMonitorMetrics.KubeStateMetrics.ImageTag }}" {{- end }} {{- end }} - name: NODE_EXPORTER_VERSION @@ -200,7 +200,7 @@ spec: - --secret-name=aad-msi-auth-token - --token-server-listening-port=7777 - --health-server-listening-port=9999 - image: "mcr.microsoft.com{{ .Values.AzureMonitorMetrics.AddonTokenAdapter.ImageRepository }}:{{ .Values.AzureMonitorMetrics.AddonTokenAdapter.ImageTag }}" + image: "{{ .Values.AzureMonitorMetrics.AddonTokenAdapter.ImageRegistry }}{{ .Values.AzureMonitorMetrics.AddonTokenAdapter.ImageRepository }}:{{ .Values.AzureMonitorMetrics.AddonTokenAdapter.ImageTag }}" imagePullPolicy: IfNotPresent env: - name: AZMON_COLLECT_ENV @@ -337,7 +337,7 @@ spec: serviceAccountName: ama-metrics-serviceaccount containers: - name: prometheus-collector - image: "mcr.microsoft.com{{ .Values.AzureMonitorMetrics.ImageRepository }}:{{ .Values.AzureMonitorMetrics.ImageTagWin }}" + image: "{{ .Values.AzureMonitorMetrics.ImageRegistry }}{{ .Values.AzureMonitorMetrics.ImageRepository }}:{{ .Values.AzureMonitorMetrics.ImageTagWin }}" imagePullPolicy: IfNotPresent resources: limits: @@ -395,7 +395,7 @@ spec: {{- if .Values.AzureMonitorMetrics }} {{- if .Values.AzureMonitorMetrics.KubeStateMetrics }} - name: KUBE_STATE_VERSION - value: "mcr.microsoft.com{{ .Values.AzureMonitorMetrics.KubeStateMetrics.ImageRepository }}:{{ .Values.AzureMonitorMetrics.KubeStateMetrics.ImageTagWin }}" + value: "{{ .Values.AzureMonitorMetrics.KubeStateMetrics.ImageRegistry }}{{ .Values.AzureMonitorMetrics.KubeStateMetrics.ImageRepository }}:{{ .Values.AzureMonitorMetrics.KubeStateMetrics.ImageTagWin }}" {{- end }} {{- end }} - name: NODE_EXPORTER_VERSION @@ -455,7 +455,7 @@ spec: - --secret-name=aad-msi-auth-token - --token-server-listening-port=7777 - --health-server-listening-port=9999 - image: "mcr.microsoft.com{{ .Values.AzureMonitorMetrics.AddonTokenAdapter.ImageRepositoryWin }}:{{ .Values.AzureMonitorMetrics.AddonTokenAdapter.ImageTagWin }}" + image: "{{ .Values.AzureMonitorMetrics.AddonTokenAdapter.ImageRegistry }}{{ .Values.AzureMonitorMetrics.AddonTokenAdapter.ImageRepositoryWin }}:{{ .Values.AzureMonitorMetrics.AddonTokenAdapter.ImageTagWin }}" imagePullPolicy: IfNotPresent livenessProbe: httpGet: diff --git a/otelcollector/deploy/addon-chart/azure-monitor-metrics-addon/templates/ama-metrics-deployment.yaml b/otelcollector/deploy/addon-chart/azure-monitor-metrics-addon/templates/ama-metrics-deployment.yaml index b4355d740..1dd7d0c14 100644 --- a/otelcollector/deploy/addon-chart/azure-monitor-metrics-addon/templates/ama-metrics-deployment.yaml +++ b/otelcollector/deploy/addon-chart/azure-monitor-metrics-addon/templates/ama-metrics-deployment.yaml @@ -44,7 +44,7 @@ spec: serviceAccountName: ama-metrics-serviceaccount containers: - name: prometheus-collector - image: "mcr.microsoft.com{{ .Values.AzureMonitorMetrics.ImageRepository }}:{{ .Values.AzureMonitorMetrics.ImageTag }}" + image: "{{ .Values.AzureMonitorMetrics.ImageRegistry }}{{ .Values.AzureMonitorMetrics.ImageRepository }}:{{ .Values.AzureMonitorMetrics.ImageTag }}" imagePullPolicy: IfNotPresent resources: limits: @@ -149,7 +149,7 @@ spec: {{- if .Values.AzureMonitorMetrics }} {{- if .Values.AzureMonitorMetrics.KubeStateMetrics }} - name: KUBE_STATE_VERSION - value: "mcr.microsoft.com{{ .Values.AzureMonitorMetrics.KubeStateMetrics.ImageRepository }}:{{ .Values.AzureMonitorMetrics.KubeStateMetrics.ImageTag }}" + value: "{{ .Values.AzureMonitorMetrics.KubeStateMetrics.ImageRegistry }}{{ .Values.AzureMonitorMetrics.KubeStateMetrics.ImageRepository }}:{{ .Values.AzureMonitorMetrics.KubeStateMetrics.ImageTag }}" {{- if .Values.AzureMonitorMetrics.KubeStateMetrics.MetricLabelsAllowlist }} - name: KUBE_STATE_METRIC_LABELS_ALLOWLIST value: "{{ .Values.AzureMonitorMetrics.KubeStateMetrics.MetricLabelsAllowlist }}" @@ -240,7 +240,7 @@ spec: - --secret-name=aad-msi-auth-token - --token-server-listening-port=7777 - --health-server-listening-port=9999 - image: "mcr.microsoft.com{{ .Values.AzureMonitorMetrics.AddonTokenAdapter.ImageRepository }}:{{ .Values.AzureMonitorMetrics.AddonTokenAdapter.ImageTag }}" + image: "{{ .Values.AzureMonitorMetrics.AddonTokenAdapter.ImageRegistry }}{{ .Values.AzureMonitorMetrics.AddonTokenAdapter.ImageRepository }}:{{ .Values.AzureMonitorMetrics.AddonTokenAdapter.ImageTag }}" imagePullPolicy: IfNotPresent env: - name: AZMON_COLLECT_ENV diff --git a/otelcollector/deploy/addon-chart/azure-monitor-metrics-addon/templates/ama-metrics-ksm-deployment.yaml b/otelcollector/deploy/addon-chart/azure-monitor-metrics-addon/templates/ama-metrics-ksm-deployment.yaml index 8b8377e3c..515f8e104 100644 --- a/otelcollector/deploy/addon-chart/azure-monitor-metrics-addon/templates/ama-metrics-ksm-deployment.yaml +++ b/otelcollector/deploy/addon-chart/azure-monitor-metrics-addon/templates/ama-metrics-ksm-deployment.yaml @@ -65,7 +65,7 @@ spec: imagePullPolicy: IfNotPresent {{- if .Values.AzureMonitorMetrics }} {{- if .Values.AzureMonitorMetrics.KubeStateMetrics }} - image: "mcr.microsoft.com{{ .Values.AzureMonitorMetrics.KubeStateMetrics.ImageRepository }}:{{ .Values.AzureMonitorMetrics.KubeStateMetrics.ImageTag }}" + image: "{{ .Values.AzureMonitorMetrics.KubeStateMetrics.ImageRegistry }}{{ .Values.AzureMonitorMetrics.KubeStateMetrics.ImageRepository }}:{{ .Values.AzureMonitorMetrics.KubeStateMetrics.ImageTag }}" {{- end }} {{- end }} resources: diff --git a/otelcollector/deploy/addon-chart/azure-monitor-metrics-addon/templates/ama-metrics-targetallocator.yaml b/otelcollector/deploy/addon-chart/azure-monitor-metrics-addon/templates/ama-metrics-targetallocator.yaml index bf1cb0412..7b61d9b1a 100644 --- a/otelcollector/deploy/addon-chart/azure-monitor-metrics-addon/templates/ama-metrics-targetallocator.yaml +++ b/otelcollector/deploy/addon-chart/azure-monitor-metrics-addon/templates/ama-metrics-targetallocator.yaml @@ -35,7 +35,7 @@ spec: - name: targetallocator args: - --enable-prometheus-cr-watcher - image: "mcr.microsoft.com{{ .Values.AzureMonitorMetrics.ImageRepository }}:{{ .Values.AzureMonitorMetrics.ImageTagTargetAllocator }}" + image: "{{ .Values.AzureMonitorMetrics.ImageRegistry }}{{ .Values.AzureMonitorMetrics.ImageRepository }}:{{ .Values.AzureMonitorMetrics.ImageTagTargetAllocator }}" imagePullPolicy: IfNotPresent resources: limits: @@ -83,7 +83,7 @@ spec: periodSeconds: 15 failureThreshold: 3 - name: config-reader - image: "mcr.microsoft.com{{ .Values.AzureMonitorMetrics.ImageRepository }}:{{ .Values.AzureMonitorMetrics.ImageTagCfgReader }}" + image: "{{ .Values.AzureMonitorMetrics.ImageRegistry }}{{ .Values.AzureMonitorMetrics.ImageRepository }}:{{ .Values.AzureMonitorMetrics.ImageTagCfgReader }}" imagePullPolicy: IfNotPresent resources: limits: diff --git a/otelcollector/deploy/addon-chart/azure-monitor-metrics-addon/values-template.yaml b/otelcollector/deploy/addon-chart/azure-monitor-metrics-addon/values-template.yaml index c79d0b7b9..1384f40b4 100644 --- a/otelcollector/deploy/addon-chart/azure-monitor-metrics-addon/values-template.yaml +++ b/otelcollector/deploy/addon-chart/azure-monitor-metrics-addon/values-template.yaml @@ -3,6 +3,7 @@ AzureMonitorMetrics: # Uncomment the below 2 settings if you want to pass in the labels and/or annotations #MetricLabelsAllowlist: "testlabel=[.*]" #MetricAnnotationsAllowList: "" + ImageRegistry: mcr.microsoft.com ImageRepository: "/oss/kubernetes/kube-state-metrics" # Kube-state-metrics ImageTag - 2.12.0, corresponds to chart version - 5.19.0 ImageTag: "v2.12.0" @@ -35,6 +36,7 @@ AzureMonitorMetrics: - storageclasses - validatingwebhookconfigurations - volumeattachments + ImageRegistry: mcr.microsoft.com ImageRepository: ${MCR_REPOSITORY} ImageTag: ${IMAGE_TAG} ImageTagWin: ${IMAGE_TAG}-win @@ -69,6 +71,7 @@ AzureMonitorMetrics: # Repository: https://msazure.visualstudio.com/CloudNativeCompute/_git/aks-rp?path=/ccp/charts/addon-charts/azure-monitor-metrics-addon/templates/ama-metrics-daemonset.yaml&version=GBrashmi/prom-addon-arm64&line=136&lineEnd=136&lineStartColumn=56&lineEndColumn=85&lineStyle=plain&_a=contents # ImageTag: https://msazure.visualstudio.com/CloudNativeCompute/_git/aks-rp?path=/ccp/charts/kube-control-plane/templates/_images.tpl&version=GBrashmi/prom-addon-arm64&line=530&lineEnd=530&lineStartColumn=28&lineEndColumn=53&lineStyle=plain&_a=contents AddonTokenAdapter: + ImageRegistry: mcr.microsoft.com ImageRepository: "/aks/msi/addon-token-adapter" ImageTag: "master.230804.1" ImageRepositoryWin: "/aks/hcp/addon-token-adapter"