-
Notifications
You must be signed in to change notification settings - Fork 232
ci: add workflow to run kepler on k8s #2128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,145 @@ | ||
| name: Build and Deploy on K8s | ||
|
|
||
| on: #yamllint disable-line rule:truthy | ||
| pull_request: | ||
| branches: [reboot] | ||
|
|
||
| jobs: | ||
| build-and-deploy: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Install Docker | ||
| shell: bash | ||
| run: | | ||
| sudo apt-get update | ||
| sudo apt-get install -y apt-transport-https ca-certificates curl software-properties-common | ||
| curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg | ||
| echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list | ||
| sudo apt-get update | ||
| sudo apt-get install -y docker-ce docker-ce-cli containerd.io | ||
| sudo usermod -aG docker $USER | ||
|
|
||
| - name: Verify Docker installation | ||
| shell: bash | ||
| run: | | ||
| docker ps | ||
| docker --version | ||
|
|
||
| - name: Install Kind | ||
| shell: bash | ||
| 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/kind | ||
|
|
||
| - name: Verify Kind installation | ||
| shell: bash | ||
| run: | | ||
| kind version | ||
|
|
||
| - name: Install Kubectl | ||
| shell: bash | ||
| run: | | ||
| curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" | ||
| chmod +x ./kubectl | ||
| sudo mv ./kubectl /usr/local/bin/kubectl | ||
|
|
||
| - name: Verify Kubectl installation | ||
| shell: bash | ||
| run: | | ||
| kubectl version --client | ||
|
|
||
| - name: Checkout source | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Setup Go | ||
| uses: actions/setup-go@v5.4.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: Enable fake cpu meter | ||
| shell: bash | ||
| run: | | ||
| sed -i '/fake-cpu-meter:/{n;s/enabled: false/enabled: true/}' manifests/k8s/configmap.yaml | ||
|
|
||
| - 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 | ||
|
|
||
| # TODO: Move this once we add validator tool to the repo | ||
| - name: Validate metric endpoint | ||
| id: validate | ||
| shell: bash | ||
| run: | | ||
| kubectl port-forward service/kepler 28282:28282 -n kepler & | ||
| sleep 20 # sleep for 20 seconds to give the service time to start | ||
|
|
||
| HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:28282/metrics) | ||
| [[ $HTTP_STATUS -ne 200 ]] && echo "HTTP status code is not 200" && exit 1 | ||
|
|
||
| curl -s -o /tmp/metrics.txt http://localhost:28282/metrics | ||
|
|
||
| for metric in kepler_process_cpu_watts \ | ||
| kepler_node_cpu_info \ | ||
| kepler_process_cpu_joules_total \ | ||
| kepler_container_cpu_joules_total \ | ||
| kepler_container_cpu_watts; do | ||
| echo "Checking metric: $metric" | ||
| if ! grep -q "$metric" /tmp/metrics.txt; then | ||
| echo "Metric $metric not found" | ||
| exit 1 | ||
| fi | ||
| done | ||
|
|
||
| - name: Run must gather | ||
| if: failure() | ||
| 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::" | ||
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you also please check that there are no
An error has occurred?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure will add this as well