opentelemetry-helm-charts icon indicating copy to clipboard operation
opentelemetry-helm-charts copied to clipboard

otel demo env schema supports extracting k8s metadata.

Open Frapschen opened this issue 2 years ago • 4 comments

In some scenarios, we want to add some Pod and container fields into OTEL_RESOURCE_ATTRIBUTES enviroment in some components, like namespace name, node name, pod name, which can help us understand a service's running metadata and also show the span attrubute's usage scenarios.

a demo values.yaml like:

components:
  adService:
    enabled: true
    servicePort: 8080
  env:
    - name: OTEL_K8S_NAMESPACE
      valueFrom:
        fieldRef:
          fieldPath: metadata.namespace
    - name: OTEL_K8S_CPU_REQUEST
      valueFrom:
        resourceFieldRef:
          containerName: test-container
          resource: requests.cpu
    - name: OTEL_RESOURCE_ATTRIBUTES
      value: k8s.namespace.name=$(OTEL_K8S_NAMESPACE),k8s.cpu.requests=$(OTEL_K8S_CPU_REQUEST)

current values.yaml schema only support name value in env section:

        "Env": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
                "name": {
                    "type": "string"
                },
                "value": {
                    "type": "string"
                }
            },
            "required": [
                "name"
            ],
            "title": "Env"
        }

I propose to add env.valueFrom into the schema for catching the feature described above.

Frapschen avatar Aug 03 '22 07:08 Frapschen

@TylerHelmuth @wph95 since there are many microservice in otel-demo, we can add a default env setion to handle the specific values extracted from k8s metadata and I can help with the implementation of the custom default env section.

Frapschen avatar Aug 03 '22 07:08 Frapschen

#302

Frapschen avatar Aug 03 '22 08:08 Frapschen

@Frapschen so the goal is to be able to set environment variables using downward api?

TylerHelmuth avatar Aug 03 '22 14:08 TylerHelmuth

@Frapschen so the goal is to be able to set environment variables using downward api?

yes

Frapschen avatar Aug 03 '22 16:08 Frapschen

Closed as completed in https://github.com/open-telemetry/opentelemetry-helm-charts/pull/302

dmitryax avatar Aug 11 '22 04:08 dmitryax