@ -0,0 +1,50 @@ | |||
name: Deploy basket-api | |||
on: | |||
workflow_dispatch: | |||
repository_dispatch: | |||
types: | |||
- deploy | |||
workflow_run: | |||
workflows: ["basket-api"] | |||
branches: [dev] | |||
types: [completed] | |||
env: | |||
CHART: basket-api | |||
NAMESPACE: eshop | |||
CHART_ROOT: deploy/k8s/helm | |||
jobs: | |||
deploy-to-k8s: | |||
#if: ${{ github.event_name == 'workflow_dispatch' || github.event_name == 'repository_dispatch' || github.event.workflow_run.conclusion == 'success' }} | |||
if: false | |||
runs-on: ubuntu-latest | |||
steps: | |||
- uses: actions/checkout@v2 | |||
- uses: azure/login@v1 | |||
with: | |||
creds: ${{ secrets.AZURE_CREDENTIALS }} | |||
- uses: azure/aks-set-context@v1 | |||
name: Set AKS context | |||
with: | |||
creds: '${{ secrets.AZURE_CREDENTIALS }}' | |||
cluster-name: ${{ secrets.CLUSTER_NAME }} | |||
resource-group: ${{ secrets.RESOURCE_GROUP }} | |||
- name: Set branch name as env variable | |||
run: | | |||
currentbranch=$(echo ${GITHUB_REF##*/}) | |||
echo "running on $currentbranch" | |||
echo "BRANCH=$currentbranch" >> $GITHUB_ENV | |||
shell: bash | |||
- name: Deploy Chart | |||
run: | | |||
./deploy-chart.sh -c ${{ env.CHART }} --dns aks --aks-name ${{ secrets.CLUSTER_NAME }} --aks-rg ${{ secrets.RESOURCE_GROUP }} -r ${{ secrets.REGISTRY_HOST }} -t $TAG --namespace ${{ env.NAMESPACE }} --acr-connected | |||
env: | |||
TAG: ${{ env.BRANCH }} | |||
working-directory: ${{ env.CHART_ROOT }} |
@ -0,0 +1,50 @@ | |||
name: Deploy catalog-api | |||
on: | |||
workflow_dispatch: | |||
repository_dispatch: | |||
types: | |||
- deploy | |||
workflow_run: | |||
workflows: ["catalog-api"] | |||
branches: [dev] | |||
types: [completed] | |||
env: | |||
CHART: catalog-api | |||
NAMESPACE: eshop | |||
CHART_ROOT: deploy/k8s/helm | |||
jobs: | |||
deploy-to-k8s: | |||
#if: ${{ github.event_name == 'workflow_dispatch' || github.event_name == 'repository_dispatch' || github.event.workflow_run.conclusion == 'success' }} | |||
if: false | |||
runs-on: ubuntu-latest | |||
steps: | |||
- uses: actions/checkout@v2 | |||
- uses: azure/login@v1 | |||
with: | |||
creds: ${{ secrets.AZURE_CREDENTIALS }} | |||
- uses: azure/aks-set-context@v1 | |||
name: Set AKS context | |||
with: | |||
creds: '${{ secrets.AZURE_CREDENTIALS }}' | |||
cluster-name: ${{ secrets.CLUSTER_NAME }} | |||
resource-group: ${{ secrets.RESOURCE_GROUP }} | |||
- name: Set branch name as env variable | |||
run: | | |||
currentbranch=$(echo ${GITHUB_REF##*/}) | |||
echo "running on $currentbranch" | |||
echo "BRANCH=$currentbranch" >> $GITHUB_ENV | |||
shell: bash | |||
- name: Deploy chart | |||
run: | | |||
./deploy-chart.sh -c ${{ env.CHART }} --dns aks --aks-name ${{ secrets.CLUSTER_NAME }} --aks-rg ${{ secrets.RESOURCE_GROUP }} -r ${{ secrets.REGISTRY_HOST }} -t $TAG --namespace ${{ env.NAMESPACE }} --acr-connected | |||
env: | |||
TAG: ${{ env.BRANCH }} | |||
working-directory: ${{ env.CHART_ROOT }} |
@ -0,0 +1,50 @@ | |||
name: Deploy identity-api | |||
on: | |||
workflow_dispatch: | |||
repository_dispatch: | |||
types: | |||
- deploy | |||
workflow_run: | |||
workflows: ["identity-api"] | |||
branches: [dev] | |||
types: [completed] | |||
env: | |||
CHART: identity-api | |||
NAMESPACE: eshop | |||
CHART_ROOT: deploy/k8s/helm | |||
jobs: | |||
deploy-to-k8s: | |||
#if: ${{ github.event_name == 'workflow_dispatch' || github.event_name == 'repository_dispatch' || github.event.workflow_run.conclusion == 'success' }} | |||
if: false | |||
runs-on: ubuntu-latest | |||
steps: | |||
- uses: actions/checkout@v2 | |||
- uses: azure/login@v1 | |||
with: | |||
creds: ${{ secrets.AZURE_CREDENTIALS }} | |||
- uses: azure/aks-set-context@v1 | |||
name: Set AKS context | |||
with: | |||
creds: '${{ secrets.AZURE_CREDENTIALS }}' | |||
cluster-name: ${{ secrets.CLUSTER_NAME }} | |||
resource-group: ${{ secrets.RESOURCE_GROUP }} | |||
- name: Set branch name as env variable | |||
run: | | |||
currentbranch=$(echo ${GITHUB_REF##*/}) | |||
echo "running on $currentbranch" | |||
echo "BRANCH=$currentbranch" >> $GITHUB_ENV | |||
shell: bash | |||
- name: Deploy Chart | |||
run: | | |||
./deploy-chart.sh -c ${{ env.CHART }} --dns aks --aks-name ${{ secrets.CLUSTER_NAME }} --aks-rg ${{ secrets.RESOURCE_GROUP }} -r ${{ secrets.REGISTRY_HOST }} -t $TAG --namespace ${{ env.NAMESPACE }} --acr-connected | |||
env: | |||
TAG: ${{ env.BRANCH }} | |||
working-directory: ${{ env.CHART_ROOT }} |
@ -0,0 +1,50 @@ | |||
name: Deploy mobileshoppingagg | |||
on: | |||
workflow_dispatch: | |||
repository_dispatch: | |||
types: | |||
- deploy | |||
workflow_run: | |||
workflows: ["mobileshoppingagg"] | |||
branches: [dev] | |||
types: [completed] | |||
env: | |||
CHART: mobileshoppingagg | |||
NAMESPACE: eshop | |||
CHART_ROOT: deploy/k8s/helm | |||
jobs: | |||
deploy-to-k8s: | |||
#if: ${{ github.event_name == 'workflow_dispatch' || github.event_name == 'repository_dispatch' || github.event.workflow_run.conclusion == 'success' }} | |||
if: false | |||
runs-on: ubuntu-latest | |||
steps: | |||
- uses: actions/checkout@v2 | |||
- uses: azure/login@v1 | |||
with: | |||
creds: ${{ secrets.AZURE_CREDENTIALS }} | |||
- uses: azure/aks-set-context@v1 | |||
name: Set AKS context | |||
with: | |||
creds: '${{ secrets.AZURE_CREDENTIALS }}' | |||
cluster-name: ${{ secrets.CLUSTER_NAME }} | |||
resource-group: ${{ secrets.RESOURCE_GROUP }} | |||
- name: Set branch name as env variable | |||
run: | | |||
currentbranch=$(echo ${GITHUB_REF##*/}) | |||
echo "running on $currentbranch" | |||
echo "BRANCH=$currentbranch" >> $GITHUB_ENV | |||
shell: bash | |||
- name: Deploy Chart | |||
run: | | |||
./deploy-chart.sh -c ${{ env.CHART }} --dns aks --aks-name ${{ secrets.CLUSTER_NAME }} --aks-rg ${{ secrets.RESOURCE_GROUP }} -r ${{ secrets.REGISTRY_HOST }} -t $TAG --namespace ${{ env.NAMESPACE }} --acr-connected | |||
env: | |||
TAG: ${{ env.BRANCH }} | |||
working-directory: ${{ env.CHART_ROOT }} |
@ -0,0 +1,50 @@ | |||
name: Deploy ordering-api | |||
on: | |||
workflow_dispatch: | |||
repository_dispatch: | |||
types: | |||
- deploy | |||
workflow_run: | |||
workflows: ["ordering-api"] | |||
branches: [dev] | |||
types: [completed] | |||
env: | |||
CHART: ordering-api | |||
NAMESPACE: eshop | |||
CHART_ROOT: deploy/k8s/helm | |||
jobs: | |||
deploy-to-k8s: | |||
#if: ${{ github.event_name == 'workflow_dispatch' || github.event_name == 'repository_dispatch' || github.event.workflow_run.conclusion == 'success' }} | |||
if: false | |||
runs-on: ubuntu-latest | |||
steps: | |||
- uses: actions/checkout@v2 | |||
- uses: azure/login@v1 | |||
with: | |||
creds: ${{ secrets.AZURE_CREDENTIALS }} | |||
- uses: azure/aks-set-context@v1 | |||
name: Set AKS context | |||
with: | |||
creds: '${{ secrets.AZURE_CREDENTIALS }}' | |||
cluster-name: ${{ secrets.CLUSTER_NAME }} | |||
resource-group: ${{ secrets.RESOURCE_GROUP }} | |||
- name: Set branch name as env variable | |||
run: | | |||
currentbranch=$(echo ${GITHUB_REF##*/}) | |||
echo "running on $currentbranch" | |||
echo "BRANCH=$currentbranch" >> $GITHUB_ENV | |||
shell: bash | |||
- name: Deploy Chart | |||
run: | | |||
./deploy-chart.sh -c ${{ env.CHART }} --dns aks --aks-name ${{ secrets.CLUSTER_NAME }} --aks-rg ${{ secrets.RESOURCE_GROUP }} -r ${{ secrets.REGISTRY_HOST }} -t $TAG --namespace ${{ env.NAMESPACE }} --acr-connected | |||
env: | |||
TAG: ${{ env.BRANCH }} | |||
working-directory: ${{ env.CHART_ROOT }} |
@ -0,0 +1,50 @@ | |||
name: Deploy ordering-backgroundtasks | |||
on: | |||
workflow_dispatch: | |||
repository_dispatch: | |||
types: | |||
- deploy | |||
workflow_run: | |||
workflows: ["ordering-backgroundtasks"] | |||
branches: [dev] | |||
types: [completed] | |||
env: | |||
CHART: ordering-backgroundtasks | |||
NAMESPACE: eshop | |||
CHART_ROOT: deploy/k8s/helm | |||
jobs: | |||
deploy-to-k8s: | |||
#if: ${{ github.event_name == 'workflow_dispatch' || github.event_name == 'repository_dispatch' || github.event.workflow_run.conclusion == 'success' }} | |||
if: false | |||
runs-on: ubuntu-latest | |||
steps: | |||
- uses: actions/checkout@v2 | |||
- uses: azure/login@v1 | |||
with: | |||
creds: ${{ secrets.AZURE_CREDENTIALS }} | |||
- uses: azure/aks-set-context@v1 | |||
name: Set AKS context | |||
with: | |||
creds: '${{ secrets.AZURE_CREDENTIALS }}' | |||
cluster-name: ${{ secrets.CLUSTER_NAME }} | |||
resource-group: ${{ secrets.RESOURCE_GROUP }} | |||
- name: Set branch name as env variable | |||
run: | | |||
currentbranch=$(echo ${GITHUB_REF##*/}) | |||
echo "running on $currentbranch" | |||
echo "BRANCH=$currentbranch" >> $GITHUB_ENV | |||
shell: bash | |||
- name: Deploy Chart | |||
run: | | |||
./deploy-chart.sh -c ${{ env.CHART }} --dns aks --aks-name ${{ secrets.CLUSTER_NAME }} --aks-rg ${{ secrets.RESOURCE_GROUP }} -r ${{ secrets.REGISTRY_HOST }} -t $TAG --namespace ${{ env.NAMESPACE }} --acr-connected | |||
env: | |||
TAG: ${{ env.BRANCH }} | |||
working-directory: ${{ env.CHART_ROOT }} |
@ -0,0 +1,50 @@ | |||
name: Deploy ordering-signalrhub | |||
on: | |||
workflow_dispatch: | |||
repository_dispatch: | |||
types: | |||
- deploy | |||
workflow_run: | |||
workflows: ["ordering-signalrhub"] | |||
branches: [dev] | |||
types: [completed] | |||
env: | |||
CHART: ordering-signalrhub | |||
NAMESPACE: eshop | |||
CHART_ROOT: deploy/k8s/helm | |||
jobs: | |||
deploy-to-k8s: | |||
#if: ${{ github.event_name == 'workflow_dispatch' || github.event_name == 'repository_dispatch' || github.event.workflow_run.conclusion == 'success' }} | |||
if: false | |||
runs-on: ubuntu-latest | |||
steps: | |||
- uses: actions/checkout@v2 | |||
- uses: azure/login@v1 | |||
with: | |||
creds: ${{ secrets.AZURE_CREDENTIALS }} | |||
- uses: azure/aks-set-context@v1 | |||
name: Set AKS context | |||
with: | |||
creds: '${{ secrets.AZURE_CREDENTIALS }}' | |||
cluster-name: ${{ secrets.CLUSTER_NAME }} | |||
resource-group: ${{ secrets.RESOURCE_GROUP }} | |||
- name: Set branch name as env variable | |||
run: | | |||
currentbranch=$(echo ${GITHUB_REF##*/}) | |||
echo "running on $currentbranch" | |||
echo "BRANCH=$currentbranch" >> $GITHUB_ENV | |||
shell: bash | |||
- name: Deploy Chart | |||
run: | | |||
./deploy-chart.sh -c ${{ env.CHART }} --dns aks --aks-name ${{ secrets.CLUSTER_NAME }} --aks-rg ${{ secrets.RESOURCE_GROUP }} -r ${{ secrets.REGISTRY_HOST }} -t $TAG --namespace ${{ env.NAMESPACE }} --acr-connected | |||
env: | |||
TAG: ${{ env.BRANCH }} | |||
working-directory: ${{ env.CHART_ROOT }} |
@ -0,0 +1,50 @@ | |||
name: Deploy payment-api | |||
on: | |||
workflow_dispatch: | |||
repository_dispatch: | |||
types: | |||
- deploy | |||
workflow_run: | |||
workflows: ["payment-api"] | |||
branches: [dev] | |||
types: [completed] | |||
env: | |||
CHART: payment-api | |||
NAMESPACE: eshop | |||
CHART_ROOT: deploy/k8s/helm | |||
jobs: | |||
deploy-to-k8s: | |||
#if: ${{ github.event_name == 'workflow_dispatch' || github.event_name == 'repository_dispatch' || github.event.workflow_run.conclusion == 'success' }} | |||
if: false | |||
runs-on: ubuntu-latest | |||
steps: | |||
- uses: actions/checkout@v2 | |||
- uses: azure/login@v1 | |||
with: | |||
creds: ${{ secrets.AZURE_CREDENTIALS }} | |||
- uses: azure/aks-set-context@v1 | |||
name: Set AKS context | |||
with: | |||
creds: '${{ secrets.AZURE_CREDENTIALS }}' | |||
cluster-name: ${{ secrets.CLUSTER_NAME }} | |||
resource-group: ${{ secrets.RESOURCE_GROUP }} | |||
- name: Set branch name as env variable | |||
run: | | |||
currentbranch=$(echo ${GITHUB_REF##*/}) | |||
echo "running on $currentbranch" | |||
echo "BRANCH=$currentbranch" >> $GITHUB_ENV | |||
shell: bash | |||
- name: Deploy Chart | |||
run: | | |||
./deploy-chart.sh -c ${{ env.CHART }} --dns aks --aks-name ${{ secrets.CLUSTER_NAME }} --aks-rg ${{ secrets.RESOURCE_GROUP }} -r ${{ secrets.REGISTRY_HOST }} -t $TAG --namespace ${{ env.NAMESPACE }} --acr-connected | |||
env: | |||
TAG: ${{ env.BRANCH }} | |||
working-directory: ${{ env.CHART_ROOT }} |
@ -0,0 +1,50 @@ | |||
name: Deploy webhooks-api | |||
on: | |||
workflow_dispatch: | |||
repository_dispatch: | |||
types: | |||
- deploy | |||
workflow_run: | |||
workflows: ["webhooks-api"] | |||
branches: [dev] | |||
types: [completed] | |||
env: | |||
CHART: webhooks-api | |||
NAMESPACE: eshop | |||
CHART_ROOT: deploy/k8s/helm | |||
jobs: | |||
deploy-to-k8s: | |||
#if: ${{ github.event_name == 'workflow_dispatch' || github.event_name == 'repository_dispatch' || github.event.workflow_run.conclusion == 'success' }} | |||
if: false | |||
runs-on: ubuntu-latest | |||
steps: | |||
- uses: actions/checkout@v2 | |||
- uses: azure/login@v1 | |||
with: | |||
creds: ${{ secrets.AZURE_CREDENTIALS }} | |||
- uses: azure/aks-set-context@v1 | |||
name: Set AKS context | |||
with: | |||
creds: '${{ secrets.AZURE_CREDENTIALS }}' | |||
cluster-name: ${{ secrets.CLUSTER_NAME }} | |||
resource-group: ${{ secrets.RESOURCE_GROUP }} | |||
- name: Set branch name as env variable | |||
run: | | |||
currentbranch=$(echo ${GITHUB_REF##*/}) | |||
echo "running on $currentbranch" | |||
echo "BRANCH=$currentbranch" >> $GITHUB_ENV | |||
shell: bash | |||
- name: Deploy Chart | |||
run: | | |||
./deploy-chart.sh -c ${{ env.CHART }} --dns aks --aks-name ${{ secrets.CLUSTER_NAME }} --aks-rg ${{ secrets.RESOURCE_GROUP }} -r ${{ secrets.REGISTRY_HOST }} -t $TAG --namespace ${{ env.NAMESPACE }} --acr-connected | |||
env: | |||
TAG: ${{ env.BRANCH }} | |||
working-directory: ${{ env.CHART_ROOT }} |
@ -0,0 +1,50 @@ | |||
name: Deploy webmvc | |||
on: | |||
workflow_dispatch: | |||
repository_dispatch: | |||
types: | |||
- deploy | |||
workflow_run: | |||
workflows: ["webmvc"] | |||
branches: [dev] | |||
types: [completed] | |||
env: | |||
CHART: webmvc | |||
NAMESPACE: eshop | |||
CHART_ROOT: deploy/k8s/helm | |||
jobs: | |||
deploy-to-k8s: | |||
#if: ${{ github.event_name == 'workflow_dispatch' || github.event_name == 'repository_dispatch' || github.event.workflow_run.conclusion == 'success' }} | |||
if: false | |||
runs-on: ubuntu-latest | |||
steps: | |||
- uses: actions/checkout@v2 | |||
- uses: azure/login@v1 | |||
with: | |||
creds: ${{ secrets.AZURE_CREDENTIALS }} | |||
- uses: azure/aks-set-context@v1 | |||
name: Set AKS context | |||
with: | |||
creds: '${{ secrets.AZURE_CREDENTIALS }}' | |||
cluster-name: ${{ secrets.CLUSTER_NAME }} | |||
resource-group: ${{ secrets.RESOURCE_GROUP }} | |||
- name: Set branch name as env variable | |||
run: | | |||
currentbranch=$(echo ${GITHUB_REF##*/}) | |||
echo "running on $currentbranch" | |||
echo "BRANCH=$currentbranch" >> $GITHUB_ENV | |||
shell: bash | |||
- name: Deploy Chart | |||
run: | | |||
./deploy-chart.sh -c ${{ env.CHART }} --dns aks --aks-name ${{ secrets.CLUSTER_NAME }} --aks-rg ${{ secrets.RESOURCE_GROUP }} -r ${{ secrets.REGISTRY_HOST }} -t $TAG --namespace ${{ env.NAMESPACE }} --acr-connected | |||
env: | |||
TAG: ${{ env.BRANCH }} | |||
working-directory: ${{ env.CHART_ROOT }} |
@ -0,0 +1,50 @@ | |||
name: Deploy webshoppingagg | |||
on: | |||
workflow_dispatch: | |||
repository_dispatch: | |||
types: | |||
- deploy | |||
workflow_run: | |||
workflows: ["webshoppingagg"] | |||
branches: [dev] | |||
types: [completed] | |||
env: | |||
CHART: webshoppingagg | |||
NAMESPACE: eshop | |||
CHART_ROOT: deploy/k8s/helm | |||
jobs: | |||
deploy-to-k8s: | |||
#if: ${{ github.event_name == 'workflow_dispatch' || github.event_name == 'repository_dispatch' || github.event.workflow_run.conclusion == 'success' }} | |||
if: false | |||
runs-on: ubuntu-latest | |||
steps: | |||
- uses: actions/checkout@v2 | |||
- uses: azure/login@v1 | |||
with: | |||
creds: ${{ secrets.AZURE_CREDENTIALS }} | |||
- uses: azure/aks-set-context@v1 | |||
name: Set AKS context | |||
with: | |||
creds: '${{ secrets.AZURE_CREDENTIALS }}' | |||
cluster-name: ${{ secrets.CLUSTER_NAME }} | |||
resource-group: ${{ secrets.RESOURCE_GROUP }} | |||
- name: Set branch name as env variable | |||
run: | | |||
currentbranch=$(echo ${GITHUB_REF##*/}) | |||
echo "running on $currentbranch" | |||
echo "BRANCH=$currentbranch" >> $GITHUB_ENV | |||
shell: bash | |||
- name: Deploy Chart | |||
run: | | |||
./deploy-chart.sh -c ${{ env.CHART }} --dns aks --aks-name ${{ secrets.CLUSTER_NAME }} --aks-rg ${{ secrets.RESOURCE_GROUP }} -r ${{ secrets.REGISTRY_HOST }} -t $TAG --namespace ${{ env.NAMESPACE }} --acr-connected | |||
env: | |||
TAG: ${{ env.BRANCH }} | |||
working-directory: ${{ env.CHART_ROOT }} |
@ -0,0 +1,50 @@ | |||
name: Deploy webspa | |||
on: | |||
workflow_dispatch: | |||
repository_dispatch: | |||
types: | |||
- deploy | |||
workflow_run: | |||
workflows: ["webspa"] | |||
branches: [dev] | |||
types: [completed] | |||
env: | |||
CHART: webspa | |||
NAMESPACE: eshop | |||
CHART_ROOT: deploy/k8s/helm | |||
jobs: | |||
deploy-to-k8s: | |||
#if: ${{ github.event_name == 'workflow_dispatch' || github.event_name == 'repository_dispatch' || github.event.workflow_run.conclusion == 'success' }} | |||
if: false | |||
runs-on: ubuntu-latest | |||
steps: | |||
- uses: actions/checkout@v2 | |||
- uses: azure/login@v1 | |||
with: | |||
creds: ${{ secrets.AZURE_CREDENTIALS }} | |||
- uses: azure/aks-set-context@v1 | |||
name: Set AKS context | |||
with: | |||
creds: '${{ secrets.AZURE_CREDENTIALS }}' | |||
cluster-name: ${{ secrets.CLUSTER_NAME }} | |||
resource-group: ${{ secrets.RESOURCE_GROUP }} | |||
- name: Set branch name as env variable | |||
run: | | |||
currentbranch=$(echo ${GITHUB_REF##*/}) | |||
echo "running on $currentbranch" | |||
echo "BRANCH=$currentbranch" >> $GITHUB_ENV | |||
shell: bash | |||
- name: Deploy Chart | |||
run: | | |||
./deploy-chart.sh -c ${{ env.CHART }} --dns aks --aks-name ${{ secrets.CLUSTER_NAME }} --aks-rg ${{ secrets.RESOURCE_GROUP }} -r ${{ secrets.REGISTRY_HOST }} -t $TAG --namespace ${{ env.NAMESPACE }} --acr-connected | |||
env: | |||
TAG: ${{ env.BRANCH }} | |||
working-directory: ${{ env.CHART_ROOT }} |
@ -0,0 +1,50 @@ | |||
name: Deploy webstatus | |||
on: | |||
workflow_dispatch: | |||
repository_dispatch: | |||
types: | |||
- deploy | |||
workflow_run: | |||
workflows: ["webstatus"] | |||
branches: [dev] | |||
types: [completed] | |||
env: | |||
CHART: webstatus | |||
NAMESPACE: eshop | |||
CHART_ROOT: deploy/k8s/helm | |||
jobs: | |||
deploy-to-k8s: | |||
#if: ${{ github.event_name == 'workflow_dispatch' || github.event_name == 'repository_dispatch' || github.event.workflow_run.conclusion == 'success' }} | |||
if: false | |||
runs-on: ubuntu-latest | |||
steps: | |||
- uses: actions/checkout@v2 | |||
- uses: azure/login@v1 | |||
with: | |||
creds: ${{ secrets.AZURE_CREDENTIALS }} | |||
- uses: azure/aks-set-context@v1 | |||
name: Set AKS context | |||
with: | |||
creds: '${{ secrets.AZURE_CREDENTIALS }}' | |||
cluster-name: ${{ secrets.CLUSTER_NAME }} | |||
resource-group: ${{ secrets.RESOURCE_GROUP }} | |||
- name: Set branch name as env variable | |||
run: | | |||
currentbranch=$(echo ${GITHUB_REF##*/}) | |||
echo "running on $currentbranch" | |||
echo "BRANCH=$currentbranch" >> $GITHUB_ENV | |||
shell: bash | |||
- name: Deploy Chart | |||
run: | | |||
./deploy-chart.sh -c ${{ env.CHART }} --dns aks --aks-name ${{ secrets.CLUSTER_NAME }} --aks-rg ${{ secrets.RESOURCE_GROUP }} -r ${{ secrets.REGISTRY_HOST }} -t $TAG --namespace ${{ env.NAMESPACE }} --acr-connected | |||
env: | |||
TAG: ${{ env.BRANCH }} | |||
working-directory: ${{ env.CHART_ROOT }} |
@ -0,0 +1,199 @@ | |||
#!/usr/bin/env bash | |||
# http://redsymbol.net/articles/unofficial-bash-strict-mode | |||
set -euo pipefail | |||
usage() | |||
{ | |||
cat <<END | |||
deploy.sh: deploys the $app_name application to a Kubernetes cluster using Helm. | |||
Parameters: | |||
--aks-name <AKS cluster name> | |||
The name of the AKS cluster. Required when the registry (using the -r parameter) is set to "aks". | |||
--aks-rg <AKS resource group> | |||
The resource group for the AKS cluster. Required when the registry (using the -r parameter) is set to "aks". | |||
-c | --chart <name of chart> | |||
The name of the chart to upgrade (or install) | |||
-d | --dns <dns or ip address> | --dns aks | |||
Specifies the external DNS/ IP address of the Kubernetes cluster. | |||
If 'aks' is set as value, the DNS value is retrieved from the AKS. --aks-name and --aks-rg are needed. | |||
When --use-local-k8s is specified the external DNS is automatically set to localhost. | |||
-h | --help | |||
Displays this help text and exits the script. | |||
-n | --app-name <the name of the app> | |||
Specifies the name of the application (default: eshop). | |||
--namespace <namespace name> | |||
Specifies the namespace name to deploy the app. If it doesn't exists it will be created (default: eshop). | |||
-p | --docker-password <docker password> | |||
The Docker password used to logon to the custom registry, supplied using the -r parameter. | |||
-r | --registry <container registry> | |||
Specifies the container registry to use (required), e.g. myregistry.azurecr.io. | |||
--skip-clean | |||
Do not clean the Kubernetes helm chart. Default is to clean the chart. | |||
-t | --tag <docker image tag> | |||
The tag used for the newly created docker images. Default: latest. | |||
-u | --docker-username <docker username> | |||
The Docker username used to logon to the custom registry, supplied using the -r parameter. | |||
--use-local-k8s | |||
Deploy to a locally installed Kubernetes (default: false). | |||
It is assumed that the Kubernetes cluster has been granted access to the container registry. | |||
If using AKS and ACR see link for more info: | |||
https://docs.microsoft.com/en-us/azure/container-registry/container-registry-auth-aks | |||
WARNING! THE SCRIPT WILL COMPLETELY DESTROY ALL DEPLOYMENTS AND SERVICES VISIBLE | |||
FROM THE CURRENT CONFIGURATION CONTEXT AND NAMESPACE. | |||
It is recommended that you check your selected namespace, 'eshop' by default, is already in use. | |||
Every deployment and service done in the namespace will be deleted. | |||
For more information see https://kubernetes.io/docs/tasks/administer-cluster/namespaces/ | |||
END | |||
} | |||
acr_connected='' | |||
app_name='eshop' | |||
aks_name='' | |||
aks_rg='' | |||
chart='' | |||
clean='yes' | |||
container_registry='' | |||
docker_password='' | |||
docker_username='' | |||
dns='' | |||
image_tag='latest' | |||
skip_infrastructure='' | |||
use_local_k8s='' | |||
namespace='eshop' | |||
while [[ $# -gt 0 ]]; do | |||
case "$1" in | |||
--acr-connected ) | |||
acr_connected='yes'; shift ;; | |||
--aks-name ) | |||
aks_name="$2"; shift 2;; | |||
--aks-rg ) | |||
aks_rg="$2"; shift 2;; | |||
-c | --chart ) | |||
chart="$2"; shift 2;; | |||
-d | --dns ) | |||
dns="$2"; shift 2;; | |||
-h | --help ) | |||
usage; exit 1 ;; | |||
-n | --app-name ) | |||
app_name="$2"; shift 2;; | |||
-p | --docker-password ) | |||
docker_password="$2"; shift 2;; | |||
-r | --registry ) | |||
container_registry="$2"; shift 2;; | |||
--skip-clean ) | |||
clean=''; shift ;; | |||
--image-build ) | |||
build_images='yes'; shift ;; | |||
--image-push ) | |||
push_images='yes'; shift ;; | |||
--skip-infrastructure ) | |||
skip_infrastructure='yes'; shift ;; | |||
-t | --tag ) | |||
image_tag="$2"; shift 2;; | |||
-u | --docker-username ) | |||
docker_username="$2"; shift 2;; | |||
--use-local-k8s ) | |||
use_local_k8s='yes'; shift ;; | |||
--namespace ) | |||
namespace="$2"; shift 2;; | |||
*) | |||
echo "Unknown option $1" | |||
usage; exit 2 ;; | |||
esac | |||
done | |||
export TAG=$image_tag | |||
use_custom_registry='' | |||
if [[ -n $container_registry ]] && [[ -z $acr_connected ]]; then | |||
echo "################ Log into custom registry $container_registry ##################" | |||
use_custom_registry='yes' | |||
if [[ -z $docker_username ]] || [[ -z $docker_password ]]; then | |||
echo "Error: Must use -u (--docker-username) AND -p (--docker-password) if specifying custom registry" | |||
exit 1 | |||
fi | |||
docker login -u $docker_username -p $docker_password $container_registry | |||
fi | |||
ingress_values_file="ingress_values.yaml" | |||
if [[ $use_local_k8s ]]; then | |||
ingress_values_file="ingress_values_dockerk8s.yaml" | |||
dns="localhost" | |||
fi | |||
if [[ $dns == "aks" ]]; then | |||
echo "#################### Begin AKS discovery based on the --dns aks setting. ####################" | |||
if [[ -z $aks_name ]] || [[ -z $aks_rg ]]; then | |||
echo "Error: When using -dns aks, MUST set -aksName and -aksRg too." | |||
echo '' | |||
usage | |||
exit 1 | |||
fi | |||
echo "Getting AKS cluster $aks_name AKS (in resource group $aks_rg)" | |||
# JMESPath queries are case sensitive and httpapplicationrouting can be lowercase sometimes | |||
jmespath_dnsqueries=(\ | |||
addonProfiles.httpApplicationRouting.config.HTTPApplicationRoutingZoneName \ | |||
addonProfiles.httpapplicationrouting.config.HTTPApplicationRoutingZoneName \ | |||
) | |||
for q in "${jmespath_dnsqueries[@]}" | |||
do | |||
dns="$(az aks show -n $aks_name -g $aks_rg --query $q -o tsv)" | |||
if [[ -n $dns ]]; then break; fi | |||
done | |||
if [[ -z $dns ]]; then | |||
echo "Error: when getting DNS of AKS $aks_name (in resource group $aks_rg). Please ensure AKS has httpRouting enabled AND Azure CLI is logged in and is of version 2.0.37 or higher." | |||
exit 1 | |||
fi | |||
echo "DNS base found is $dns. Will use $aks_name.$dns for the app!" | |||
dns="$aks_name.$dns" | |||
fi | |||
# Initialization & check commands | |||
if [[ -z $dns ]]; then | |||
echo "No DNS specified. Ingress resources will be bound to public IP." | |||
fi | |||
previous_install='' | |||
if [[ -z $(helm ls -q --namespace $namespace | grep "$app_name-$chart") ]]; then | |||
echo "No previous release found" | |||
else | |||
previous_install='yes' | |||
fi | |||
if [[ $clean ]] && [[ $previous_install ]]; then | |||
echo "Cleaning previous helm releases..." | |||
helm uninstall "$app_name-$chart" --namespace $namespace | |||
echo "Previous release deleted" | |||
waitsecs=5; while [ $waitsecs -gt 0 ]; do echo -ne "$waitsecs\033[0K\r"; sleep 1; : $((waitsecs--)); done | |||
previous_install='' | |||
fi | |||
echo "#################### Begin $app_name $chart installation using Helm ####################" | |||
if [[ $use_custom_registry ]] || [[ $acr_connected ]]; then | |||
if [[ -z $acr_connected ]]; then | |||
if [[ -z $previous_install ]]; then | |||
helm upgrade --install "$app_name-$chart" --namespace $namespace --set "ingress.hosts={$dns}" --set inf.registry.server=$container_registry --set inf.registry.login=$docker_username --set inf.registry.pwd=$docker_password --set inf.registry.secretName=eshop-docker-scret --values app.yaml --values inf.yaml --values $ingress_values_file --set app.name=$app_name --set inf.k8s.dns=$dns --set image.tag=$image_tag --set image.pullPolicy=Always $chart | |||
else | |||
helm upgrade --install "$app_name-$chart" --namespace $namespace --set "ingress.hosts={$dns}" --values app.yaml --values inf.yaml --values $ingress_values_file --set app.name=$app_name --set inf.k8s.dns=$dns --set image.tag=$image_tag --set image.pullPolicy=Always $chart | |||
fi | |||
elif [[ $chart != "eshop-common" ]]; then | |||
# ACR is already connected, so we don't need username/password | |||
if [[ -z $previous_install ]]; then | |||
helm install "$app_name-$chart" --namespace $namespace --set "ingress.hosts={$dns}" --set inf.registry.server=$container_registry --values app.yaml --values inf.yaml --values $ingress_values_file --set app.name=$app_name --set inf.k8s.dns=$dns --set image.tag=$image_tag --set image.pullPolicy=Always $chart | |||
else | |||
# don't set the image repo since it's already set | |||
helm upgrade "$app_name-$chart" --namespace $namespace --set "ingress.hosts={$dns}" --values app.yaml --values inf.yaml --values $ingress_values_file --set app.name=$app_name --set inf.k8s.dns=$dns --set image.tag=$image_tag --set image.pullPolicy=Always $chart | |||
fi | |||
fi | |||
elif [[ $chart != "eshop-common" ]]; then # eshop-common is ignored when no secret must be deployed | |||
helm upgrade --install "$app_name-$chart" --namespace $namespace --set "ingress.hosts={$dns}" --values app.yaml --values inf.yaml --values $ingress_values_file --set app.name=$app_name --set inf.k8s.dns=$dns --set image.tag=$image_tag --set image.pullPolicy=Always $chart | |||
fi | |||
echo "FINISHED: Helm chart installed." |
@ -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/ |
@ -0,0 +1,5 @@ | |||
apiVersion: v1 | |||
appVersion: "1.0" | |||
description: A Helm chart for Kubernetes | |||
name: zipkin | |||
version: 0.1.0 |
@ -0,0 +1,2 @@ | |||
eShop trace tool Zipkin installed. | |||
----------------------- |
@ -0,0 +1,32 @@ | |||
{{/* vim: set filetype=mustache: */}} | |||
{{/* | |||
Expand the name of the chart. | |||
*/}} | |||
{{- define "zipkin.name" -}} | |||
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} | |||
{{- end }} | |||
{{/* | |||
Create a default fully qualified app name. | |||
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). | |||
If release name contains chart name it will be used as a full name. | |||
*/}} | |||
{{- define "zipkin.fullname" -}} | |||
{{- if .Values.fullnameOverride }} | |||
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} | |||
{{- else }} | |||
{{- $name := default .Chart.Name .Values.nameOverride }} | |||
{{- if contains $name .Release.Name }} | |||
{{- .Release.Name | trunc 63 | trimSuffix "-" }} | |||
{{- else }} | |||
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} | |||
{{- end }} | |||
{{- end }} | |||
{{- end }} | |||
{{/* | |||
Create chart name and version as used by the chart label. | |||
*/}} | |||
{{- define "zipkin.chart" -}} | |||
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} | |||
{{- end }} |
@ -0,0 +1,60 @@ | |||
{{- define "suffix-name" -}} | |||
{{- if .Values.app.name -}} | |||
{{- .Values.app.name -}} | |||
{{- else -}} | |||
{{- .Release.Name -}} | |||
{{- end -}} | |||
{{- end -}} | |||
{{- define "sql-name" -}} | |||
{{- if .Values.inf.sql.host -}} | |||
{{- .Values.inf.sql.host -}} | |||
{{- else -}} | |||
{{- printf "%s" "sql-data" -}} | |||
{{- end -}} | |||
{{- end -}} | |||
{{- define "mongo-name" -}} | |||
{{- if .Values.inf.mongo.host -}} | |||
{{- .Values.inf.mongo.host -}} | |||
{{- else -}} | |||
{{- printf "%s" "nosql-data" -}} | |||
{{- end -}} | |||
{{- end -}} | |||
{{- define "url-of" -}} | |||
{{- $name := first .}} | |||
{{- $ctx := last .}} | |||
{{- if eq $name "" -}} | |||
{{- $ctx.Values.inf.k8s.dns -}} | |||
{{- else -}} | |||
{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} {{/*Value is just <dns>/<name> */}} | |||
{{- end -}} | |||
{{- end -}} | |||
{{- define "pathBase" -}} | |||
{{- if .Values.inf.k8s.suffix -}} | |||
{{- $suffix := include "suffix-name" . -}} | |||
{{- printf "%s-%s" .Values.pathBase $suffix -}} | |||
{{- else -}} | |||
{{- .Values.pathBase -}} | |||
{{- end -}} | |||
{{- end -}} | |||
{{- define "fqdn-image" -}} | |||
{{- if .Values.inf.registry -}} | |||
{{- printf "%s/%s" .Values.inf.registry.server .Values.image.repository -}} | |||
{{- else -}} | |||
{{- .Values.image.repository -}} | |||
{{- end -}} | |||
{{- end -}} | |||
{{- define "protocol" -}} | |||
{{- if .Values.inf.tls.enabled -}} | |||
{{- printf "%s" "https" -}} | |||
{{- else -}} | |||
{{- printf "%s" "http" -}} | |||
{{- end -}} | |||
{{- end -}} |
@ -0,0 +1,63 @@ | |||
apiVersion: apps/v1 | |||
kind: Deployment | |||
metadata: | |||
name: {{ include "zipkin.fullname" . }} | |||
labels: | |||
app: {{ template "zipkin.name" . }} | |||
chart: {{ template "zipkin.chart" . }} | |||
release: {{ .Release.Name }} | |||
heritage: {{ .Release.Service }} | |||
spec: | |||
replicas: {{ .Values.replicaCount }} | |||
selector: | |||
matchLabels: | |||
app: {{ template "zipkin.name" . }} | |||
release: {{ .Release.Name }} | |||
template: | |||
metadata: | |||
{{- with .Values.podAnnotations }} | |||
annotations: | |||
{{- toYaml . | nindent 8 }} | |||
{{- end }} | |||
labels: | |||
app: {{ template "zipkin.name" . }} | |||
release: {{ .Release.Name }} | |||
{{ if .Values.inf.mesh.enabled -}} | |||
annotations: | |||
linkerd.io/inject: enabled | |||
{{- end }} | |||
spec: | |||
{{- with .Values.imagePullSecrets }} | |||
imagePullSecrets: | |||
{{- toYaml . | nindent 8 }} | |||
{{- end }} | |||
containers: | |||
- name: {{ .Chart.Name }} | |||
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" | |||
imagePullPolicy: {{ .Values.image.pullPolicy }} | |||
ports: | |||
- name: http | |||
containerPort: 9411 | |||
protocol: TCP | |||
livenessProbe: | |||
httpGet: | |||
path: / | |||
port: http | |||
readinessProbe: | |||
httpGet: | |||
path: / | |||
port: http | |||
resources: | |||
{{- toYaml .Values.resources | nindent 12 }} | |||
{{- with .Values.nodeSelector }} | |||
nodeSelector: | |||
{{- toYaml . | nindent 8 }} | |||
{{- end }} | |||
{{- with .Values.affinity }} | |||
affinity: | |||
{{- toYaml . | nindent 8 }} | |||
{{- end }} | |||
{{- with .Values.tolerations }} | |||
tolerations: | |||
{{- toYaml . | nindent 8 }} | |||
{{- end }} |
@ -0,0 +1,33 @@ | |||
{{- if .Values.ingress.enabled -}} | |||
{{- if .Values.inf.k8s.local -}} | |||
{{- $ingressPath := include "pathBase" . -}} | |||
{{- $serviceName := .Values.app.svc.zipkin }} | |||
{{- $name := include "zipkin.fullname" . -}} | |||
apiVersion: networking.k8s.io/v1beta1 | |||
kind: Ingress | |||
metadata: | |||
name: {{ $name }}-local | |||
labels: | |||
app: {{ template "zipkin.name" . }} | |||
chart: {{ template "zipkin.chart" . }} | |||
release: {{ .Release.Name }} | |||
heritage: {{ .Release.Service }} | |||
{{- with .Values.ingress.annotations }} | |||
annotations: | |||
{{ toYaml . | indent 4 }} | |||
{{- end }} | |||
{{- if .Values.inf.mesh.enabled }} | |||
{{- with .Values.ingress.mesh.annotations }} | |||
{{ toYaml . | indent 4 }} | |||
{{- end }} | |||
{{- end }} | |||
spec: | |||
rules: | |||
- http: | |||
paths: | |||
- backend: | |||
serviceName: {{ $serviceName }} | |||
servicePort: http | |||
path: {{ $ingressPath }} | |||
{{- end -}} | |||
{{- end -}} |
@ -0,0 +1,39 @@ | |||
{{- if .Values.ingress.enabled -}} | |||
{{- $ingressPath := include "pathBase" . -}} | |||
{{- $serviceName := include "zipkin.fullname" . -}} | |||
{{- $svcPort := .Values.service.port -}} | |||
apiVersion: networking.k8s.io/v1beta1 | |||
kind: Ingress | |||
metadata: | |||
name: {{ template "zipkin.fullname" . }} | |||
labels: | |||
app: {{ template "zipkin.name" . }} | |||
chart: {{ template "zipkin.chart" . }} | |||
release: {{ .Release.Name }} | |||
heritage: {{ .Release.Service }} | |||
{{- with .Values.ingress.annotations }} | |||
annotations: | |||
{{- toYaml . | nindent 4 }} | |||
{{- end }} | |||
spec: | |||
{{- if .Values.ingress.tls }} | |||
tls: | |||
{{- range .Values.ingress.tls }} | |||
- hosts: | |||
{{- range .hosts }} | |||
- {{ . }} | |||
{{- end }} | |||
secretName: {{ .secretName }} | |||
{{- end }} | |||
{{- end }} | |||
rules: | |||
{{- range .Values.ingress.hosts }} | |||
- host: {{ . }} | |||
http: | |||
paths: | |||
- path: {{ $ingressPath }} | |||
backend: | |||
serviceName: {{ $.Values.app.svc.zipkin }} | |||
servicePort: http | |||
{{- end }} | |||
{{- end }} |
@ -0,0 +1,19 @@ | |||
apiVersion: v1 | |||
kind: Service | |||
metadata: | |||
name: {{ .Values.app.svc.zipkin }} | |||
labels: | |||
app: {{ template "zipkin.name" . }} | |||
chart: {{ template "zipkin.chart" . }} | |||
release: {{ .Release.Name }} | |||
heritage: {{ .Release.Service }} | |||
spec: | |||
type: {{ .Values.service.type }} | |||
ports: | |||
- port: {{ .Values.service.port }} | |||
targetPort: http | |||
protocol: TCP | |||
name: http | |||
selector: | |||
app: {{ template "zipkin.name" . }} | |||
release: {{ .Release.Name }} |
@ -0,0 +1,26 @@ | |||
replicaCount: 1 | |||
clusterName: eshop-aks | |||
pathBase: /zipkin | |||
image: | |||
repository: openzipkin/zipkin | |||
tag: latest | |||
pullPolicy: IfNotPresent | |||
service: | |||
type: ClusterIP | |||
port: 9411 | |||
ingress: | |||
enabled: true | |||
annotations: {} | |||
tls: [] | |||
resources: {} | |||
nodeSelector: {} | |||
tolerations: [] | |||
affinity: {} |
@ -0,0 +1,120 @@ | |||
using Microsoft.Extensions.DependencyInjection; | |||
using OpenTelemetry; | |||
using OpenTelemetry.Resources; | |||
using OpenTelemetry.Trace; | |||
using StackExchange.Redis; | |||
using System; | |||
namespace OpenTelemetry.Customization.Extensions | |||
{ | |||
public static class OpenTelemetryExtensions | |||
{ | |||
public static IServiceCollection AddOpenTelemetry(this IServiceCollection services, OpenTelemetryConfig openTelemetryConfig) | |||
{ | |||
if (openTelemetryConfig == null || openTelemetryConfig.ExportType == null) | |||
{ | |||
return services; | |||
} | |||
return services.AddOpenTelemetryTracing((serviceProvider, tracerProviderBuilder) => | |||
{ | |||
// Configure resource | |||
tracerProviderBuilder | |||
.SetResourceBuilder(ResourceBuilder.CreateDefault().AddService(openTelemetryConfig.ServiceName)); | |||
// Configure instrumentation | |||
tracerProviderBuilder | |||
.AddAspNetCoreInstrumentation() | |||
.AddHttpClientInstrumentation() | |||
.AddGrpcClientInstrumentation() | |||
.AddSqlClientInstrumentation(); | |||
// Configure exporter | |||
switch (openTelemetryConfig.ExportType) | |||
{ | |||
case "jaeger": | |||
tracerProviderBuilder.AddJaegerExporter(options => | |||
{ | |||
options.AgentHost = openTelemetryConfig.ExportToolEndpoint; | |||
}); | |||
break; | |||
case "otlp": | |||
tracerProviderBuilder.AddOtlpExporter(options => | |||
{ | |||
options.Endpoint = new Uri(openTelemetryConfig.ExportToolEndpoint); | |||
var headers = Environment.GetEnvironmentVariable("OTEL_EXPORTER_OTLP_TRACES_HEADERS") | |||
?? Environment.GetEnvironmentVariable("OTEL_EXPORTER_OTLP_HEADERS"); | |||
options.Headers = headers; | |||
}); | |||
break; | |||
case "zipkin": | |||
tracerProviderBuilder.AddZipkinExporter(options => | |||
{ | |||
options.Endpoint = new Uri(openTelemetryConfig.ExportToolEndpoint); | |||
}); | |||
break; | |||
default: | |||
tracerProviderBuilder.AddConsoleExporter(); | |||
break; | |||
} | |||
}); | |||
} | |||
public static IServiceCollection AddOpenTelemetry(this IServiceCollection services, ConnectionMultiplexer connectionMultiplexer, OpenTelemetryConfig openTelemetryConfig) | |||
{ | |||
if (openTelemetryConfig == null || openTelemetryConfig.ExportType == null) | |||
{ | |||
return services; | |||
} | |||
return services.AddOpenTelemetryTracing((serviceProvider, tracerProviderBuilder) => | |||
{ | |||
// Configure resource | |||
tracerProviderBuilder | |||
.SetResourceBuilder(ResourceBuilder.CreateDefault().AddService(openTelemetryConfig.ServiceName)); | |||
// Configure instrumentation | |||
tracerProviderBuilder | |||
.AddAspNetCoreInstrumentation() | |||
.AddHttpClientInstrumentation() | |||
.AddGrpcClientInstrumentation() | |||
.AddRedisInstrumentation(connectionMultiplexer); | |||
// Configure exporter | |||
switch (openTelemetryConfig.ExportType) | |||
{ | |||
case "jaeger": | |||
tracerProviderBuilder.AddJaegerExporter(options => | |||
{ | |||
options.AgentHost = openTelemetryConfig.ExportToolEndpoint; | |||
}); | |||
break; | |||
case "otlp": | |||
tracerProviderBuilder.AddOtlpExporter(options => | |||
{ | |||
options.Endpoint = new Uri(openTelemetryConfig.ExportToolEndpoint); | |||
var headers = Environment.GetEnvironmentVariable("OTEL_EXPORTER_OTLP_TRACES_HEADERS") | |||
?? Environment.GetEnvironmentVariable("OTEL_EXPORTER_OTLP_HEADERS"); | |||
options.Headers = headers; | |||
}); | |||
break; | |||
case "zipkin": | |||
tracerProviderBuilder.AddZipkinExporter(options => | |||
{ | |||
options.Endpoint = new Uri(openTelemetryConfig.ExportToolEndpoint); | |||
}); | |||
break; | |||
default: | |||
tracerProviderBuilder.AddConsoleExporter(); | |||
break; | |||
} | |||
}); | |||
} | |||
} | |||
} |
@ -0,0 +1,22 @@ | |||
<Project Sdk="Microsoft.NET.Sdk"> | |||
<PropertyGroup> | |||
<TargetFramework>net5.0</TargetFramework> | |||
</PropertyGroup> | |||
<ItemGroup> | |||
<PackageReference Include="StackExchange.Redis" Version="2.2.4" /> | |||
<PackageReference Include="OpenTelemetry" Version="1.0.1" /> | |||
<PackageReference Include="OpenTelemetry.Exporter.Console" Version="1.0.1" /> | |||
<PackageReference Include="OpenTelemetry.Exporter.Jaeger" Version="1.0.1" /> | |||
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.0.1" /> | |||
<PackageReference Include="OpenTelemetry.Exporter.Zipkin" Version="1.0.1" /> | |||
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.0.0-rc2" /> | |||
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.0.0-rc2" /> | |||
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.0.0-rc2" /> | |||
<PackageReference Include="OpenTelemetry.Instrumentation.GrpcNetClient" Version="1.0.0-rc2" /> | |||
<PackageReference Include="OpenTelemetry.Instrumentation.SqlClient" Version="1.0.0-rc2" /> | |||
<PackageReference Include="OpenTelemetry.Instrumentation.StackExchangeRedis" Version="1.0.0-rc2" /> | |||
</ItemGroup> | |||
</Project> |
@ -0,0 +1,18 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace OpenTelemetry.Customization | |||
{ | |||
public class OpenTelemetryConfig | |||
{ | |||
public string ServiceName { get; set; } | |||
public string ExportType { get; set; } | |||
public string ExportToolEndpoint { get; set; } | |||
} | |||
} |
@ -1,66 +0,0 @@ | |||
using Microsoft.Extensions.DependencyInjection; | |||
using OpenTelemetry; | |||
using OpenTelemetry.Resources; | |||
using OpenTelemetry.Trace; | |||
using StackExchange.Redis; | |||
using System; | |||
static class OpenTelemetryExtensions | |||
{ | |||
public static void AddOpenTelemetry(ConnectionMultiplexer connectionMultiplexer) | |||
{ | |||
var exportType = Environment.GetEnvironmentVariable("OTEL_USE_EXPORTER")?.ToLower(); | |||
if (exportType == null) | |||
{ | |||
return; | |||
} | |||
var tracerProviderBuilder = Sdk.CreateTracerProviderBuilder(); | |||
// Configure resource | |||
tracerProviderBuilder | |||
.SetResourceBuilder(ResourceBuilder.CreateDefault().AddService("Basket.API")); | |||
// Configure instrumentation | |||
tracerProviderBuilder | |||
.AddAspNetCoreInstrumentation() | |||
.AddHttpClientInstrumentation() | |||
.AddRedisInstrumentation(connectionMultiplexer); | |||
// Configure exporter | |||
switch (exportType) | |||
{ | |||
case "jaeger": | |||
tracerProviderBuilder.AddJaegerExporter(options => | |||
{ | |||
var agentHost = Environment.GetEnvironmentVariable("OTEL_EXPORTER_JAEGER_AGENTHOST"); | |||
options.AgentHost = agentHost; | |||
}); | |||
break; | |||
case "otlp": | |||
tracerProviderBuilder.AddOtlpExporter(options => | |||
{ | |||
var endpoint = Environment.GetEnvironmentVariable("OTEL_EXPORTER_OTLP_TRACES_ENDPOINT") | |||
?? Environment.GetEnvironmentVariable("OTEL_EXPORTER_OTLP_ENDPOINT"); | |||
options.Endpoint = new Uri(endpoint); | |||
var headers = Environment.GetEnvironmentVariable("OTEL_EXPORTER_OTLP_TRACES_HEADERS") | |||
?? Environment.GetEnvironmentVariable("OTEL_EXPORTER_OTLP_HEADERS"); | |||
options.Headers = headers; | |||
}); | |||
break; | |||
case "zipkin": | |||
tracerProviderBuilder.AddZipkinExporter(options => | |||
{ | |||
var endpoint = Environment.GetEnvironmentVariable("OTEL_EXPORTER_ZIPKIN_ENDPOINT"); | |||
options.Endpoint = new Uri(endpoint); | |||
}); | |||
break; | |||
default: | |||
tracerProviderBuilder.AddConsoleExporter(); | |||
break; | |||
} | |||
tracerProviderBuilder.Build(); | |||
} | |||
} |