Feature/prometheus power meter #519
Workflow file for this run
This file contains hidden or 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: Build and Deploy K8s on Self Hosted BM | |
| on: # yamllint disable-line rule:truthy | |
| pull_request: | |
| # default permissions as read only | |
| permissions: read-all | |
| jobs: | |
| check-changes: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| changes: ${{ steps.filter.outputs.changes }} | |
| steps: | |
| - name: checkout source | |
| uses: actions/checkout@v6 | |
| - name: filter changes | |
| uses: dorny/paths-filter@v3 | |
| id: filter | |
| with: | |
| filters: | | |
| changes: | |
| - 'cmd/**/*.go' | |
| - 'internal/**/*.go' | |
| - 'config/**/*.go' | |
| - 'go.mod' | |
| - 'go.sum' | |
| - '.github/workflows/k8s-bm.yaml' | |
| build-and-deploy: | |
| needs: [check-changes] | |
| if: needs.check-changes.outputs.changes == 'true' && github.repository_owner == 'sustainable-computing-io' | |
| runs-on: self-hosted | |
| steps: | |
| # NOTE: In case of self-hosted runners, tools like docker, make, kubectl etc. are installed at the time of setting up the runner. | |
| # Hence, we don't need to install them as part of the job. | |
| - name: Checkout source | |
| uses: actions/checkout@v6 | |
| with: | |
| ref: ${{ github.event.pull_request.head.sha }} | |
| fetch-depth: 0 | |
| - name: Setup Go | |
| uses: actions/setup-go@v6.2.0 | |
| with: | |
| go-version-file: go.mod | |
| cache: false | |
| - name: Build image | |
| shell: bash | |
| run: | | |
| make image | |
| env: | |
| IMG_BASE: localhost:5001 | |
| VERSION: dev | |
| - name: Setup Kind cluster | |
| shell: bash | |
| run: | | |
| make cluster-up | |
| - name: Push image | |
| shell: bash | |
| run: | | |
| make push | |
| env: | |
| IMG_BASE: localhost:5001 | |
| VERSION: dev | |
| - name: Deploy Kepler | |
| shell: bash | |
| run: | | |
| make deploy | |
| env: | |
| IMG_BASE: localhost:5001 | |
| VERSION: dev | |
| - name: Verify Kepler deployment | |
| shell: bash | |
| run: | | |
| kubectl rollout status daemonset/kepler -n kepler --timeout=5m | |
| - name: Run k8s e2e tests | |
| shell: bash | |
| run: | | |
| make test-e2e-k8s | |
| - name: Run must gather | |
| if: always() | |
| shell: bash | |
| run: | | |
| echo "::group::Get pods in kepler namespace" | |
| kubectl get pods -n kepler || true | |
| echo "::endgroup::" | |
| echo "::group::Get pods in monitoring namespace" | |
| kubectl get pods -n monitoring || true | |
| echo "::endgroup::" | |
| echo "::group::Get logs for kepler daemonset" | |
| kubectl logs daemonset/kepler -n kepler || true | |
| echo "::endgroup::" | |
| echo "::group::Fetch metrics from localhost:28282" | |
| curl -s http://localhost:28282/metrics || true | |
| echo "::endgroup::" | |
| # NOTE: Ensure that all deployments, built images and cluster are properly cleaned up | |
| # to prevent residual resources | |
| - name: Undeploy Kepler | |
| if: always() | |
| shell: bash | |
| run: | | |
| make undeploy | |
| - name: Remove kind cluster | |
| if: always() | |
| shell: bash | |
| run: | | |
| make cluster-down | |
| - name: Clean Docker images | |
| if: always() | |
| shell: bash | |
| run: | | |
| docker image prune -af |