clusterpedia-io / clusterpedia-helm

Apache License 2.0
4 stars 15 forks source link

add OTEL trace env for helm chart #65

Closed KubeKyrie closed 10 months ago

KubeKyrie commented 11 months ago

Note on DCO:

If the DCO action in the integration test fails, one or more of your commits are not signed off. Please click on the Details link next to the DCO action for instructions on how to resolve this.

Checklist:

Changes are automatically published when merged to main. They are not published on branches.

clusterpedia-bot commented 11 months ago

Hi @KubeKyrie, Thanks for your pull request! If the PR is ready, use the /auto-cc command to assign Reviewer to Review. We will review it shortly.

Details Instructions for interacting with me using comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the [gh-ci-bot](https://github.com/clusterpedia-io/gh-ci-bot) repository.
KubeKyrie commented 11 months ago

There is test results:

  1. donnot enable otel trace:

helm install clusterpedia -n test --create-namespace ./charts/clusterpedia/ --set persistenceMatchNode=None --set postgresql.primary.persistence.enabled=false --debug

企业微信截图_6c5006b1-81c9-4e51-bac3-481df6815d3a

  1. enable otel trace: helm install clusterpedia -n pedia-system --create-namespace ./charts/clusterpedia/ --set telemetry.tracing.enabled=true --set persistenceMatchNode=None --set postgresql.primary.persistence.enabled=false --debug

image

those otel trace env are added for deploy clusterpedia-apiserver


kind: Deployment
metadata:
  annotations:
    deployment.kubernetes.io/revision: "2"
    meta.helm.sh/release-name: clusterpedia
    meta.helm.sh/release-namespace: pedia-system
  creationTimestamp: "2023-12-05T11:51:28Z"
  generation: 2
  labels:
    app: clusterpedia-apiserver
    app.kubernetes.io/instance: clusterpedia
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/name: clusterpedia
    app.kubernetes.io/version: v0.7.0
    helm.sh/chart: clusterpedia-2.0.1
  name: clusterpedia-apiserver
  namespace: pedia-system
  resourceVersion: "6317151"
  uid: 6cbdf5d9-4405-43b8-955a-28b465c6e9dc
spec:
  progressDeadlineSeconds: 600
  replicas: 1
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      app: clusterpedia-apiserver
      app.kubernetes.io/instance: clusterpedia
      app.kubernetes.io/name: clusterpedia
  strategy:
    rollingUpdate:
      maxSurge: 25%
      maxUnavailable: 25%
    type: RollingUpdate
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: clusterpedia-apiserver
        app.kubernetes.io/instance: clusterpedia
        app.kubernetes.io/managed-by: Helm
        app.kubernetes.io/name: clusterpedia
        app.kubernetes.io/version: v0.7.0
        helm.sh/chart: clusterpedia-2.0.1
    spec:
      containers:
      - command:
        - /usr/local/bin/apiserver
        - --secure-port=443
        - --storage-config=/etc/clusterpedia/storage/internalstorage-config.yaml
        - --tracing-config-file=/etc/clusterpedia/trace/tracing-config.yaml
        - -v=3
        env:
        - name: DB_PASSWORD
          valueFrom:
            secretKeyRef:
              key: password
              name: clusterpedia-internalstorage
        - name: OTEL_EXPORTER_OTLP_ENDPOINT
          value: localhost:4317
        - name: OTEL_SERVICE_NAME
          value: clusterpedia-apiserver
        - name: OTEL_K8S_NAMESPACE
          valueFrom:
            fieldRef:
              apiVersion: v1
              fieldPath: metadata.namespace
        - name: OTEL_RESOURCE_ATTRIBUTES_NODE_NAME
          valueFrom:
            fieldRef:
              apiVersion: v1
              fieldPath: spec.nodeName
        - name: OTEL_RESOURCE_ATTRIBUTES_POD_NAME
          valueFrom:
            fieldRef:
              apiVersion: v1
              fieldPath: metadata.name
        - name: OTEL_RESOURCE_ATTRIBUTES
          value: k8s.namespace.name=$(OTEL_K8S_NAMESPACE),k8s.node.name=$(OTEL_RESOURCE_ATTRIBUTES_NODE_NAME),k8s.pod.name=$(OTEL_RESOURCE_ATTRIBUTES_POD_NAME)
        - name: GODEBUG
          value: netdns=go
        image: ghcr.io/kubekyrie/clusterpedia/apiserver-amd64:latest
        imagePullPolicy: IfNotPresent
        name: clusterpedia-apiserver
        resources: {}
        terminationMessagePath: /dev/termination-log
        terminationMessagePolicy: File
        volumeMounts:
        - mountPath: /etc/clusterpedia/storage
          name: internalstorage-config
          readOnly: true
        - mountPath: /etc/clusterpedia/trace
          name: tracing-config
          readOnly: true
      dnsPolicy: ClusterFirst
      initContainers:
      - command:
        - /bin/bash
        - -ec
        - "# Load YAML data into a Bash variable\nsource /opt/scripts/parse-yaml.sh;\ncreate_variables
          /etc/clusterpedia/storage/internalstorage-config.yaml;\nuntil pg_isready
          -U ${user} -d \"dbname=${database}\" -h ${host} -p ${port}; do\necho waiting
          for database check && sleep 1; \ndone;\necho 'DataBase OK ✓'\n"
        image: docker.io/bitnami/postgresql:11.15.0-debian-10-r14
        imagePullPolicy: IfNotPresent
        name: check-storage
        resources: {}
        terminationMessagePath: /dev/termination-log
        terminationMessagePolicy: File
        volumeMounts:
        - mountPath: /etc/clusterpedia/storage
          name: internalstorage-config
          readOnly: true
        - mountPath: /opt/scripts
          name: scripts
          readOnly: true
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext: {}
      serviceAccount: clusterpedia-apiserver
      serviceAccountName: clusterpedia-apiserver
      terminationGracePeriodSeconds: 30
      volumes:
      - configMap:
          defaultMode: 420
          name: clusterpedia-internalstorage
        name: internalstorage-config
      - configMap:
          defaultMode: 420
          name: clusterpedia-scripts
        name: scripts
      - configMap:
          defaultMode: 420
          name: clusterpedia-tracing-config
        name: tracing-config
status:
  availableReplicas: 1
  conditions:
  - lastTransitionTime: "2023-12-05T11:52:16Z"
    lastUpdateTime: "2023-12-05T11:52:16Z"
    message: Deployment has minimum availability.
    reason: MinimumReplicasAvailable
    status: "True"
    type: Available
  - lastTransitionTime: "2023-12-05T11:51:28Z"
    lastUpdateTime: "2023-12-05T11:52:16Z"
    message: ReplicaSet "clusterpedia-apiserver-5474589d87" has successfully progressed.
    reason: NewReplicaSetAvailable
    status: "True"
    type: Progressing
  observedGeneration: 2
  readyReplicas: 1
  replicas: 1
  updatedReplicas: 1
KubeKyrie commented 11 months ago

@Iceber @calvin0327 PTAL

KubeKyrie commented 10 months ago

New test results:

  1. enable otel trace: helm install clusterpedia -n pedia-system --create-namespace ./charts/clusterpedia/ --set persistenceMatchNode=None --set postgresql.primary.persistence.enabled=false --set apiserver.telemetry.tracing.enabled=true --debug

企业微信截图_06b69133-f51d-41e3-a67c-349ef5726c2e

  1. default, disable otel trace: helm install clusterpedia -n pedia-system --create-namespace ./charts/clusterpedia/ --set persistenceMatchNode=None --set postgresql.primary.persistence.enabled=false --debug

image

calvin0327 commented 10 months ago

LGTM