-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented Helm deployment for OTel collector (#13)
* Fix trigger path * Implement otel collector Helm deployment
- Loading branch information
Showing
3 changed files
with
160 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |