[모니터링] 배포 자동화 (#423) #1
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
name: monitoring-cd | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- infra/helm/monitoring/** | |
workflow_dispatch: # for manual trigger | |
permissions: | |
id-token: write | |
jobs: | |
cd: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Notify CD start to slack | |
run: | | |
curl -X POST -H 'Content-type: application/json' --data "{\"attachments\":[{\"color\":\"#46AE74\",\"title\":\"[Monitoring] Deploy Started\", \"text\":\"version - latest\"}]}" ${{ secrets.SLACK_URL_SCC_SERVER_CHANNEL }} -v | |
- name: Install kubeconfig | |
env: | |
SCC_K3S_KUBECONFIG: ${{ secrets.SCC_K3S_KUBECONFIG }} | |
run: | | |
mkdir -p ~/.kube && echo "$SCC_K3S_KUBECONFIG" > ~/.kube/config | |
- uses: azure/setup-helm@v1 | |
with: | |
version: '3.8.2' | |
id: install-helm | |
- uses: azure/setup-kubectl@v3 | |
with: | |
version: 'v1.24.1' | |
id: install-kubectl | |
- name: Upgrade monitoring helm chart | |
working-directory: infra/helm/monitoring | |
env: | |
MONITORING_ENDPOINT: ${{ secrets.MONITORING_ENDPOINT }} | |
MONITORING_AUTHORIZATION_HEADER: ${{ secrets.MONITORING_AUTHORIZATION_HEADER }} | |
run: | | |
helm upgrade --install monitoring ./ \ | |
--namespace monitoring \ | |
-f values.yaml \ | |
--set openobserve-collector.exporters."otlphttp/openobserve".endpoint="$MONITORING_ENDPOINT" \ | |
--set openobserve-collector.exporters."otlphttp/openobserve".headers.Authorization="$MONITORING_AUTHORIZATION_HEADER" \ | |
--set openobserve-collector.exporters."otlphttp/openobserve_k8s_events".endpoint="$MONITORING_ENDPOINT" \ | |
--set openobserve-collector.exporters."otlphttp/openobserve_k8s_events".headers.Authorization="$MONITORING_AUTHORIZATION_HEADER" | |
- name: Wait for monitoring rollout | |
run: | | |
kubectl rollout status ds/monitoring-openobserve-collector-agent-collector -n monitoring | |
- name: Notify CD failure to slack | |
if: failure() | |
run: | | |
CURRENT_GITHUB_ACTION_RUN_URL="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" | |
curl -X POST -H 'Content-type: application/json' --data "{\"attachments\":[{\"color\":\"#FF0000\",\"title\":\"[Monitoring] Deployment Failed\", \"text\":\"<!subteam^S052B9W7129> (<$CURRENT_GITHUB_ACTION_RUN_URL|github action run url>)\"}]}" ${{ secrets.SLACK_URL_SCC_SERVER_CHANNEL }} -v | |
- name: Notify CD success to slack | |
if: success() | |
run: | | |
CURRENT_GITHUB_ACTION_RUN_URL="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" | |
curl -X POST -H 'Content-type: application/json' --data "{\"attachments\":[{\"color\":\"#0000FF\",\"title\":\"[Monitoring] Deploy Success\"}]}" ${{ secrets.SLACK_URL_SCC_SERVER_CHANNEL }} -v |