From 94d72c94de3913232c6793e9e14c4839fdbe52a8 Mon Sep 17 00:00:00 2001 From: Ty Bekiares Date: Mon, 24 Oct 2022 09:46:35 -0500 Subject: [PATCH] [elastic] customize for elasticsearch workflow --- .github/actions/setup/action.yaml | 2 +- .github/workflows/collector-release.yaml | 44 +++++ .github/workflows/demo-release.yaml | 48 +++++ .github/workflows/lint.yaml | 2 +- .github/workflows/release.yaml | 6 +- charts/opentelemetry-collector/build.sh | 3 + .../templates/_config.tpl | 3 + .../templates/_pod.tpl | 9 + charts/opentelemetry-demo/Chart.lock | 14 +- charts/opentelemetry-demo/Chart.yaml | 16 +- charts/opentelemetry-demo/build.sh | 4 + .../templates}/component.yaml | 0 charts/opentelemetry-demo/values.yaml | 186 +++++++----------- 13 files changed, 193 insertions(+), 144 deletions(-) create mode 100644 .github/workflows/collector-release.yaml create mode 100644 .github/workflows/demo-release.yaml create mode 100755 charts/opentelemetry-collector/build.sh create mode 100755 charts/opentelemetry-demo/build.sh rename charts/opentelemetry-demo/examples/default/rendered/{ => elastic-opentelemetry-demo/templates}/component.yaml (100%) diff --git a/.github/actions/setup/action.yaml b/.github/actions/setup/action.yaml index 6a6b1e5..3c6984b 100644 --- a/.github/actions/setup/action.yaml +++ b/.github/actions/setup/action.yaml @@ -27,6 +27,6 @@ runs: - name: Add Dependencies shell: bash run: | - helm repo add open-telemetry https://open-telemetry.github.io/opentelemetry-helm-charts + helm repo add open-telemetry https://ty-elastic.github.io/opentelemetry-helm-charts helm repo add prometheus https://prometheus-community.github.io/helm-charts helm repo add grafana https://grafana.github.io/helm-charts diff --git a/.github/workflows/collector-release.yaml b/.github/workflows/collector-release.yaml new file mode 100644 index 0000000..0e52861 --- /dev/null +++ b/.github/workflows/collector-release.yaml @@ -0,0 +1,44 @@ +name: Release Collector Charts + +on: + push: + branches: + - ty-elastic/elastic + +jobs: + collector-release: + permissions: + contents: write + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Configure Git + run: | + git config user.name "$GITHUB_ACTOR" + git config user.email "$GITHUB_ACTOR@users.noreply.github.com" + + - name: Install Helm + uses: azure/setup-helm@v3.3 + with: + version: v3.4.1 + + - name: Remove File + uses: JesseTG/rm@v1.0.3 + with: + path: charts/opentelemetry-demo + + - name: Remove File + uses: JesseTG/rm@v1.0.3 + with: + path: charts/opentelemetry-operator + + - name: Run chart-releaser + uses: helm/chart-releaser-action@v1.4.1 + with: + charts_dir: charts + env: + CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" \ No newline at end of file diff --git a/.github/workflows/demo-release.yaml b/.github/workflows/demo-release.yaml new file mode 100644 index 0000000..d571ba7 --- /dev/null +++ b/.github/workflows/demo-release.yaml @@ -0,0 +1,48 @@ +name: Release Demo Charts + +on: + push: + branches: + - ty-elastic/elastic + +jobs: + demo-release: + permissions: + contents: write + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Configure Git + run: | + git config user.name "$GITHUB_ACTOR" + git config user.email "$GITHUB_ACTOR@users.noreply.github.com" + + - name: Install Helm + uses: azure/setup-helm@v3.3 + with: + version: v3.4.1 + + - name: Add dependent repositories + run: | + helm repo add open-telemetry https://ty-elastic.github.io/opentelemetry-helm-charts + + - name: Remove File + uses: JesseTG/rm@v1.0.3 + with: + path: charts/opentelemetry-collector + + - name: Remove File + uses: JesseTG/rm@v1.0.3 + with: + path: charts/opentelemetry-operator + + - name: Run chart-releaser + uses: helm/chart-releaser-action@v1.4.1 + with: + charts_dir: charts + env: + CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index e9299ce..95a33d2 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -3,7 +3,7 @@ name: Lint Charts on: pull_request: branches: - - main + - ty-elastic/elastic jobs: lint-test: diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index f344809..57643bf 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -3,10 +3,12 @@ name: Release Charts on: push: branches: - - main + - ty-elastic/elastic jobs: release: + permissions: + contents: write runs-on: ubuntu-latest steps: - name: Checkout @@ -26,7 +28,7 @@ jobs: - name: Add dependent repositories run: | - helm repo add open-telemetry https://open-telemetry.github.io/opentelemetry-helm-charts + helm repo add open-telemetry https://ty-elastic.github.io/opentelemetry-helm-charts helm repo add prometheus https://prometheus-community.github.io/helm-charts helm repo add grafana https://grafana.github.io/helm-charts diff --git a/charts/opentelemetry-collector/build.sh b/charts/opentelemetry-collector/build.sh new file mode 100755 index 0000000..194a07b --- /dev/null +++ b/charts/opentelemetry-collector/build.sh @@ -0,0 +1,3 @@ +rm -rf opentelemetry-collector-0.37.1.tgz +helm package . +curl -L --data-binary "@opentelemetry-collector-0.37.1.tgz" http://localhost:8080/api/charts \ No newline at end of file diff --git a/charts/opentelemetry-collector/templates/_config.tpl b/charts/opentelemetry-collector/templates/_config.tpl index 568e8ab..7e4478a 100644 --- a/charts/opentelemetry-collector/templates/_config.tpl +++ b/charts/opentelemetry-collector/templates/_config.tpl @@ -281,6 +281,8 @@ receivers: processors: k8sattributes: passthrough: false + filter: + node_from_env_var: OTEL_K8S_NODE_NAME pod_association: - sources: - from: resource_attribute @@ -298,6 +300,7 @@ processors: - "k8s.daemonset.name" - "k8s.cronjob.name" - "k8s.job.name" + - "container.id" {{- end }} {{/* Build the list of port for deployment service */}} diff --git a/charts/opentelemetry-collector/templates/_pod.tpl b/charts/opentelemetry-collector/templates/_pod.tpl index 06f661d..e6408af 100644 --- a/charts/opentelemetry-collector/templates/_pod.tpl +++ b/charts/opentelemetry-collector/templates/_pod.tpl @@ -37,6 +37,15 @@ containers: fieldRef: apiVersion: v1 fieldPath: status.podIP + - name: OTEL_K8S_NODE_IP + valueFrom: + fieldRef: + fieldPath: status.hostIP + - name: OTEL_K8S_NODE_NAME + valueFrom: + fieldRef: + apiVersion: v1 + fieldPath: spec.nodeName {{- if .Values.presets.hostMetrics.enabled }} - name: HOST_PROC value: /hostfs/proc diff --git a/charts/opentelemetry-demo/Chart.lock b/charts/opentelemetry-demo/Chart.lock index f0a36b6..60cbf1c 100644 --- a/charts/opentelemetry-demo/Chart.lock +++ b/charts/opentelemetry-demo/Chart.lock @@ -1,12 +1,6 @@ dependencies: - name: opentelemetry-collector - repository: https://open-telemetry.github.io/opentelemetry-helm-charts - version: 0.38.0 -- name: prometheus - repository: https://prometheus-community.github.io/helm-charts - version: 15.16.1 -- name: grafana - repository: https://grafana.github.io/helm-charts - version: 6.42.2 -digest: sha256:a053cc4c963d0e1e305a9719832073e000adfd2eccec3107e921067414e68c8a -generated: "2022-11-01T22:54:12.017808-04:00" + repository: https://ty-elastic.github.io/opentelemetry-helm-charts + version: 0.38.2 +digest: sha256:ce682595c33367d9e36f80d67ae356a1b53c3a4746737e67131a6829fe3a100f +generated: "2022-11-09T10:55:24.552684-06:00" diff --git a/charts/opentelemetry-demo/Chart.yaml b/charts/opentelemetry-demo/Chart.yaml index b106108..910f9f2 100644 --- a/charts/opentelemetry-demo/Chart.yaml +++ b/charts/opentelemetry-demo/Chart.yaml @@ -5,7 +5,7 @@ version: 0.11.1 description: opentelemetry demo helm chart home: https://opentelemetry.io/ sources: - - https://github.com/open-telemetry/opentelemetry-demo + - https://github.com/ty-elastic/opentelemetry-helm-charts maintainers: - name: dmitryax - name: puckpuck @@ -14,14 +14,6 @@ icon: https://opentelemetry.io/img/logos/opentelemetry-logo-nav.png appVersion: "1.0.0" dependencies: - name: opentelemetry-collector - version: 0.38.0 - repository: https://open-telemetry.github.io/opentelemetry-helm-charts - condition: observability.otelcol.enabled - - name: prometheus - version: 15.16.1 - repository: https://prometheus-community.github.io/helm-charts - condition: observability.prometheus.enabled - - name: grafana - version: 6.42.2 - repository: https://grafana.github.io/helm-charts - condition: observability.grafana.enabled + version: 0.38.2 + repository: https://ty-elastic.github.io/opentelemetry-helm-charts + condition: observability.otelcol.enabled \ No newline at end of file diff --git a/charts/opentelemetry-demo/build.sh b/charts/opentelemetry-demo/build.sh new file mode 100755 index 0000000..bc33798 --- /dev/null +++ b/charts/opentelemetry-demo/build.sh @@ -0,0 +1,4 @@ +helm dependency update +rm -rf opentelemetry-demo-0.11.1.tgz +helm package . +curl -L --data-binary "@opentelemetry-demo-0.11.1.tgz" http://localhost:8080/api/charts \ No newline at end of file diff --git a/charts/opentelemetry-demo/examples/default/rendered/component.yaml b/charts/opentelemetry-demo/examples/default/rendered/elastic-opentelemetry-demo/templates/component.yaml similarity index 100% rename from charts/opentelemetry-demo/examples/default/rendered/component.yaml rename to charts/opentelemetry-demo/examples/default/rendered/elastic-opentelemetry-demo/templates/component.yaml diff --git a/charts/opentelemetry-demo/values.yaml b/charts/opentelemetry-demo/values.yaml index 689beb2..289f2c5 100644 --- a/charts/opentelemetry-demo/values.yaml +++ b/charts/opentelemetry-demo/values.yaml @@ -3,7 +3,7 @@ observability: otelcol: enabled: true jaeger: - enabled: true + enabled: false image: repository: jaegertracing/all-in-one # Overrides the image tag whose default is the chart appVersion. @@ -16,13 +16,32 @@ observability: memory: 275Mi serviceType: "ClusterIP" prometheus: - enabled: true + enabled: false grafana: - enabled: true + enabled: false default: # list of environment variables applied to all components env: + - name: OTEL_K8S_CONTAINER_NAME + valueFrom: + fieldRef: + apiVersion: v1 + fieldPath: "metadata.labels['app.kubernetes.io/component']" + - name: OTEL_K8S_NODE_IP + valueFrom: + fieldRef: + fieldPath: status.hostIP + - name: OTEL_K8S_POD_UID + valueFrom: + fieldRef: + apiVersion: v1 + fieldPath: metadata.uid + - name: OTEL_K8S_POD_IP + valueFrom: + fieldRef: + apiVersion: v1 + fieldPath: status.podIP - name: OTEL_SERVICE_NAME valueFrom: fieldRef: @@ -44,7 +63,7 @@ default: apiVersion: v1 fieldPath: metadata.name - name: OTEL_RESOURCE_ATTRIBUTES - value: service.name=$(OTEL_SERVICE_NAME),k8s.namespace.name=$(OTEL_K8S_NAMESPACE),k8s.node.name=$(OTEL_K8S_NODE_NAME),k8s.pod.name=$(OTEL_K8S_POD_NAME) + value: service.name=$(OTEL_SERVICE_NAME),k8s.namespace.name=$(OTEL_K8S_NAMESPACE),k8s.node.name=$(OTEL_K8S_NODE_NAME),k8s.pod.name=$(OTEL_K8S_POD_NAME),k8s.pod.uid=$(OTEL_K8S_POD_UID),k8s.pod.ip=$(OTEL_K8S_POD_IP),k8s.container.name=$(OTEL_K8S_CONTAINER_NAME),k8s.container.restart_count=0 # Allows overriding and additions to .Values.default.env envOverrides: [] # - name: OTEL_K8S_NODE_NAME @@ -98,7 +117,7 @@ components: servicePort: 8080 env: - name: OTEL_EXPORTER_OTLP_ENDPOINT - value: 'http://{{ include "otel-demo.name" . }}-otelcol:4317' + value: 'http://$(OTEL_K8S_NODE_IP):4317' - name: AD_SERVICE_PORT value: "8080" envOverrides: [] @@ -125,7 +144,7 @@ components: - name: REDIS_ADDR value: '{{ include "otel-demo.name" . }}-redis:6379' - name: OTEL_EXPORTER_OTLP_ENDPOINT - value: 'http://{{ include "otel-demo.name" . }}-otelcol:4317' + value: 'http://$(OTEL_K8S_NODE_IP):4317' - name: CART_SERVICE_PORT value: "8080" envOverrides: [] @@ -160,7 +179,7 @@ components: - name: EMAIL_SERVICE_ADDR value: 'http://{{ include "otel-demo.name" . }}-emailservice:8080' - name: OTEL_EXPORTER_OTLP_ENDPOINT - value: 'http://{{ include "otel-demo.name" . }}-otelcol:4317' + value: 'http://$(OTEL_K8S_NODE_IP):4317' - name: CHECKOUT_SERVICE_PORT value: "8080" envOverrides: [] @@ -185,7 +204,7 @@ components: - name: PORT value: "8080" - name: OTEL_EXPORTER_OTLP_ENDPOINT - value: 'http://{{ include "otel-demo.name" . }}-otelcol:4317' + value: 'http://$(OTEL_K8S_NODE_IP):4317' - name: CURRENCY_SERVICE_PORT value: "8080" envOverrides: [] @@ -213,9 +232,9 @@ components: - name: PORT value: "8080" - name: OTEL_EXPORTER_OTLP_ENDPOINT - value: 'http://{{ include "otel-demo.name" . }}-otelcol:4317' + value: 'http://$(OTEL_K8S_NODE_IP):4317' - name: OTEL_EXPORTER_OTLP_TRACES_ENDPOINT - value: 'http://{{ include "otel-demo.name" . }}-otelcol:4318/v1/traces' + value: 'http://$(OTEL_K8S_NODE_IP):4318/v1/traces' - name: EMAIL_SERVICE_PORT value: "8080" envOverrides: [] @@ -229,7 +248,10 @@ components: useDefault: env: true - imageOverride: {} + imageOverride: + repository: ghcr.io/ty-elastic/demo + tag: "v1.0.0-featureflagservice" + pullPolicy: Always schedulingRules: nodeSelector: {} affinity: {} @@ -240,11 +262,15 @@ components: - name: FEATURE_FLAG_SERVICE_PORT value: "8081" - name: OTEL_EXPORTER_OTLP_TRACES_PROTOCOL + value: http_protobuf + - name: OTEL_EXPORTER_OTLP_PROTOCOL value: grpc - name: DATABASE_URL value: 'ecto://ffs:ffs@{{ include "otel-demo.name" . }}-ffspostgres:5432/ffs' - name: OTEL_EXPORTER_OTLP_ENDPOINT - value: 'http://{{ include "otel-demo.name" . }}-otelcol:4317' + value: 'http://$(OTEL_K8S_NODE_IP):4317' + - name: OTEL_EXPORTER_OTLP_TRACES_ENDPOINT + value: 'http://$(OTEL_K8S_NODE_IP):4318/v1/traces' envOverrides: [] serviceType: ClusterIP ports: @@ -278,7 +304,7 @@ components: - name: POSTGRES_USER value: ffs - name: OTEL_EXPORTER_OTLP_ENDPOINT - value: 'http://{{ include "otel-demo.name" . }}-otelcol:4317' + value: 'http://$(OTEL_K8S_NODE_IP):4317' envOverrides: [] serviceType: ClusterIP ports: @@ -295,7 +321,10 @@ components: useDefault: env: true - imageOverride: {} + imageOverride: + repository: ghcr.io/ty-elastic/demo + tag: "v1.0.0-frontend" + pullPolicy: Always schedulingRules: nodeSelector: {} affinity: {} @@ -320,7 +349,7 @@ components: - name: SHIPPING_SERVICE_ADDR value: '{{ include "otel-demo.name" . }}-shippingservice:8080' - name: OTEL_EXPORTER_OTLP_ENDPOINT - value: 'http://{{ include "otel-demo.name" . }}-otelcol:4317' + value: 'http://$(OTEL_K8S_NODE_IP):4317' - name: FRONTEND_PORT value: "8080" - name: PUBLIC_OTEL_EXPORTER_OTLP_TRACES_ENDPOINT @@ -402,7 +431,7 @@ components: - name: PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION value: python - name: OTEL_EXPORTER_OTLP_ENDPOINT - value: 'http://{{ include "otel-demo.name" . }}-otelcol:4317' + value: 'http://$(OTEL_K8S_NODE_IP):4317' - name: LOADGENERATOR_PORT value: "8089" envOverrides: [] @@ -425,7 +454,7 @@ components: servicePort: 8080 env: - name: OTEL_EXPORTER_OTLP_ENDPOINT - value: 'http://{{ include "otel-demo.name" . }}-otelcol:4317' + value: 'http://$(OTEL_K8S_NODE_IP):4317' - name: PAYMENT_SERVICE_PORT value: "8080" envOverrides: [] @@ -448,7 +477,7 @@ components: servicePort: 8080 env: - name: OTEL_EXPORTER_OTLP_ENDPOINT - value: 'http://{{ include "otel-demo.name" . }}-otelcol:4317' + value: 'http://$(OTEL_K8S_NODE_IP):4317' - name: PRODUCT_CATALOG_SERVICE_PORT value: "8080" - name: FEATURE_FLAG_GRPC_SERVICE_ADDR @@ -477,7 +506,7 @@ components: - name: PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION value: python - name: OTEL_EXPORTER_OTLP_ENDPOINT - value: 'http://{{ include "otel-demo.name" . }}-otelcol:4317' + value: 'http://$(OTEL_K8S_NODE_IP):4317' - name: FEATURE_FLAG_GRPC_SERVICE_ADDR value: '{{ include "otel-demo.name" . }}-featureflagservice:50053' - name: RECOMMENDATION_SERVICE_PORT @@ -495,7 +524,10 @@ components: useDefault: env: true - imageOverride: {} + imageOverride: + repository: ghcr.io/ty-elastic/demo + tag: "v1.0.0-shippingservice" + pullPolicy: Always schedulingRules: nodeSelector: {} affinity: {} @@ -506,9 +538,9 @@ components: - name: PORT value: "8080" - name: OTEL_EXPORTER_OTLP_ENDPOINT - value: 'http://{{ include "otel-demo.name" . }}-otelcol:4317' + value: 'http://$(OTEL_K8S_NODE_IP):4317' - name: OTEL_EXPORTER_OTLP_TRACES_ENDPOINT - value: 'http://{{ include "otel-demo.name" . }}-otelcol:4317' + value: 'http://$(OTEL_K8S_NODE_IP):4317' - name: SHIPPING_SERVICE_PORT value: "8080" - name: QUOTE_SERVICE_ADDR @@ -541,7 +573,7 @@ components: - name: OTEL_PHP_TRACES_PROCESSOR value: "simple" - name: OTEL_EXPORTER_OTLP_ENDPOINT - value: '{{ include "otel-demo.name" . }}-otelcol:4317' + value: '${OTEL_K8S_NODE_IP}:4317' - name: QUOTE_SERVICE_PORT value: "8080" envOverrides: [] @@ -552,23 +584,18 @@ components: opentelemetry-collector: nameOverride: otelcol - mode: deployment + mode: daemonset resources: limits: memory: 100Mi - service: - type: ClusterIP - ports: - metrics: - enabled: true - prometheus: + presets: + logsCollection: + enabled: false + hostMetrics: + enabled: false + kubernetesAttributes: enabled: true - containerPort: 9464 - servicePort: 9464 - protocol: TCP podAnnotations: - prometheus.io/scrape: "true" - prometheus.io/port: "9464" opentelemetry_community_demo: "true" config: receivers: @@ -582,96 +609,19 @@ opentelemetry-collector: - "https://*" exporters: - otlp: - endpoint: '{{ include "otel-demo.name" . }}-jaeger:4317' + logging: {} + otlp/elastic: + endpoint: ${OTEL_K8S_NODE_IP}:8200 tls: insecure: true - prometheus: - endpoint: '0.0.0.0:9464' processors: - spanmetrics: - metrics_exporter: prometheus service: pipelines: traces: - processors: [memory_limiter, spanmetrics, batch] - exporters: [otlp, logging] + processors: [memory_limiter, batch] + exporters: [otlp/elastic, logging] metrics: - exporters: [prometheus, logging] + exporters: [otlp/elastic, logging] -prometheus: - alertmanager: - enabled: false - configmapReload: - prometheus: - enabled: false - kubeStateMetrics: - enabled: false - nodeExporter: - enabled: false - pushgateway: - enabled: false - - server: - global: - scrape_interval: 5s - scrape_timeout: 3s - evaluation_interval: 30s - service: - servicePort: 9090 - - serverFiles: - prometheus.yml: - scrape_configs: - - job_name: 'opentelemetry-community-demo' - kubernetes_sd_configs: - - role: pod - relabel_configs: - - source_labels: [__meta_kubernetes_pod_annotation_opentelemetry_community_demo] - action: keep - regex: true - -grafana: - grafana.ini: - auth: - disable_login_form: true - auth.anonymous: - enabled: true - org_name: Main Org. - org_role: Admin - server: - root_url: "%(protocol)s://%(domain)s:%(http_port)s/grafana" - serve_from_sub_path: true - adminPassword: admin - datasources: - datasources.yaml: - apiVersion: 1 - datasources: - - name: Prometheus - uid: webstore-metrics - type: prometheus - url: 'http://{{ include "otel-demo.name" . }}-prometheus-server:9090' - editable: true - isDefault: true - - name: Jaeger - uid: webstore-traces - type: jaeger - url: 'http://{{ include "otel-demo.name" . }}-jaeger:16686' - editable: true - isDefault: false - dashboardProviders: - dashboardproviders.yaml: - apiVersion: 1 - providers: - - name: 'default' - orgId: 1 - folder: '' - type: file - disableDeletion: false - editable: true - options: - path: /var/lib/grafana/dashboards/default - dashboardsConfigMaps: - default: '{{ include "otel-demo.name" . }}-grafana-dashboards'