Code Monkey home page Code Monkey logo

digma-helm-helper's Introduction

digma-helm-helper

This repo contains helpers to instrument an application running in a Helm file - without changing the original Helm file.

Prerequisite

Kustomize cli should be installed (https://kustomize.io/)

How to use:

For a full walkthrough see our documentation

What's in this repo

  • example-app An example application to test the kustomize script on
  • java-agent-initializer The source code of the init container used to provide the agent files
  • kustomize scripts used to prepare the patch for you application Helm file

Troubleshooting

You got:

Error: error while running post render on files: error while running command /java-in-helm-instrumentation/kustomize/kustomize_build.sh. error output:
Error: add operation does not apply: doc is missing path: "/spec/template/spec/containers/0/volumeMounts/-": missing value
: exit status 1
helm.go:84: [debug] exit status 1
error while running command /java-in-helm-instrumentation/kustomize/kustomize_build.sh. error output:
Error: add operation does not apply: doc is missing path: "/spec/template/spec/containers/0/volumeMounts/-": missing value

The problem is that your volumeMounts for your container is empty and kustomize cannot add it.

How to fix: change line https://github.com/digma-ai/java-in-helm-instrumentation/blob/main/kustomize/kustomization.yaml#L32 from path: "/spec/template/spec/containers/0/volumeMounts/-" to path: "/spec/template/spec/containers/0/volumeMounts"

Kustomize updates only the first container of my deployment.

We assume you have only one container per deployment configuration, if it's not true for you, you need to duplicate patch https://github.com/digma-ai/java-in-helm-instrumentation/blob/main/kustomize/kustomization.yaml#L9 section and and change duplicated lines 11,27,32 with next number of your container (to 1, means second container).

Example:

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
  - generated-chart-output.yaml
patches:
  - path: patch.yaml
    target:
      labelSelector: <LABEL_TARGET_SELECTOR>
  - patch: |-
      - op: add
        path: "/spec/template/spec/containers/0/env/-"
        value:
          name: JAVA_TOOL_OPTIONS
          value: >-
            -javaagent:/shared-vol/otel-agent.jar 
            -Dotel.javaagent.extensions=/shared-vol/digma-ext.jar 
            -Dotel.exporter.otlp.traces.endpoint=<DIGMA_OTLP_ENDPOINT>
            -Dotel.traces.exporter=otlp 
            -Dotel.metrics.exporter=none 
            -Dotel.logs.exporter=none 
            -Dotel.exporter.otlp.protocol=grpc 
            -Dotel.instrumentation.common.experimental.controller.telemetry.enabled=true 
            -Dotel.instrumentation.common.experimental.view.telemetry.enabled=true 
            -Dotel.instrumentation.experimental.span-suppression-strategy=none 
            -Dotel.service.name=<SERVICE_NAME>
      - op: add
        path: "/spec/template/spec/containers/0/env/-"
        value:
          name: OTEL_RESOURCE_ATTRIBUTES
          value: <SERVICE_OTEL_RESOURCE_ATTRIBUTES>
      - op: add
        path: "/spec/template/spec/containers/0/volumeMounts/-"
        value:
          name: shared
          mountPath: /shared-vol
      - op: add
        path: "/spec/template/spec/containers/1/env/-"
        value:
          name: JAVA_TOOL_OPTIONS
          value: >-
            -javaagent:/shared-vol/otel-agent.jar 
            -Dotel.javaagent.extensions=/shared-vol/digma-ext.jar 
            -Dotel.exporter.otlp.traces.endpoint=<DIGMA_OTLP_ENDPOINT>
            -Dotel.traces.exporter=otlp 
            -Dotel.metrics.exporter=none 
            -Dotel.logs.exporter=none 
            -Dotel.exporter.otlp.protocol=grpc 
            -Dotel.instrumentation.common.experimental.controller.telemetry.enabled=true 
            -Dotel.instrumentation.common.experimental.view.telemetry.enabled=true 
            -Dotel.instrumentation.experimental.span-suppression-strategy=none 
            -Dotel.service.name=<SERVICE_NAME>
      - op: add
        path: "/spec/template/spec/containers/1/env/-"
        value:
          name: OTEL_RESOURCE_ATTRIBUTES
          value: <SERVICE_OTEL_RESOURCE_ATTRIBUTES>
      - op: add
        path: "/spec/template/spec/containers/1/volumeMounts/-"
        value:
          name: shared
          mountPath: /shared-vol
    target:
      labelSelector: <LABEL_TARGET_SELECTOR>

digma-helm-helper's People

Contributors

borisermakof avatar doppleware avatar asafchen-dig avatar

Watchers

 avatar Shalom Ben Zvi Kazaz avatar Shay Keren avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.