diff --git a/.github/workflows/helm-lint.yml b/.github/workflows/helm-lint.yml new file mode 100644 index 000000000..c1ccbf7ba --- /dev/null +++ b/.github/workflows/helm-lint.yml @@ -0,0 +1,17 @@ +name: Lint Charts + +on: + pull_request: + paths: + - helm/** + +jobs: + lint-charts: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Install Helm + uses: azure/setup-helm@v4 + - name: Lint Charts + run: helm lint helm/* diff --git a/.github/workflows/publish-cli.yml b/.github/workflows/release.yml similarity index 73% rename from .github/workflows/publish-cli.yml rename to .github/workflows/release.yml index 9a03c9b1b..52a05aef1 100644 --- a/.github/workflows/publish-cli.yml +++ b/.github/workflows/release.yml @@ -18,18 +18,15 @@ env: DOCKERHUB_ORG: "keyval" jobs: - release: - runs-on: - labels: ubuntu-latest + release-cli: + runs-on: ubuntu-latest steps: - - name: Determine Tag Value - id: set_tag run: | if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then - echo "TAG=${{ github.event.inputs.tag }}" >> $GITHUB_OUTPUT + echo "TAG=${{ github.event.inputs.tag }}" >> $GITHUB_ENV elif [ "${{ github.event_name }}" = "repository_dispatch" ]; then - echo "TAG=${{ github.event.client_payload.tag }}" >> $GITHUB_OUTPUT + echo "TAG=${{ github.event.client_payload.tag }}" >> $GITHUB_ENV else echo "Unknown event type" exit 1 @@ -38,7 +35,7 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 - ref: ${{ steps.set_tag.outputs.tag }} + ref: ${{ env.TAG }} - name: Set env id: vars @@ -51,12 +48,12 @@ jobs: env: SLACK_WEBHOOK_URL: ${{ secrets.ODIGOS_RELEASE_STATUS_WEBHOOK_URL }} run: | - curl -X POST -H 'Content-type: application/json' --data '{"description":"Starting Odigos CLI release", "tag":"${{ steps.set_tag.outputs.tag }}"}' ${{ env.SLACK_WEBHOOK_URL }} + curl -X POST -H 'Content-type: application/json' --data '{"description":"Starting Odigos CLI release", "tag":"${{ env.TAG }}"}' ${{ env.SLACK_WEBHOOK_URL }} - name: Verify Components Image Ready run: | declare -a REPOS=("odigos-autoscaler" "odigos-scheduler" "odigos-instrumentor" "odigos-odiglet" "odigos-collector" "odigos-enterprise-odiglet") - TAG_TO_CHECK=${{ steps.set_tag.outputs.tag }} + TAG_TO_CHECK=${{ env.TAG }} for REPO in "${REPOS[@]}"; do echo "Checking tag $TAG_TO_CHECK in $REPO..." @@ -98,8 +95,7 @@ jobs: -H "Accept: application/vnd.github.v3+json" \ -H "Authorization: token ${{ secrets.RELEASE_BOT_TOKEN }}" \ https://api.github.com/repos/odigos-io/odigos-charts/dispatches \ - -d '{"event_type": "create_release_pr", "client_payload": {"tag": "${{ steps.set_tag.outputs.tag }}"}}' - + -d '{"event_type": "create_release_pr", "client_payload": {"tag": "${{ env.TAG }}"}}' - uses: ko-build/setup-ko@v0.7 @@ -108,17 +104,17 @@ jobs: env: KO_DOCKER_REPO: ${{ env.DOCKERHUB_ORG }}/odigos-cli KO_CONFIG_PATH: ./.ko.yaml - VERSION: ${{ steps.set_tag.outputs.tag }} + VERSION: ${{ env.TAG }} SHORT_COMMIT: ${{ steps.vars.outputs.short_commit }} DATE: ${{ steps.vars.outputs.date }} run: | - ko build --bare --tags latest --tags ${{ steps.set_tag.outputs.tag }} --platform=all . + ko build --bare --tags latest --tags ${{ env.TAG }} --platform=all . - name: Notify Slack End env: SLACK_WEBHOOK_URL: ${{ secrets.ODIGOS_RELEASE_STATUS_WEBHOOK_URL }} run: | - curl -X POST -H 'Content-type: application/json' --data '{"description":"Odigos CLI released successfully. new version is ready", "tag":"${{ steps.set_tag.outputs.tag }}"}' ${{ env.SLACK_WEBHOOK_URL }} + curl -X POST -H 'Content-type: application/json' --data '{"description":"Odigos CLI released successfully. new version is ready", "tag":"${{ env.TAG }}"}' ${{ env.SLACK_WEBHOOK_URL }} - name: Notify Slack on Failure if: failure() @@ -127,4 +123,37 @@ jobs: GITHUB_REPOSITORY: ${{ github.repository }} GITHUB_RUN_ID: ${{ github.run_id }} run: | - curl -X POST -H 'Content-type: application/json' --data '{"link":"https://github.com/${{ env.GITHUB_REPOSITORY }}/actions/runs/${{ env.GITHUB_RUN_ID }}", "description":"ERROR: failed to publish odigos CLI", "tag":"${{ steps.set_tag.outputs.tag }}"}' ${{ env.SLACK_WEBHOOK_URL }} + curl -X POST -H 'Content-type: application/json' --data '{"link":"https://github.com/${{ env.GITHUB_REPOSITORY }}/actions/runs/${{ env.GITHUB_RUN_ID }}", "description":"ERROR: failed to publish odigos CLI", "tag":"${{ env.TAG }}"}' ${{ env.SLACK_WEBHOOK_URL }} + + release-helm: + needs: [release-cli] + runs-on: ubuntu-latest + steps: + - name: Determine Tag Value + run: | + if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then + echo "TAG=${{ github.event.inputs.tag }}" >> $GITHUB_ENV + elif [ "${{ github.event_name }}" = "repository_dispatch" ]; then + echo "TAG=${{ github.event.client_payload.tag }}" >> $GITHUB_ENV + else + echo "Unknown event type" + exit 1 + fi + + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Configure Git + run: | + git config --global user.email "bot@odigos.io" + git config --global user.name "Odigos Release Bot" + + - name: Install Helm + uses: azure/setup-helm@v4.2.0 + with: + version: v3.15.2 + + - name: Release Helm charts + run: sh ./scripts/release-charts.sh diff --git a/common/envOverwrite/owerwriter_test.go b/common/envOverwrite/overwriter_test.go similarity index 100% rename from common/envOverwrite/owerwriter_test.go rename to common/envOverwrite/overwriter_test.go diff --git a/helm/odigos/.helmignore b/helm/odigos/.helmignore new file mode 100644 index 000000000..0e8a0eb36 --- /dev/null +++ b/helm/odigos/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/helm/odigos/Chart.yaml b/helm/odigos/Chart.yaml new file mode 100644 index 000000000..574dc984e --- /dev/null +++ b/helm/odigos/Chart.yaml @@ -0,0 +1,8 @@ +apiVersion: v2 +name: odigos +description: Odigos Helm Chart for Kubernetes +type: application +# v0.0.0 will be replaced by the git tag version on release +version: "v0.0.0" +appVersion: "v0.0.0" +icon: https://d2q89wckrml3k4.cloudfront.net/logo.png diff --git a/helm/odigos/templates/odigos-config.yaml b/helm/odigos/templates/odigos-config.yaml new file mode 100644 index 000000000..0e8eb711b --- /dev/null +++ b/helm/odigos/templates/odigos-config.yaml @@ -0,0 +1,120 @@ +# THIS RESOURCE STILL LIVES IN odigos-io/odigos-charts repo +# ADDED HERE FOR TESTING WORKFLOWS +apiVersion: odigos.io/v1alpha1 +kind: OdigosConfiguration +metadata: + name: odigos-config + namespace: {{ .Release.Namespace }} + annotations: + "helm.sh/hook": post-install,post-upgrade +spec: + configVersion: 1 + autoscalerImage: {{ .Values.autoscaler.image.repository }} + {{- if .Values.imagePrefix }} + imagePrefix: {{ .Values.imagePrefix }} + {{- end }} + {{- if .Values.collectorGateway }} + collectorGateway: + {{- with .Values.collectorGateway.requestMemoryMiB }} + requestMemoryMiB: {{ . }} + {{- end }} + {{- with .Values.collectorGateway.memoryLimiterLimitMiB }} + memoryLimiterLimitMiB: {{ . }} + {{- end }} + {{- with .Values.collectorGateway.memoryLimiterSpikeLimitMiB }} + memoryLimiterSpikeLimitMiB: {{ . }} + {{- end }} + {{- with .Values.collectorGateway.goMemLimitMiB }} + goMemLimitMiB: {{ . }} + {{- end }} + {{- end }} + instrumentorImage: {{ .Values.instrumentor.image.repository }} + odigosVersion: {{ .Values.image.tag | default .Chart.AppVersion }} + telemetryEnabled: {{ .Values.telemetry.enabled }} + openshiftEnabled: {{ .Values.openshift.enabled }} + psp: {{ .Values.psp.enabled }} + ignoredNamespaces: + {{- toYaml .Values.ignoredNamespaces | nindent 8 }} + ignoredContainers: + {{- toYaml .Values.ignoredContainers | nindent 8 }} + {{- if .Values.onPremToken }} + defaultSDKs: + dotnet: + sdkTier: community + sdkType: native + go: + sdkTier: enterprise + sdkType: ebpf + java: + sdkTier: enterprise + sdkType: ebpf + javascript: + sdkTier: enterprise + sdkType: ebpf + python: + sdkTier: enterprise + sdkType: ebpf + mysql: + sdkTier: enterprise + sdkType: ebpf + supportedSDKs: + dotnet: + - sdkTier: community + sdkType: native + go: + - sdkTier: enterprise + sdkType: ebpf + java: + - sdkTier: community + sdkType: native + - sdkTier: enterprise + sdkType: ebpf + - sdkTier: enterprise + sdkType: native + javascript: + - sdkTier: community + sdkType: native + - sdkTier: enterprise + sdkType: ebpf + python: + - sdkTier: community + sdkType: native + - sdkTier: enterprise + sdkType: ebpf + mysql: + - sdkTier: enterprise + sdkType: ebpf + {{- else }} + defaultSDKs: + dotnet: + sdkTier: community + sdkType: native + go: + sdkTier: community + sdkType: ebpf + java: + sdkTier: community + sdkType: native + javascript: + sdkTier: community + sdkType: native + python: + sdkTier: community + sdkType: native + supportedSDKs: + dotnet: + - sdkTier: community + sdkType: native + go: + - sdkTier: community + sdkType: ebpf + java: + - sdkTier: community + sdkType: native + javascript: + - sdkTier: community + sdkType: native + python: + - sdkTier: community + sdkType: native + {{- end }} \ No newline at end of file diff --git a/helm/odigos/templates/odigos-deployment.yaml b/helm/odigos/templates/odigos-deployment.yaml new file mode 100644 index 000000000..f511866d9 --- /dev/null +++ b/helm/odigos/templates/odigos-deployment.yaml @@ -0,0 +1,9 @@ +# THIS RESOURCE STILL LIVES IN odigos-io/odigos-charts repo +# ADDED HERE FOR TESTING WORKFLOWS +apiVersion: v1 +kind: ConfigMap +metadata: + name: odigos-deployment + namespace: {{ .Release.Namespace }} +data: + ODIGOS_VERSION: {{ .Values.image.tag | default .Chart.AppVersion }} diff --git a/helm/odigos/values.yaml b/helm/odigos/values.yaml new file mode 100644 index 000000000..70cfea37f --- /dev/null +++ b/helm/odigos/values.yaml @@ -0,0 +1,97 @@ +image: + tag: "" +imagePullSecrets: [] + +# namespaces not to show in odigos ui +ignoredNamespaces: + - odigos-system + - kube-system + - local-path-storage + - istio-system + - linkerd + - kube-node-lease + +ignoredContainers: + - istio-proxy + +collectorGateway: + # the memory request for the cluster gateway collector deployment. + # it will be embedded in the deployment as a resource request + # of the form "memory: Mi". + # default value is 500Mi + requestMemoryMiB: 500 + # sets the "limit_mib" parameter in the memory limiter configuration for the collector gateway. + # it is the hard limit after which a force garbage collection will be performed. + # if not set, it will be 50Mi below the memory request. + memoryLimiterLimitMiB: 450 + # sets the "spike_limit_mib" parameter in the memory limiter configuration for the collector gateway. + # note that this is not the processor soft limit, but the diff in MiB between the hard limit and the soft limit. + # if not specified, this value will be set to 20% of the hard limit (so the soft limit will be 80% of the hard limit). + memoryLimiterSpikeLimitMiB: 90 + # the GOMEMLIMIT environment variable value for the collector gateway deployment. + # this is when go runtime will start garbage collection. + # if not specified, it will be set to 80% of the hard limit of the memory limiter. + goMemLimitMiB: 340 + +autoscaler: + image: + repository: keyval/odigos-autoscaler + nodeSelector: + kubernetes.io/os: linux + tolerations: [] + affinity: {} + +scheduler: + image: + repository: keyval/odigos-scheduler + nodeSelector: + kubernetes.io/os: linux + tolerations: [] + affinity: {} + +ui: + image: + repository: keyval/odigos-ui + nodeSelector: + kubernetes.io/os: linux + tolerations: [] + affinity: {} + +instrumentor: + deleteLangDetectionPods: true + image: + repository: keyval/odigos-instrumentor + nodeSelector: + kubernetes.io/os: linux + tolerations: [] + affinity: {} + +odiglet: + image: + repository: keyval/odigos-odiglet + enterpriseRepository: keyval/odigos-enterprise-odiglet + nodeSelector: + kubernetes.io/os: linux + tolerations: + - effect: NoSchedule + key: node.kubernetes.io/os + operator: Equal + value: windows + affinity: {} + +cli: + image: + repository: keyval/odigos-cli + +# Pod Security Policy +psp: + enabled: false + +telemetry: + enabled: true + +openshift: + enabled: false + +gke: + enabled: false \ No newline at end of file diff --git a/scripts/release-charts.sh b/scripts/release-charts.sh new file mode 100644 index 000000000..443a4824b --- /dev/null +++ b/scripts/release-charts.sh @@ -0,0 +1,49 @@ +#!/usr/bin/env sh + +# Setup +TMPDIR="$(mktemp -d)" +CHARTDIR="helm/odigos" + +if [ -z "$TAG" ]; then + echo "TAG required" + exit 1 +fi + +if [ -z "$GITHUB_REPOSITORY" ]; then + echo "GITHUB_REPOSITORY required" + exit 1 +fi + +if [[ $(git diff -- $CHARTDIR | wc -c) -ne 0 ]]; then + echo "Helm chart dirty. Aborting." + exit 1 +fi + +# Ignore errors because it will mostly always error locally +helm repo add odigos https://odigos-io.github.io/odigos-charts 2> /dev/null || true +git worktree add $TMPDIR gh-pages -f + +# Update index with new packages +sed -i -E 's/v0.0.0/'"${TAG}"'/' $CHARTDIR/Chart.yaml +helm package helm/* -d $TMPDIR +pushd $TMPDIR +helm repo index . --merge index.yaml --url https://github.com/$GITHUB_REPOSITORY/releases/download/$TAG/ + +# The check avoids pushing the same tag twice and only pushes if there's a new entry in the index +if [[ $(git diff -G apiVersion | wc -c) -ne 0 ]]; then + # Upload new packages + rename 'odigos' 'test-helm-assets-odigos' *.tgz + gh release upload -R $GITHUB_REPOSITORY $TAG $TMPDIR/*.tgz + + git add index.yaml + git commit -m "update index with $TAG" && git push + popd + git fetch +else + echo "No significant changes" + popd +fi + +# Roll back chart version changes +git checkout $CHARTDIR +git worktree remove $TMPDIR -f || echo " -> Failed to clean up temp worktree"