Skip to content

Commit

Permalink
Implemented Helm deployment for OTel collector (#13)
Browse files Browse the repository at this point in the history
* Fix trigger path

* Implement otel collector Helm deployment
  • Loading branch information
utr1903 authored Jan 31, 2024
1 parent 7ea983d commit 864e757
Show file tree
Hide file tree
Showing 3 changed files with 160 additions and 1 deletion.
59 changes: 59 additions & 0 deletions .github/workflows/helm_deploy_otel_collector.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Helm OTel collector deployment

on:
workflow_dispatch:
pull_request:
branches:
- main
paths:
- ".github/workflows/helm_deploy_otel_collector.yaml"
- "infra/helm/otel/collector/**"

jobs:
helm_deploy:
name: "Deploy OTel collector"
runs-on: ubuntu-latest

steps:
- name: Checkout repository
id: checkout_repo
uses: actions/checkout@v2

- name: Login to Azure
id: login_to_azure
run: |
az login \
--service-principal \
-u ${{ secrets.AZURE_SERVICE_PRINCIPAL_APP_ID }} \
-p ${{ secrets.AZURE_SERVICE_PRINCIPAL_SECRET }} \
--tenant ${{ secrets.AZURE_TENANT_ID }}
- name: Get AKS credentials
id: get_aks_credentials
run: |
az aks get-credentials \
--resource-group "rg${{ secrets.PROJECT }}main${{ secrets.INSTANCE }}" \
--name "aks${{ secrets.PROJECT }}main${{ secrets.INSTANCE }}" \
--overwrite-existing
- name: Install Helm
id: install_helm
uses: azure/setup-helm@v3
with:
version: "v3.11.1"

- name: Deploy Helm chart
id: deploy_helm_chart
run: |
bash ./infra/helm/otel/collector/deploy.sh \
--project ${{ secrets.PROJECT }} \
--instance ${{ secrets.INSTANCE }} \
--cluster-type aks \
--newrelic-otlp-endpoint ${{ secrets.NEWRELIC_OTLP_ENDPOINT }} \
--newrelic-opsteam-license-key ${{ secrets.NEWRELIC_LICENSE_KEY_OPSTEAM }}
- name: Logout of Azure
id: logout_from_azure
if: always()
run: |
az logout
2 changes: 1 addition & 1 deletion .github/workflows/helm_deploy_otel_operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
branches:
- main
paths:
- ".github/workflows/helm_deploy_otel_operator.yml"
- ".github/workflows/helm_deploy_otel_operator.yaml"
- "infra/helm/otel/operator/**"

jobs:
Expand Down
100 changes: 100 additions & 0 deletions infra/helm/otel/collector/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
#!/bin/bash

# Get commandline arguments
while (( "$#" )); do
case "$1" in
--project)
project="${2}"
shift
;;
--instance)
instance="${2}"
shift
;;
--cluster-type)
clusterType="${2}"
shift
;;
--newrelic-otlp-endpoint)
newrelicOtlpEndpoint="${2}"
shift
;;
--newrelic-opsteam-license-key)
newrelicOpsteamLicenseKey="${2}"
shift
;;
*)
shift
;;
esac
done

### Check input

# Project
if [[ $project == "" ]]; then
echo -e "Project [--project] is not provided!\n"
exit 1
fi

# Instance
if [[ $instance == "" ]]; then
echo -e "Instance [--instance] is not provided!\n"
exit 1
fi

# Cluster type
if [[ $clusterType == "" ]]; then
echo "Cluster type [--cluster-type] is not given."
exit 1
else
if [[ $clusterType != "aks" ]]; then
echo "Given cluster type [--cluster-type] is not supported. Supported values are: aks."
exit 1
fi
clusterName="${clusterType}${project}${instance}"
fi

# New Relic OTLP endpoint
if [[ $newrelicOtlpEndpoint == "" ]]; then
echo -e "New Relic OTLP endpoint [--newrelic-otlp-endpoint] is not provided.\n"
exit 1
else
if [[ $newrelicOtlpEndpoint != "otlp.nr-data.net:4317" && $newrelicOtlpEndpoint != "otlp.eu01.nr-data.net:4317" ]]; then
echo "Given New Relic OTLP endpoint [--newrelic-otlp-endpoint] is not supported. Supported values are: US -> otlp.nr-data.net:4317, EU -> otlp.eu01.nr-data.net:4317."
exit 1
fi
fi

# New Relic OTLP endpoint
if [[ $newrelicOpsteamLicenseKey == "" ]]; then
echo -e "New Relic opsteam license key [--newrelic-opsteam-license-key] is not provided!\n"
exit 1
fi

### Set variables
declare -A otelcollectors
otelcollectors["name"]="nrotelk8s"
otelcollectors["namespace"]="monitoring"

###################
### Deploy Helm ###
###################

# Add helm repos
helm repo add newrelic-experimental https://newrelic-experimental.github.io/monitoring-kubernetes-with-opentelemetry/charts
helm repo update

# otel-collector
helm upgrade ${otelcollectors[name]} \
--install \
--wait \
--debug \
--create-namespace \
--namespace ${otelcollectors[namespace]} \
--set clusterName=$clusterName \
--set global.newrelic.enabled=true \
--set global.newrelic.endpoint=$newrelicOtlpEndpoint \
--set global.newrelic.teams.opsteam.licenseKey.value=$newrelicOpsteamLicenseKey \
--version "0.6.0" \
"newrelic-experimental/nrotelk8s"

0 comments on commit 864e757

Please sign in to comment.