From 46a28f385676dc7290bece1baa37130cdcf2b647 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20=C5=9Awi=C4=85tek?= Date: Thu, 2 Nov 2023 19:01:13 +0100 Subject: [PATCH] fix(instrumentation): replace tools image with kubectl The kubernetes-tools image isn't supported for production use. The kubectl image with minimal dependencies suffices for applying default instrumentation CRs. --- .changelog/3373.fixed.txt | 1 + deploy/helm/sumologic/README.md | 4 +-- .../job-instrumentation-cr.yaml | 28 +++++------------ deploy/helm/sumologic/values.yaml | 4 +-- .../job.output.yaml | 30 ++++++------------- 5 files changed, 22 insertions(+), 45 deletions(-) create mode 100644 .changelog/3373.fixed.txt diff --git a/.changelog/3373.fixed.txt b/.changelog/3373.fixed.txt new file mode 100644 index 0000000000..335bfee64f --- /dev/null +++ b/.changelog/3373.fixed.txt @@ -0,0 +1 @@ +fix(instrumentation): replace tools image with kubectl \ No newline at end of file diff --git a/deploy/helm/sumologic/README.md b/deploy/helm/sumologic/README.md index a7ba679522..42d73c53e9 100644 --- a/deploy/helm/sumologic/README.md +++ b/deploy/helm/sumologic/README.md @@ -276,8 +276,8 @@ The following table lists the configurable parameters of the Sumo Logic chart an | `opentelemetry-operator.manager.resources.requests.cpu` | Used to set requested CPU for OpenTelemetry-Operator Manager. | `150m` | | `opentelemetry-operator.manager.resources.requests.memory` | Used to set requested Memory for OpenTelemetry-Operator Manager. | `256Mi` | | `opentelemetry-operator.instrumentationNamespaces` | Used to create `Instrumentation` resources in specified namespaces. | `Nil` | -| `opentelemetry-operator.instrumentationJobImage.image.repository` | Name of the image repository used to apply Instrumentation resource | `sumologic/kubernetes-tools` | -| `opentelemetry-operator.instrumentationJobImage.image.tag` | Name of the image tag used to apply Instrumentation resource | `2.14.0` | +| `opentelemetry-operator.instrumentationJobImage.image.repository` | Name of the image repository used to apply Instrumentation resource | `public.ecr.aws/sumologic/kubernetes-tools-kubectl` | +| `opentelemetry-operator.instrumentationJobImage.image.tag` | Name of the image tag used to apply Instrumentation resource | `2.20.0` | | `opentelemetry-operator.admissionWebhooks` | Admission webhooks make sure only requests with correctly formatted rules will get into the Operator. They also enable the sidecar injection for OpenTelemetryCollector and Instrumentation CR's. | See [values.yaml] | | `opentelemetry-operator.manager.env` | Additional environment variables for opentelemetry-operator helm chart. | `{"ENABLE_WEBHOOKS": "true"}` | | `otelcolInstrumentation.enabled` | Enables Sumo Otel Distro Collector StatefulSet to collect telemetry data. [See docs for more information.](/docs/opentelemetry-collector/traces.md) | `true` | diff --git a/deploy/helm/sumologic/templates/opentelemetry-operator/job-instrumentation-cr.yaml b/deploy/helm/sumologic/templates/opentelemetry-operator/job-instrumentation-cr.yaml index 7889e3cfd8..8019913295 100644 --- a/deploy/helm/sumologic/templates/opentelemetry-operator/job-instrumentation-cr.yaml +++ b/deploy/helm/sumologic/templates/opentelemetry-operator/job-instrumentation-cr.yaml @@ -26,26 +26,17 @@ spec: - name: instrumentation-cr-configmap mountPath: /tmp/instrumentation-cr.yaml subPath: instrumentation.cr.yaml - command: ["/bin/bash", "-c"] + command: ["/usr/local/bin/bash", "-c"] args: - | max_wait=180 sleep_interval=5 counter=0 - ready=false - while [[ ready != "false" ]] + while ! kubectl apply -f /tmp/instrumentation-cr.yaml do - is_ready=$(curl -s -o /dev/null -m 3 -L -w ''%{http_code}'' {{ template "opentelemetry-operator.controller.manager.metrics.service.url" . }}) - - if [[ is_ready -eq "200" ]] - then - ready=true - break - else - echo "Waiting for {{ .Release.Name }}-opentelemetry-operator" - sleep $sleep_interval - counter=$(($counter + $sleep_interval)) - fi + echo "Waiting for {{ .Release.Name }}-opentelemetry-operator" + sleep $sleep_interval + counter=$(($counter + $sleep_interval)) if [[ "$counter" -gt "$max_wait" ]] then @@ -55,12 +46,9 @@ spec: fi done - if [[ $ready == true ]] - then - echo "Applying Instrumentation resources" - kubectl apply -f /tmp/instrumentation-cr.yaml - exit $? - fi + kubectl apply -f /tmp/instrumentation-cr.yaml || exit 1 + echo "Successfully applied Instrumentation resources" + exit $? volumes: - name: instrumentation-cr-configmap configMap: diff --git a/deploy/helm/sumologic/values.yaml b/deploy/helm/sumologic/values.yaml index b33163f058..b69354466c 100644 --- a/deploy/helm/sumologic/values.yaml +++ b/deploy/helm/sumologic/values.yaml @@ -2416,8 +2416,8 @@ opentelemetry-operator: ## Specific for Sumo Logic chart - Instrumentation resource creation instrumentationJobImage: image: - repository: sumologic/kubernetes-tools - tag: 2.14.0 + repository: public.ecr.aws/sumologic/kubernetes-tools-kubectl + tag: 2.20.0 createDefaultInstrumentation: false instrumentationNamespaces: "" diff --git a/tests/helm/testdata/goldenfile/opentelemetry_operator_instrumentation_cr_job/job.output.yaml b/tests/helm/testdata/goldenfile/opentelemetry_operator_instrumentation_cr_job/job.output.yaml index 8d35446ed0..a77237f54e 100644 --- a/tests/helm/testdata/goldenfile/opentelemetry_operator_instrumentation_cr_job/job.output.yaml +++ b/tests/helm/testdata/goldenfile/opentelemetry_operator_instrumentation_cr_job/job.output.yaml @@ -19,31 +19,22 @@ spec: serviceAccountName: RELEASE-NAME-sumologic containers: - name: instrumentation-cr-applier - image: sumologic/kubernetes-tools:2.14.0 + image: public.ecr.aws/sumologic/kubernetes-tools-kubectl:2.20.0 volumeMounts: - name: instrumentation-cr-configmap mountPath: /tmp/instrumentation-cr.yaml subPath: instrumentation.cr.yaml - command: ["/bin/bash", "-c"] + command: ["/usr/local/bin/bash", "-c"] args: - | max_wait=180 sleep_interval=5 counter=0 - ready=false - while [[ ready != "false" ]] + while ! kubectl apply -f /tmp/instrumentation-cr.yaml do - is_ready=$(curl -s -o /dev/null -m 3 -L -w ''%{http_code}'' http://RELEASE-NAME-opentelemetry-operator.sumologic:8080/metrics) - - if [[ is_ready -eq "200" ]] - then - ready=true - break - else - echo "Waiting for RELEASE-NAME-opentelemetry-operator" - sleep $sleep_interval - counter=$(($counter + $sleep_interval)) - fi + echo "Waiting for RELEASE-NAME-opentelemetry-operator" + sleep $sleep_interval + counter=$(($counter + $sleep_interval)) if [[ "$counter" -gt "$max_wait" ]] then @@ -53,12 +44,9 @@ spec: fi done - if [[ $ready == true ]] - then - echo "Applying Instrumentation resources" - kubectl apply -f /tmp/instrumentation-cr.yaml - exit $? - fi + kubectl apply -f /tmp/instrumentation-cr.yaml || exit 1 + echo "Successfully applied Instrumentation resources" + exit $? volumes: - name: instrumentation-cr-configmap configMap: