From 6071ae142e4776a9600d96c6005a023b256e2794 Mon Sep 17 00:00:00 2001 From: Andreas Salhus Bakseter <141913422+baksetercx@users.noreply.github.com> Date: Tue, 21 Jan 2025 10:41:58 +0100 Subject: [PATCH] Migrate from AZDO to GitHub Actions --- .../deploy/values-demo-api-progressive.yml | 0 .../deploy/values-demo-api-stable.yml | 0 .github/workflows/chart-testing.yml | 69 +++++++++++++++ .github/workflows/deploy-demo-api.yml | 38 +++++++++ CI/demo-api-azure-pipeline.yaml | 48 ----------- CI/templates/deploy.yaml | 43 ---------- azure-pipeline.yaml | 83 ------------------- 7 files changed, 107 insertions(+), 174 deletions(-) rename CI/demo-api-values-progressive.yaml => .github/deploy/values-demo-api-progressive.yml (100%) rename CI/demo-api-values-stable.yaml => .github/deploy/values-demo-api-stable.yml (100%) create mode 100644 .github/workflows/chart-testing.yml create mode 100644 .github/workflows/deploy-demo-api.yml delete mode 100644 CI/demo-api-azure-pipeline.yaml delete mode 100644 CI/templates/deploy.yaml delete mode 100644 azure-pipeline.yaml diff --git a/CI/demo-api-values-progressive.yaml b/.github/deploy/values-demo-api-progressive.yml similarity index 100% rename from CI/demo-api-values-progressive.yaml rename to .github/deploy/values-demo-api-progressive.yml diff --git a/CI/demo-api-values-stable.yaml b/.github/deploy/values-demo-api-stable.yml similarity index 100% rename from CI/demo-api-values-stable.yaml rename to .github/deploy/values-demo-api-stable.yml diff --git a/.github/workflows/chart-testing.yml b/.github/workflows/chart-testing.yml new file mode 100644 index 0000000..0591a1b --- /dev/null +++ b/.github/workflows/chart-testing.yml @@ -0,0 +1,69 @@ +name: Chart testing + +on: + push: + branches: [master] + pull_request: + branches: [master] + +jobs: + chart-testing: + name: Chart testing + runs-on: elvia-runner + steps: + - name: Install Kubernetes cluster + run: | + curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.23.0/kind-linux-amd64 + chmod +x ./kind + sudo mv kind /usr/local/bin + sudo service docker restart + kind create cluster --wait 5m + + - name: Install kube-prometheus-stack with Helm + run: | + helm repo add prometheus-community https://prometheus-community.github.io/helm-charts + helm repo update + helm install prometheus prometheus-community/kube-prometheus-stack + + - name: Get events + if: failure() + run: kubectl get events + + - name: Install Traefik + run: | + helm repo add traefik https://helm.traefik.io/traefik + helm install --version '26.*' traefik traefik/traefik + + - name: Create namespace core + run: kubectl create namespace core + + - name: Create service accounts + run: | + kubectl -n core create sa pushreceiver-chart-testing + kubectl -n core create sa webapi-chart-testing + kubectl -n core create sa worker-chart-testing + + - name: Test kubectl + run: | + kubectl get namespace + kubectl get servicemonitor --all-namespaces + + - name: Install yamllint + run: | + sudo apt-get update + sudo apt-get install yamllint -y + + - name: Install yamale + run: pipx install yamale + + - name: Configure ct config + run: | + mkdir $HOME/.ct + mv ct/etc/* $HOME/.ct/ + chmod +x ct/bin/ct + + - name: Run ct lint + run: ./ct/bin/ct lint --config ct.yaml + + - name: Run ct install --upgrade + run: ./ct/bin/ct install --upgrade --config ct.yaml diff --git a/.github/workflows/deploy-demo-api.yml b/.github/workflows/deploy-demo-api.yml new file mode 100644 index 0000000..6bf7381 --- /dev/null +++ b/.github/workflows/deploy-demo-api.yml @@ -0,0 +1,38 @@ +name: Deploy demo-api + +on: + pull_request: + branches: [master] + push: + branches: [master] + +env: + APPLICATION_NAME: 'demo-api' + SYSTEM_NAME: 'core' + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + deploy-dev: + name: Deploy Dev + runs-on: elvia-runner + strategy: + matrix: + helm-values-file: + - '.github/deploy/values-demo-api-stable.yml' + - '.github/deploy/values-demo-api-progressive.yml' + permissions: + contents: read + id-token: write + environment: dev + steps: + - uses: 3lvia/core-github-actions-templates/deploy@trunk + with: + name: ${{ env.APPLICATION_NAME }} + namespace: ${{ env.SYSTEM_NAME }} + environment: 'dev' + AZURE_CLIENT_ID: ${{ vars.AKS_CLIENT_ID }} + helm-values-file: ${{ matrix.helm-values-file }} + helm-chart-repository-url: 'https://raw.githubusercontent.com/${{ github.repository }}/refs/heads/${{ github.ref_name }}' diff --git a/CI/demo-api-azure-pipeline.yaml b/CI/demo-api-azure-pipeline.yaml deleted file mode 100644 index f7934f6..0000000 --- a/CI/demo-api-azure-pipeline.yaml +++ /dev/null @@ -1,48 +0,0 @@ -trigger: - - master - -pool: - vmImage: "ubuntu-latest" - -variables: - containerregistry: 'ContainerRegistryElvia' - namespace: core - -resources: - repositories: - - repository: templates - type: github - name: 3lvia/core-azure-devops-templates - endpoint: 3lvia - -stages: -- stage: Build - jobs: - - job: Build - steps: - - task: PublishBuildArtifacts@1 - displayName: "Publish kubernetes configuration artifacts" - inputs: - PathtoPublish: CI - ArtifactName: CI - - task: PublishBuildArtifacts@1 - displayName: "Publish helm chart" - inputs: - PathtoPublish: elvia-deployment - ArtifactName: elvia-deployment - -- stage: DeployStable - dependsOn: Build - jobs: - - template: templates/deploy.yaml - parameters: - name: demo-api - helmValuesFile: demo-api-values-stable.yaml - -- stage: DeployProgressive - dependsOn: DeployStable - jobs: - - template: templates/deploy.yaml - parameters: - name: demo-api - helmValuesFile: demo-api-values-progressive.yaml diff --git a/CI/templates/deploy.yaml b/CI/templates/deploy.yaml deleted file mode 100644 index 4b945a1..0000000 --- a/CI/templates/deploy.yaml +++ /dev/null @@ -1,43 +0,0 @@ ---- -parameters: - - name: helmValuesFile - - name: name - -jobs: - - deployment: name - displayName: ${{ parameters.name }} - environment: dev - strategy: - runOnce: - deploy: - steps: - - task: HelmDeploy@0 - displayName: Helm deploy - inputs: - connectionType: Kubernetes Service Connection - kubernetesServiceEndpoint: RuntimeServiceKubernetesDev - namespace: $(namespace) - command: upgrade - failOnStderr: false - arguments: --debug - chartName: $(Pipeline.Workspace)/elvia-deployment/ - releaseName: ${{ parameters.name }} - valueFile: $(Pipeline.Workspace)/CI/${{ parameters.helmValuesFile }} - - - task: Kubernetes@1 - displayName: kubectl rollout status deploy ${{ parameters.name }} - inputs: - kubernetesServiceEndpoint: RuntimeServiceKubernetesDev - namespace: $(namespace) - command: rollout - arguments: status deploy ${{ parameters.name }} - - - task: HelmDeploy@0 - displayName: Helm rollback - inputs: - connectionType: Kubernetes Service Connection - kubernetesServiceEndpoint: RuntimeServiceKubernetesDev - namespace: $(namespace) - command: rollback - failOnStderr: false - arguments: ${{ parameters.name }} diff --git a/azure-pipeline.yaml b/azure-pipeline.yaml deleted file mode 100644 index 6a8793e..0000000 --- a/azure-pipeline.yaml +++ /dev/null @@ -1,83 +0,0 @@ -trigger: - - master - -pr: - autoCancel: 'true' - branches: - include: - - master - -pool: - vmImage: "ubuntu-20.04" - -stages: -- stage: ChartTesting - jobs: - - job: RunChartTesting - steps: - - script: | - curl https://baltocdn.com/helm/signing.asc | sudo apt-key add - - sudo apt-get install apt-transport-https --yes - echo "deb https://baltocdn.com/helm/stable/debian/ all main" | sudo tee /etc/apt/sources.list.d/helm-stable-debian.list - sudo apt-get update - sudo apt-get install helm - displayName: Install helm 3 - - script: | - curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.23.0/kind-linux-amd64 - chmod +x ./kind - sudo mv kind /usr/local/bin - sudo service docker restart - kind create cluster --wait 5m - displayName: Install kubernetes cluster - - script: | - helm repo add prometheus-community https://prometheus-community.github.io/helm-charts - helm repo update - helm install prometheus prometheus-community/kube-prometheus-stack - displayName: Helm Install kube-prometheus-stack - - script: | - kubectl get events --sort-by='{.lastTimestamp}' - displayName: kubectl get events - condition: failed() - - script: | - helm repo add traefik https://helm.traefik.io/traefik - helm install --version '26.*' traefik traefik/traefik - displayName: Install Traefik - - script: | - kubectl create namespace core - displayName: Create namespace core - - script: | - kubectl -n core create sa pushreceiver-chart-testing - kubectl -n core create sa webapi-chart-testing - kubectl -n core create sa worker-chart-testing - displayName: Create service accounts - - script: | - kubectl get namespace - kubectl get servicemonitor --all-namespaces - displayName: Test kubectl - - script: sudo apt-get install yamllint - displayName: Install yamllint - - script: | - sudo apt-get update - sudo pip3 install setuptools - sudo pip3 install yamale - displayName: Install yamale - - - script: | - mkdir $HOME/.ct - mv ct/etc/* $HOME/.ct/ - chmod +x ct/bin/ct - displayName: Configure ct config - workingDirectory: $(Build.SourcesDirectory) - - - script: ./ct/bin/ct lint --config ct.yaml - displayName: Run ct lint - workingDirectory: $(Build.SourcesDirectory) - - script: ./ct/bin/ct install --upgrade --config ct.yaml - displayName: Run ct install --upgrade - workingDirectory: $(Build.SourcesDirectory) - - - - - -