From 0180a0bf860323ed4d3f0b54a859aa6650f52fd4 Mon Sep 17 00:00:00 2001 From: mike-kingsbury <80352581+mike-kingsbury@users.noreply.github.com> Date: Fri, 28 Jun 2024 03:07:25 -0400 Subject: [PATCH] PVCORE-4214 - Otel tracing support in staging environments (#3917) * PVCORE-4214 - Otel tracing support in staging environments * StageTake3 --- .../infra-deployments/kustomization.yaml | 1 - .../kustomization.yaml | 1 + .../tracing-workload-otel-collector.yaml | 132 ++++-------------- .../tracing-workload-tracing.yaml} | 13 +- .../application-set-multisrc-src-1-patch.yaml | 7 + .../kustomization.yaml | 8 +- .../overlays/development/kustomization.yaml | 7 +- .../delete-applications.yaml | 9 +- .../delete-applications.yaml | 7 +- .../delete-applications.yaml | 15 ++ .../enable-tekton-tracing.yaml | 8 ++ .../enable-tekton-tracing/kustomization.yaml | 0 .../external-secrets/honeycomb-api-key.yaml | 19 +++ .../base/external-secrets/kustomization.yaml | 5 + .../otel-collector/base}/kustomization.yaml | 4 +- .../development/kustomization.yaml | 6 + .../patch-delete-external-secrets.yaml | 7 + .../honeycomb-api-key-secret-path.yaml | 5 + .../otel-collector/staging/kustomization.yaml | 11 ++ .../enable-tekton-tracing.yaml | 2 +- hack/preview.sh | 1 + 21 files changed, 146 insertions(+), 122 deletions(-) rename argo-cd-apps/base/all-clusters/infra-deployments/{enable-tekton-tracing/enable-tekton-tracing.yaml => tracing-workload-otel-collector/tracing-workload-tracing.yaml} (68%) create mode 100644 argo-cd-apps/k-components/inject-infra-deployments-repo-details/application-set-multisrc-src-1-patch.yaml create mode 100644 components/tracing/otel-collector/base/enable-tekton-tracing/enable-tekton-tracing.yaml rename {argo-cd-apps/base/all-clusters/infra-deployments => components/tracing/otel-collector/base}/enable-tekton-tracing/kustomization.yaml (100%) create mode 100644 components/tracing/otel-collector/base/external-secrets/honeycomb-api-key.yaml create mode 100644 components/tracing/otel-collector/base/external-secrets/kustomization.yaml rename {configs/enable-tekton-tracing => components/tracing/otel-collector/base}/kustomization.yaml (61%) create mode 100644 components/tracing/otel-collector/development/kustomization.yaml create mode 100644 components/tracing/otel-collector/development/patch-delete-external-secrets.yaml create mode 100644 components/tracing/otel-collector/staging/honeycomb-api-key-secret-path.yaml create mode 100644 components/tracing/otel-collector/staging/kustomization.yaml diff --git a/argo-cd-apps/base/all-clusters/infra-deployments/kustomization.yaml b/argo-cd-apps/base/all-clusters/infra-deployments/kustomization.yaml index 8dc26bc5429..bfb1aaacb70 100644 --- a/argo-cd-apps/base/all-clusters/infra-deployments/kustomization.yaml +++ b/argo-cd-apps/base/all-clusters/infra-deployments/kustomization.yaml @@ -12,6 +12,5 @@ resources: - enable-dvo-for-all-cluster - kubesaw-common - tracing-workload-otel-collector - - enable-tekton-tracing components: - ../../../k-components/inject-infra-deployments-repo-details diff --git a/argo-cd-apps/base/all-clusters/infra-deployments/tracing-workload-otel-collector/kustomization.yaml b/argo-cd-apps/base/all-clusters/infra-deployments/tracing-workload-otel-collector/kustomization.yaml index 692af32086e..edb6bae3dcc 100644 --- a/argo-cd-apps/base/all-clusters/infra-deployments/tracing-workload-otel-collector/kustomization.yaml +++ b/argo-cd-apps/base/all-clusters/infra-deployments/tracing-workload-otel-collector/kustomization.yaml @@ -2,3 +2,4 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: - tracing-workload-otel-collector.yaml +- tracing-workload-tracing.yaml diff --git a/argo-cd-apps/base/all-clusters/infra-deployments/tracing-workload-otel-collector/tracing-workload-otel-collector.yaml b/argo-cd-apps/base/all-clusters/infra-deployments/tracing-workload-otel-collector/tracing-workload-otel-collector.yaml index 96609719d5c..0bde96dae5d 100644 --- a/argo-cd-apps/base/all-clusters/infra-deployments/tracing-workload-otel-collector/tracing-workload-otel-collector.yaml +++ b/argo-cd-apps/base/all-clusters/infra-deployments/tracing-workload-otel-collector/tracing-workload-otel-collector.yaml @@ -3,118 +3,42 @@ kind: ApplicationSet metadata: name: tracing-workload-otel-collector labels: - ### Prevent the repoURL from being transformed to a local fork name. noSourceTransform: "true" spec: generators: - - merge: - mergeKeys: - - nameNormalized - generators: - - clusters: - values: - sourceRoot: components/tracing/otel-collector - environment: staging - clusterDir: "" - - list: - elements: [] + - merge: + mergeKeys: + - nameNormalized + generators: + - clusters: + values: + sourceRoot: components/tracing/otel-collector + environment: staging + clusterDir: "" + - list: + elements: [] template: metadata: name: tracing-workload-otel-collector-{{nameNormalized}} spec: project: default - source: - chart: opentelemetry-collector - path: '{{values.sourceRoot}}/{{values.environment}}/{{values.clusterDir}}' - repoURL: https://open-telemetry.github.io/opentelemetry-helm-charts - targetRevision: 0.90.1 - helm: - parameters: - - name: "image.repository" - value: otel/opentelemetry-collector-k8s - - name: "mode" - value: deployment - releaseName: open-telemetry - values: | - config: - exporters: - debug: - verbosity: basic - # ### To be configured in later work for stage and prod clusters.. - # otlphttp: - # endpoint: https://api.honeycomb.io:443 - # headers: - # "x-honeycomb-team": ${HONEYCOMB_API_TOKEN} - extensions: - # The health_check extension is mandatory for this chart. - # Without the health_check extension the collector will fail the readiness and liveliness probes. - # The health_check extension can be modified, but should never be removed. - health_check: {} - memory_ballast: {} - processors: - batch: {} - # If set to null, will be overridden with values based on k8s resource limits - memory_limiter: - check_interval: 2s - limit_mib: 512 - spike_limit_percentage: 100 - attributes/collector-info: - actions: - - key: collector.hostname - action: insert - value: ${env:HOSTNAME} - - key: collector.clustername - action: insert - value: dev - receivers: - jaeger: null - prometheus: null - zipkin: null - otlp: - protocols: - grpc: - endpoint: 0.0.0.0:4317 - max_recv_msg_size_mib: 999999999 - http: - endpoint: 0.0.0.0:4318 - service: - extensions: - - health_check - - memory_ballast - pipelines: - traces: - exporters: - - debug - processors: - - memory_limiter - - attributes/collector-info - - batch - receivers: - - otlp - metrics: null - # Configuration for ports - ports: - otlp: - enabled: true - containerPort: 4317 - servicePort: 4317 - hostPort: 4317 - protocol: TCP - otlp-http: - enabled: true - containerPort: 4318 - servicePort: 4318 - hostPort: 4318 - protocol: TCP - jaeger-compact: - enabled: false - jaeger-thrift: - enabled: false - jaeger-grpc: - enabled: false - zipkin: - enabled: false - + sources: + # Chart from OTel Project + - chart: opentelemetry-collector + repoURL: https://open-telemetry.github.io/opentelemetry-helm-charts + targetRevision: 0.90.1 + helm: + parameters: + - name: "image.repository" + value: otel/opentelemetry-collector-k8s + - name: "mode" + value: deployment + valueFiles: + - $values/{{values.sourceRoot}}/{{values.environment}}/otel-collector-helm-values.yaml + # Values for chart from git + - repoURL: https://github.com/redhat-appstudio/infra-deployments.git + targetRevision: main + ref: values destination: namespace: konflux-otel server: '{{server}}' diff --git a/argo-cd-apps/base/all-clusters/infra-deployments/enable-tekton-tracing/enable-tekton-tracing.yaml b/argo-cd-apps/base/all-clusters/infra-deployments/tracing-workload-otel-collector/tracing-workload-tracing.yaml similarity index 68% rename from argo-cd-apps/base/all-clusters/infra-deployments/enable-tekton-tracing/enable-tekton-tracing.yaml rename to argo-cd-apps/base/all-clusters/infra-deployments/tracing-workload-otel-collector/tracing-workload-tracing.yaml index af3fb4dce87..8971568ed12 100644 --- a/argo-cd-apps/base/all-clusters/infra-deployments/enable-tekton-tracing/enable-tekton-tracing.yaml +++ b/argo-cd-apps/base/all-clusters/infra-deployments/tracing-workload-otel-collector/tracing-workload-tracing.yaml @@ -1,7 +1,7 @@ apiVersion: argoproj.io/v1alpha1 kind: ApplicationSet metadata: - name: enable-tekton-tracing + name: tracing-workload-tracing spec: generators: - merge: @@ -10,28 +10,31 @@ spec: generators: - clusters: values: - sourceRoot: configs/enable-tekton-tracing + sourceRoot: components/tracing/otel-collector environment: staging clusterDir: "" - list: elements: [] template: metadata: - name: enable-tekton-tracing-{{nameNormalized}} + name: tracing-workload-tracing-{{nameNormalized}} spec: project: default source: - path: configs/enable-tekton-tracing + path: '{{values.sourceRoot}}/{{values.environment}}/{{values.clusterDir}}' repoURL: https://github.com/redhat-appstudio/infra-deployments.git targetRevision: main destination: + namespace: konflux-otel server: '{{server}}' syncPolicy: automated: prune: true selfHeal: true + syncOptions: + - CreateNamespace=true retry: - limit: -1 + limit: 50 backoff: duration: 10s factor: 2 diff --git a/argo-cd-apps/k-components/inject-infra-deployments-repo-details/application-set-multisrc-src-1-patch.yaml b/argo-cd-apps/k-components/inject-infra-deployments-repo-details/application-set-multisrc-src-1-patch.yaml new file mode 100644 index 00000000000..10d87d20b37 --- /dev/null +++ b/argo-cd-apps/k-components/inject-infra-deployments-repo-details/application-set-multisrc-src-1-patch.yaml @@ -0,0 +1,7 @@ +--- +- op: replace + path: /spec/template/spec/sources/1/repoURL + value: https://github.com/redhat-appstudio/infra-deployments.git +- op: replace + path: /spec/template/spec/sources/1/targetRevision + value: main diff --git a/argo-cd-apps/k-components/inject-infra-deployments-repo-details/kustomization.yaml b/argo-cd-apps/k-components/inject-infra-deployments-repo-details/kustomization.yaml index 4a094f7d7de..085bbe4bc9b 100644 --- a/argo-cd-apps/k-components/inject-infra-deployments-repo-details/kustomization.yaml +++ b/argo-cd-apps/k-components/inject-infra-deployments-repo-details/kustomization.yaml @@ -13,4 +13,10 @@ patches: group: argoproj.io version: v1alpha1 kind: Application - labelSelector: noSourceTransform != true \ No newline at end of file + labelSelector: noSourceTransform != true + - path: application-set-multisrc-src-1-patch.yaml + target: + group: argoproj.io + version: v1alpha1 + kind: ApplicationSet + name: tracing-workload-otel-collector diff --git a/argo-cd-apps/overlays/development/kustomization.yaml b/argo-cd-apps/overlays/development/kustomization.yaml index 5d78c5bbff8..3c226fa9afc 100644 --- a/argo-cd-apps/overlays/development/kustomization.yaml +++ b/argo-cd-apps/overlays/development/kustomization.yaml @@ -168,4 +168,9 @@ patches: target: kind: ApplicationSet version: v1alpha1 - name: tracing-workload-otel-collector + name: tracing-workload-tracing + - path: development-overlay-patch.yaml + target: + kind: ApplicationSet + version: v1alpha1 + name: tracing-workload-otel-collector \ No newline at end of file diff --git a/argo-cd-apps/overlays/konflux-public-production/delete-applications.yaml b/argo-cd-apps/overlays/konflux-public-production/delete-applications.yaml index 47e78222953..47ed0c213f6 100644 --- a/argo-cd-apps/overlays/konflux-public-production/delete-applications.yaml +++ b/argo-cd-apps/overlays/konflux-public-production/delete-applications.yaml @@ -5,9 +5,16 @@ metadata: name: gitops $patch: delete --- -# otel-collector is dev only. +# otel-collector is dev & staging only. apiVersion: argoproj.io/v1alpha1 kind: ApplicationSet metadata: name: tracing-workload-otel-collector $patch: delete +--- +# otel-collector is dev & staging only. +apiVersion: argoproj.io/v1alpha1 +kind: ApplicationSet +metadata: + name: tracing-workload-tracing +$patch: delete diff --git a/argo-cd-apps/overlays/konflux-public-staging/delete-applications.yaml b/argo-cd-apps/overlays/konflux-public-staging/delete-applications.yaml index 47e78222953..023879262c3 100644 --- a/argo-cd-apps/overlays/konflux-public-staging/delete-applications.yaml +++ b/argo-cd-apps/overlays/konflux-public-staging/delete-applications.yaml @@ -5,9 +5,4 @@ metadata: name: gitops $patch: delete --- -# otel-collector is dev only. -apiVersion: argoproj.io/v1alpha1 -kind: ApplicationSet -metadata: - name: tracing-workload-otel-collector -$patch: delete + diff --git a/argo-cd-apps/overlays/production-downstream/delete-applications.yaml b/argo-cd-apps/overlays/production-downstream/delete-applications.yaml index 139b6bb04f0..9abddeee660 100644 --- a/argo-cd-apps/overlays/production-downstream/delete-applications.yaml +++ b/argo-cd-apps/overlays/production-downstream/delete-applications.yaml @@ -29,3 +29,18 @@ kind: ApplicationSet metadata: name: quality-dashboard $patch: delete +--- +# otel-collector is dev & staging only. +apiVersion: argoproj.io/v1alpha1 +kind: ApplicationSet +metadata: + name: tracing-workload-otel-collector +$patch: delete +--- +# otel-collector is dev & staging only. +apiVersion: argoproj.io/v1alpha1 +kind: ApplicationSet +metadata: + name: tracing-workload-tracing +$patch: delete +--- diff --git a/components/tracing/otel-collector/base/enable-tekton-tracing/enable-tekton-tracing.yaml b/components/tracing/otel-collector/base/enable-tekton-tracing/enable-tekton-tracing.yaml new file mode 100644 index 00000000000..465981fc6ca --- /dev/null +++ b/components/tracing/otel-collector/base/enable-tekton-tracing/enable-tekton-tracing.yaml @@ -0,0 +1,8 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: config-tracing + namespace: openshift-pipelines +data: + enabled: "true" + endpoint: "http://open-telemetry-opentelemetry-collector.konflux-otel.svc.cluster.local:4318/v1/traces" \ No newline at end of file diff --git a/argo-cd-apps/base/all-clusters/infra-deployments/enable-tekton-tracing/kustomization.yaml b/components/tracing/otel-collector/base/enable-tekton-tracing/kustomization.yaml similarity index 100% rename from argo-cd-apps/base/all-clusters/infra-deployments/enable-tekton-tracing/kustomization.yaml rename to components/tracing/otel-collector/base/enable-tekton-tracing/kustomization.yaml diff --git a/components/tracing/otel-collector/base/external-secrets/honeycomb-api-key.yaml b/components/tracing/otel-collector/base/external-secrets/honeycomb-api-key.yaml new file mode 100644 index 00000000000..9f947038a50 --- /dev/null +++ b/components/tracing/otel-collector/base/external-secrets/honeycomb-api-key.yaml @@ -0,0 +1,19 @@ +apiVersion: external-secrets.io/v1beta1 +kind: ExternalSecret +metadata: + name: honeycomb-api-key + annotations: + argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true + argocd.argoproj.io/sync-wave: "-1" +spec: + dataFrom: + - extract: + key: # will be added by the overlays + refreshInterval: 1h + secretStoreRef: + kind: ClusterSecretStore + name: appsre-stonesoup-vault + target: + creationPolicy: Owner + deletionPolicy: Delete + name: honeycomb-api-key diff --git a/components/tracing/otel-collector/base/external-secrets/kustomization.yaml b/components/tracing/otel-collector/base/external-secrets/kustomization.yaml new file mode 100644 index 00000000000..62311e63ad1 --- /dev/null +++ b/components/tracing/otel-collector/base/external-secrets/kustomization.yaml @@ -0,0 +1,5 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - honeycomb-api-key.yaml +namespace: konflux-otel diff --git a/configs/enable-tekton-tracing/kustomization.yaml b/components/tracing/otel-collector/base/kustomization.yaml similarity index 61% rename from configs/enable-tekton-tracing/kustomization.yaml rename to components/tracing/otel-collector/base/kustomization.yaml index 09fe778514e..e75e90a542a 100644 --- a/configs/enable-tekton-tracing/kustomization.yaml +++ b/components/tracing/otel-collector/base/kustomization.yaml @@ -1,5 +1,5 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization - resources: - - enable-tekton-tracing.yaml \ No newline at end of file + - external-secrets + - enable-tekton-tracing diff --git a/components/tracing/otel-collector/development/kustomization.yaml b/components/tracing/otel-collector/development/kustomization.yaml new file mode 100644 index 00000000000..e18328a699a --- /dev/null +++ b/components/tracing/otel-collector/development/kustomization.yaml @@ -0,0 +1,6 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - ../base +patchesStrategicMerge: + - patch-delete-external-secrets.yaml diff --git a/components/tracing/otel-collector/development/patch-delete-external-secrets.yaml b/components/tracing/otel-collector/development/patch-delete-external-secrets.yaml new file mode 100644 index 00000000000..e47731f1268 --- /dev/null +++ b/components/tracing/otel-collector/development/patch-delete-external-secrets.yaml @@ -0,0 +1,7 @@ +--- +apiVersion: external-secrets.io/v1beta1 +kind: ExternalSecret +metadata: + name: honeycomb-api-key +$patch: delete +--- diff --git a/components/tracing/otel-collector/staging/honeycomb-api-key-secret-path.yaml b/components/tracing/otel-collector/staging/honeycomb-api-key-secret-path.yaml new file mode 100644 index 00000000000..65ee8d71b80 --- /dev/null +++ b/components/tracing/otel-collector/staging/honeycomb-api-key-secret-path.yaml @@ -0,0 +1,5 @@ +--- +- op: add + path: /spec/dataFrom/0/extract/key + value: staging/tracing/honeycomb + diff --git a/components/tracing/otel-collector/staging/kustomization.yaml b/components/tracing/otel-collector/staging/kustomization.yaml new file mode 100644 index 00000000000..a36697a4f01 --- /dev/null +++ b/components/tracing/otel-collector/staging/kustomization.yaml @@ -0,0 +1,11 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - ../base +patches: + - path: honeycomb-api-key-secret-path.yaml + target: + name: honeycomb-api-key + kind: ExternalSecret + group: external-secrets.io + version: v1beta1 diff --git a/configs/enable-tekton-tracing/enable-tekton-tracing.yaml b/configs/enable-tekton-tracing/enable-tekton-tracing.yaml index 3a3c88404ef..645a73e60ea 100644 --- a/configs/enable-tekton-tracing/enable-tekton-tracing.yaml +++ b/configs/enable-tekton-tracing/enable-tekton-tracing.yaml @@ -5,5 +5,5 @@ metadata: name: config-tracing namespace: openshift-pipelines data: - enabled: "false" + enabled: "true" endpoint: "http://open-telemetry-opentelemetry-collector.konflux-otel.svc.cluster.local:4318/v1/traces" diff --git a/hack/preview.sh b/hack/preview.sh index 0c9335646d8..276e6d7b60b 100755 --- a/hack/preview.sh +++ b/hack/preview.sh @@ -124,6 +124,7 @@ update_patch_file () { } update_patch_file "${ROOT}/argo-cd-apps/k-components/inject-infra-deployments-repo-details/application-patch.yaml" update_patch_file "${ROOT}/argo-cd-apps/k-components/inject-infra-deployments-repo-details/application-set-patch.yaml" +update_patch_file "${ROOT}/argo-cd-apps/k-components/inject-infra-deployments-repo-details/application-set-multisrc-src-1-patch.yaml" if $OBO ; then echo "Adding Observability operator and Prometheus for federation"