update(app): add helm chart and cleanup repo
Some checks failed
CI Pipeline / Build and Push Docker Image (push) Failing after 2m48s
Some checks failed
CI Pipeline / Build and Push Docker Image (push) Failing after 2m48s
This commit is contained in:
47
.github/workflows/ci.yaml
vendored
Normal file
47
.github/workflows/ci.yaml
vendored
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
name: CI Pipeline
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
|
env:
|
||||||
|
IMAGE_NAME: ghcr.io/terghalin/metalcheck-backend
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-and-push:
|
||||||
|
name: Build and Push Docker Image
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout Code
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v2
|
||||||
|
|
||||||
|
- name: Log in to GitHub Container Registry
|
||||||
|
uses: docker/login-action@v2
|
||||||
|
with:
|
||||||
|
registry: ghcr.io
|
||||||
|
username: ${{ github.actor }}
|
||||||
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Cache Python dependencies
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: ~/.cache/pip
|
||||||
|
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-pip-
|
||||||
|
|
||||||
|
- name: Build and Push Docker Image
|
||||||
|
uses: docker/build-push-action@v4
|
||||||
|
with:
|
||||||
|
push: true
|
||||||
|
tags: |
|
||||||
|
${{ env.IMAGE_NAME }}:latest
|
||||||
|
${{ env.IMAGE_NAME }}:${{ github.sha }}
|
||||||
20
README.md
20
README.md
@@ -127,3 +127,23 @@ curl -X GET "http://<EXTERNAL-IP>/export?format=yaml"
|
|||||||
```shell
|
```shell
|
||||||
curl -X GET "http://<EXTERNAL-IP>/export?format=json"
|
curl -X GET "http://<EXTERNAL-IP>/export?format=json"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## MetalCheck Helm Chart
|
||||||
|
|
||||||
|
This Helm chart deploys the MetalCheck backend on a Kubernetes cluster.
|
||||||
|
|
||||||
|
### Installation
|
||||||
|
|
||||||
|
#### Prerequisites
|
||||||
|
|
||||||
|
- Kubernetes cluster (1.18+ recommended)
|
||||||
|
- Helm 3.x installed
|
||||||
|
- Docker image for MetalCheck backend
|
||||||
|
|
||||||
|
#### Install Chart
|
||||||
|
|
||||||
|
1. Update `values.yaml` with your specific configurations.
|
||||||
|
2. Install the chart:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
helm install metalcheck ./metalcheck-helm
|
||||||
|
|||||||
@@ -1,292 +1,32 @@
|
|||||||
[
|
[
|
||||||
{
|
{
|
||||||
"name": "akita",
|
"name": "chuo",
|
||||||
"location": "Tokyo",
|
"location": "Tokyo",
|
||||||
"vendor": "Minisforum MS-01",
|
"vendor": "The Company",
|
||||||
"cpu": 24,
|
"cpu": 24,
|
||||||
"memory": "32GB",
|
"memory": "64GB",
|
||||||
"storage": "1TB",
|
"storage": "1TB",
|
||||||
"time_on_duty": 1000,
|
"time_on_duty": 522,
|
||||||
"initial_cost": 1000.0
|
"initial_cost": 1900
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "chiba",
|
"name": "kyoto",
|
||||||
"location": "Tokyo",
|
"location": "Kyoto",
|
||||||
"vendor": "Minisforum MS-01",
|
"vendor": "The Company",
|
||||||
"cpu": 24,
|
"cpu": 36,
|
||||||
"memory": "32GB",
|
"memory": "96GB",
|
||||||
"storage": "1TB",
|
"storage": "1TB",
|
||||||
"time_on_duty": 1000,
|
"time_on_duty": 807,
|
||||||
"initial_cost": 1000.0
|
"initial_cost": 1889
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "ehime",
|
"name": "sa-100",
|
||||||
"location": "Tokyo",
|
"location": "Sapporo",
|
||||||
"vendor": "Minisforum MS-01",
|
"vendor": "The Company",
|
||||||
"cpu": 24,
|
"cpu": 8,
|
||||||
"memory": "32GB",
|
"memory": "16GB",
|
||||||
"storage": "1TB",
|
"storage": "1TB",
|
||||||
"time_on_duty": 1000,
|
"time_on_duty": 4401,
|
||||||
"initial_cost": 1000.0
|
"initial_cost": 849
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "fukuoka",
|
|
||||||
"location": "Tokyo",
|
|
||||||
"vendor": "Minisforum MS-01",
|
|
||||||
"cpu": 24,
|
|
||||||
"memory": "32GB",
|
|
||||||
"storage": "1TB",
|
|
||||||
"time_on_duty": 1000,
|
|
||||||
"initial_cost": 1000.0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "kanagawa",
|
|
||||||
"location": "Tokyo",
|
|
||||||
"vendor": "Minisforum MS-01",
|
|
||||||
"cpu": 24,
|
|
||||||
"memory": "32GB",
|
|
||||||
"storage": "1TB",
|
|
||||||
"time_on_duty": 1000,
|
|
||||||
"initial_cost": 1000.0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "kumamoto",
|
|
||||||
"location": "Tokyo",
|
|
||||||
"vendor": "Minisforum MS-01",
|
|
||||||
"cpu": 24,
|
|
||||||
"memory": "32GB",
|
|
||||||
"storage": "1TB",
|
|
||||||
"time_on_duty": 1000,
|
|
||||||
"initial_cost": 1000.0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "okayama",
|
|
||||||
"location": "Tokyo",
|
|
||||||
"vendor": "Minisforum MS-01",
|
|
||||||
"cpu": 24,
|
|
||||||
"memory": "32GB",
|
|
||||||
"storage": "1TB",
|
|
||||||
"time_on_duty": 1000,
|
|
||||||
"initial_cost": 1000.0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "okinawa",
|
|
||||||
"location": "Tokyo",
|
|
||||||
"vendor": "Minisforum MS-01",
|
|
||||||
"cpu": 24,
|
|
||||||
"memory": "32GB",
|
|
||||||
"storage": "1TB",
|
|
||||||
"time_on_duty": 1000,
|
|
||||||
"initial_cost": 1000.0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "osaka",
|
|
||||||
"location": "Tokyo",
|
|
||||||
"vendor": "Minisforum MS-01",
|
|
||||||
"cpu": 24,
|
|
||||||
"memory": "32GB",
|
|
||||||
"storage": "1TB",
|
|
||||||
"time_on_duty": 1000,
|
|
||||||
"initial_cost": 1000.0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "saitama",
|
|
||||||
"location": "Tokyo",
|
|
||||||
"vendor": "Minisforum MS-01",
|
|
||||||
"cpu": 24,
|
|
||||||
"memory": "32GB",
|
|
||||||
"storage": "1TB",
|
|
||||||
"time_on_duty": 1000,
|
|
||||||
"initial_cost": 1000.0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "osaka",
|
|
||||||
"location": "Tokyo",
|
|
||||||
"vendor": "Minisforum MS-01",
|
|
||||||
"cpu": 24,
|
|
||||||
"memory": "32GB",
|
|
||||||
"storage": "1TB",
|
|
||||||
"time_on_duty": 1000,
|
|
||||||
"initial_cost": 1000.0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "saitama",
|
|
||||||
"location": "Tokyo",
|
|
||||||
"vendor": "Minisforum MS-01",
|
|
||||||
"cpu": 24,
|
|
||||||
"memory": "32GB",
|
|
||||||
"storage": "1TB",
|
|
||||||
"time_on_duty": 1000,
|
|
||||||
"initial_cost": 1000.0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "shizuoka",
|
|
||||||
"location": "Tokyo",
|
|
||||||
"vendor": "Minisforum MS-01",
|
|
||||||
"cpu": 24,
|
|
||||||
"memory": "32GB",
|
|
||||||
"storage": "1TB",
|
|
||||||
"time_on_duty": 1000,
|
|
||||||
"initial_cost": 1000.0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "yamagata",
|
|
||||||
"location": "Tokyo",
|
|
||||||
"vendor": "Minisforum MS-01",
|
|
||||||
"cpu": 24,
|
|
||||||
"memory": "32GB",
|
|
||||||
"storage": "1TB",
|
|
||||||
"time_on_duty": 1000,
|
|
||||||
"initial_cost": 1000.0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "adatara",
|
|
||||||
"location": "Tokyo",
|
|
||||||
"vendor": "OrangePi 5 ARM",
|
|
||||||
"cpu": 8,
|
|
||||||
"memory": "16GB",
|
|
||||||
"storage": "128GB",
|
|
||||||
"time_on_duty": 1000,
|
|
||||||
"initial_cost": 1000.0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "arashima",
|
|
||||||
"location": "Tokyo",
|
|
||||||
"vendor": "OrangePi 5 ARM",
|
|
||||||
"cpu": 8,
|
|
||||||
"memory": "16GB",
|
|
||||||
"storage": "128GB",
|
|
||||||
"time_on_duty": 1000,
|
|
||||||
"initial_cost": 1000.0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "asahi",
|
|
||||||
"location": "Tokyo",
|
|
||||||
"vendor": "OrangePi 5 ARM",
|
|
||||||
"cpu": 8,
|
|
||||||
"memory": "16GB",
|
|
||||||
"storage": "128GB",
|
|
||||||
"time_on_duty": 1000,
|
|
||||||
"initial_cost": 1000.0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "aso",
|
|
||||||
"location": "Tokyo",
|
|
||||||
"vendor": "OrangePi 5 ARM",
|
|
||||||
"cpu": 8,
|
|
||||||
"memory": "16GB",
|
|
||||||
"storage": "128GB",
|
|
||||||
"time_on_duty": 1000,
|
|
||||||
"initial_cost": 1000.0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "azuma",
|
|
||||||
"location": "Tokyo",
|
|
||||||
"vendor": "OrangePi 5 ARM",
|
|
||||||
"cpu": 8,
|
|
||||||
"memory": "16GB",
|
|
||||||
"storage": "128GB",
|
|
||||||
"time_on_duty": 1000,
|
|
||||||
"initial_cost": 1000.0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "daisen",
|
|
||||||
"location": "Tokyo",
|
|
||||||
"vendor": "OrangePi 5 ARM",
|
|
||||||
"cpu": 8,
|
|
||||||
"memory": "16GB",
|
|
||||||
"storage": "128GB",
|
|
||||||
"time_on_duty": 1000,
|
|
||||||
"initial_cost": 1000.0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "horoshiri",
|
|
||||||
"location": "Tokyo",
|
|
||||||
"vendor": "OrangePi 5 ARM",
|
|
||||||
"cpu": 8,
|
|
||||||
"memory": "16GB",
|
|
||||||
"storage": "128GB",
|
|
||||||
"time_on_duty": 1000,
|
|
||||||
"initial_cost": 1000.0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "nantai",
|
|
||||||
"location": "Tokyo",
|
|
||||||
"vendor": "OrangePi 5 ARM",
|
|
||||||
"cpu": 8,
|
|
||||||
"memory": "16GB",
|
|
||||||
"storage": "128GB",
|
|
||||||
"time_on_duty": 1000,
|
|
||||||
"initial_cost": 1000.0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "kirishima",
|
|
||||||
"location": "Tokyo",
|
|
||||||
"vendor": "OrangePi 5 ARM",
|
|
||||||
"cpu": 8,
|
|
||||||
"memory": "16GB",
|
|
||||||
"storage": "128GB",
|
|
||||||
"time_on_duty": 1000,
|
|
||||||
"initial_cost": 1000.0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "ontake",
|
|
||||||
"location": "Tokyo",
|
|
||||||
"vendor": "OrangePi 5 ARM",
|
|
||||||
"cpu": 8,
|
|
||||||
"memory": "16GB",
|
|
||||||
"storage": "128GB",
|
|
||||||
"time_on_duty": 1000,
|
|
||||||
"initial_cost": 1000.0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "rausu",
|
|
||||||
"location": "Tokyo",
|
|
||||||
"vendor": "OrangePi 5 ARM",
|
|
||||||
"cpu": 8,
|
|
||||||
"memory": "16GB",
|
|
||||||
"storage": "128GB",
|
|
||||||
"time_on_duty": 1000,
|
|
||||||
"initial_cost": 1000.0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "rishiri",
|
|
||||||
"location": "Tokyo",
|
|
||||||
"vendor": "OrangePi 5 ARM",
|
|
||||||
"cpu": 8,
|
|
||||||
"memory": "16GB",
|
|
||||||
"storage": "128GB",
|
|
||||||
"time_on_duty": 1000,
|
|
||||||
"initial_cost": 1000.0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "shari",
|
|
||||||
"location": "Tokyo",
|
|
||||||
"vendor": "OrangePi 5 ARM",
|
|
||||||
"cpu": 8,
|
|
||||||
"memory": "16GB",
|
|
||||||
"storage": "128GB",
|
|
||||||
"time_on_duty": 1000,
|
|
||||||
"initial_cost": 1000.0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "yotei",
|
|
||||||
"location": "Tokyo",
|
|
||||||
"vendor": "OrangePi 5 ARM",
|
|
||||||
"cpu": 8,
|
|
||||||
"memory": "16GB",
|
|
||||||
"storage": "128GB",
|
|
||||||
"time_on_duty": 1000,
|
|
||||||
"initial_cost": 1000.0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "zao",
|
|
||||||
"location": "Tokyo",
|
|
||||||
"vendor": "OrangePi 5 ARM",
|
|
||||||
"cpu": 8,
|
|
||||||
"memory": "16GB",
|
|
||||||
"storage": "128GB",
|
|
||||||
"time_on_duty": 1000,
|
|
||||||
"initial_cost": 1000.0
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
456
app/data/vm.json
456
app/data/vm.json
@@ -22,461 +22,5 @@
|
|||||||
"memory": "192GB",
|
"memory": "192GB",
|
||||||
"storage": "960GB SSD",
|
"storage": "960GB SSD",
|
||||||
"vm_type": "cx-6xlarge"
|
"vm_type": "cx-6xlarge"
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "cpx-41-1",
|
|
||||||
"location": "Helsinki",
|
|
||||||
"cpu": 8,
|
|
||||||
"memory": "16GB",
|
|
||||||
"storage": "240GB SSD",
|
|
||||||
"vm_type": "cx-xlarge"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "cpx-41-2",
|
|
||||||
"location": "Helsinki",
|
|
||||||
"cpu": 8,
|
|
||||||
"memory": "16GB",
|
|
||||||
"storage": "240GB SSD",
|
|
||||||
"vm_type": "cx-xlarge"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "cpx-41-3",
|
|
||||||
"location": "Helsinki",
|
|
||||||
"cpu": 8,
|
|
||||||
"memory": "16GB",
|
|
||||||
"storage": "240GB SSD",
|
|
||||||
"vm_type": "cx-xlarge"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "cpx-41-4",
|
|
||||||
"location": "Helsinki",
|
|
||||||
"cpu": 8,
|
|
||||||
"memory": "16GB",
|
|
||||||
"storage": "240GB SSD",
|
|
||||||
"vm_type": "cx-xlarge"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "cpx-41-5",
|
|
||||||
"location": "Helsinki",
|
|
||||||
"cpu": 8,
|
|
||||||
"memory": "16GB",
|
|
||||||
"storage": "240GB SSD",
|
|
||||||
"vm_type": "cx-xlarge"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "cpx-41-6",
|
|
||||||
"location": "Helsinki",
|
|
||||||
"cpu": 8,
|
|
||||||
"memory": "16GB",
|
|
||||||
"storage": "240GB SSD",
|
|
||||||
"vm_type": "cx-xlarge"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "cpx-41-7",
|
|
||||||
"location": "Helsinki",
|
|
||||||
"cpu": 8,
|
|
||||||
"memory": "16GB",
|
|
||||||
"storage": "240GB SSD",
|
|
||||||
"vm_type": "cx-xlarge"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "cpx-41-8",
|
|
||||||
"location": "Helsinki",
|
|
||||||
"cpu": 8,
|
|
||||||
"memory": "16GB",
|
|
||||||
"storage": "240GB SSD",
|
|
||||||
"vm_type": "cx-xlarge"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "cpx-41-9",
|
|
||||||
"location": "Helsinki",
|
|
||||||
"cpu": 8,
|
|
||||||
"memory": "16GB",
|
|
||||||
"storage": "240GB SSD",
|
|
||||||
"vm_type": "cx-xlarge"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "cpx-41-10",
|
|
||||||
"location": "Helsinki",
|
|
||||||
"cpu": 8,
|
|
||||||
"memory": "16GB",
|
|
||||||
"storage": "240GB SSD",
|
|
||||||
"vm_type": "cx-xlarge"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "cx-22-1",
|
|
||||||
"location": "Helsinki",
|
|
||||||
"cpu": 2,
|
|
||||||
"memory": "4GB",
|
|
||||||
"storage": "40GB SSD",
|
|
||||||
"vm_type": "cx-medium"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "cx-22-2",
|
|
||||||
"location": "Helsinki",
|
|
||||||
"cpu": 2,
|
|
||||||
"memory": "4GB",
|
|
||||||
"storage": "40GB SSD",
|
|
||||||
"vm_type": "cx-medium"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "cx-22-3",
|
|
||||||
"location": "Helsinki",
|
|
||||||
"cpu": 2,
|
|
||||||
"memory": "4GB",
|
|
||||||
"storage": "40GB SSD",
|
|
||||||
"vm_type": "cx-medium"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "cx-22-4",
|
|
||||||
"location": "Helsinki",
|
|
||||||
"cpu": 2,
|
|
||||||
"memory": "4GB",
|
|
||||||
"storage": "40GB SSD",
|
|
||||||
"vm_type": "cx-medium"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "cx-22-5",
|
|
||||||
"location": "Helsinki",
|
|
||||||
"cpu": 2,
|
|
||||||
"memory": "4GB",
|
|
||||||
"storage": "40GB SSD",
|
|
||||||
"vm_type": "cx-medium"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "cx-22-6",
|
|
||||||
"location": "Helsinki",
|
|
||||||
"cpu": 2,
|
|
||||||
"memory": "4GB",
|
|
||||||
"storage": "40GB SSD",
|
|
||||||
"vm_type": "cx-medium"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "cx-22-7",
|
|
||||||
"location": "Helsinki",
|
|
||||||
"cpu": 2,
|
|
||||||
"memory": "4GB",
|
|
||||||
"storage": "40GB SSD",
|
|
||||||
"vm_type": "cx-medium"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "cx-22-8",
|
|
||||||
"location": "Helsinki",
|
|
||||||
"cpu": 2,
|
|
||||||
"memory": "4GB",
|
|
||||||
"storage": "40GB SSD",
|
|
||||||
"vm_type": "cx-medium"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "cx-22-9",
|
|
||||||
"location": "Helsinki",
|
|
||||||
"cpu": 2,
|
|
||||||
"memory": "4GB",
|
|
||||||
"storage": "40GB SSD",
|
|
||||||
"vm_type": "cx-medium"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "cx-22-10",
|
|
||||||
"location": "Helsinki",
|
|
||||||
"cpu": 2,
|
|
||||||
"memory": "4GB",
|
|
||||||
"storage": "40GB SSD",
|
|
||||||
"vm_type": "cx-medium"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "cx-42-1",
|
|
||||||
"location": "Helsinki",
|
|
||||||
"cpu": 8,
|
|
||||||
"memory": "16GB",
|
|
||||||
"storage": "160GB SSD",
|
|
||||||
"vm_type": "cx-xlarge"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "cx-42-2",
|
|
||||||
"location": "Helsinki",
|
|
||||||
"cpu": 8,
|
|
||||||
"memory": "16GB",
|
|
||||||
"storage": "160GB SSD",
|
|
||||||
"vm_type": "cx-xlarge"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "cx-42-3",
|
|
||||||
"location": "Helsinki",
|
|
||||||
"cpu": 8,
|
|
||||||
"memory": "16GB",
|
|
||||||
"storage": "160GB SSD",
|
|
||||||
"vm_type": "cx-xlarge"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "cx-42-4",
|
|
||||||
"location": "Helsinki",
|
|
||||||
"cpu": 8,
|
|
||||||
"memory": "16GB",
|
|
||||||
"storage": "160GB SSD",
|
|
||||||
"vm_type": "cx-xlarge"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "cx-42-5",
|
|
||||||
"location": "Helsinki",
|
|
||||||
"cpu": 8,
|
|
||||||
"memory": "16GB",
|
|
||||||
"storage": "160GB SSD",
|
|
||||||
"vm_type": "cx-xlarge"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "cx-42-6",
|
|
||||||
"location": "Helsinki",
|
|
||||||
"cpu": 8,
|
|
||||||
"memory": "16GB",
|
|
||||||
"storage": "160GB SSD",
|
|
||||||
"vm_type": "cx-xlarge"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "cx-42-7",
|
|
||||||
"location": "Helsinki",
|
|
||||||
"cpu": 8,
|
|
||||||
"memory": "16GB",
|
|
||||||
"storage": "160GB SSD",
|
|
||||||
"vm_type": "cx-xlarge"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "cx-42-8",
|
|
||||||
"location": "Helsinki",
|
|
||||||
"cpu": 8,
|
|
||||||
"memory": "16GB",
|
|
||||||
"storage": "160GB SSD",
|
|
||||||
"vm_type": "cx-xlarge"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "cx-42-9",
|
|
||||||
"location": "Helsinki",
|
|
||||||
"cpu": 8,
|
|
||||||
"memory": "16GB",
|
|
||||||
"storage": "160GB SSD",
|
|
||||||
"vm_type": "cx-xlarge"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "cx-42-10",
|
|
||||||
"location": "Helsinki",
|
|
||||||
"cpu": 8,
|
|
||||||
"memory": "16GB",
|
|
||||||
"storage": "160GB SSD",
|
|
||||||
"vm_type": "cx-xlarge"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "cx-42-11",
|
|
||||||
"location": "Helsinki",
|
|
||||||
"cpu": 8,
|
|
||||||
"memory": "16GB",
|
|
||||||
"storage": "160GB SSD",
|
|
||||||
"vm_type": "cx-xlarge"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "cx-42-gawa-1",
|
|
||||||
"location": "Helsinki",
|
|
||||||
"cpu": 8,
|
|
||||||
"memory": "16GB",
|
|
||||||
"storage": "160GB",
|
|
||||||
"vm_type": "cx-xlarge"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "cx-42-gawa-2",
|
|
||||||
"location": "Helsinki",
|
|
||||||
"cpu": 8,
|
|
||||||
"memory": "16GB",
|
|
||||||
"storage": "160GB",
|
|
||||||
"vm_type": "cx-xlarge"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "cx-42-gawa-3",
|
|
||||||
"location": "Helsinki",
|
|
||||||
"cpu": 8,
|
|
||||||
"memory": "16GB",
|
|
||||||
"storage": "160GB",
|
|
||||||
"vm_type": "cx-xlarge"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "cx-42-gawa-4",
|
|
||||||
"location": "Helsinki",
|
|
||||||
"cpu": 8,
|
|
||||||
"memory": "16GB",
|
|
||||||
"storage": "160GB",
|
|
||||||
"vm_type": "cx-xlarge"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "cx-42-gawa-5",
|
|
||||||
"location": "Helsinki",
|
|
||||||
"cpu": 8,
|
|
||||||
"memory": "16GB",
|
|
||||||
"storage": "160GB",
|
|
||||||
"vm_type": "cx-xlarge"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "cx-42-gawa-6",
|
|
||||||
"location": "Helsinki",
|
|
||||||
"cpu": 8,
|
|
||||||
"memory": "16GB",
|
|
||||||
"storage": "160GB",
|
|
||||||
"vm_type": "cx-xlarge"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "cx-42-gawa-7",
|
|
||||||
"location": "Helsinki",
|
|
||||||
"cpu": 8,
|
|
||||||
"memory": "16GB",
|
|
||||||
"storage": "160GB",
|
|
||||||
"vm_type": "cx-xlarge"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "cx-42-gawa-8",
|
|
||||||
"location": "Helsinki",
|
|
||||||
"cpu": 8,
|
|
||||||
"memory": "16GB",
|
|
||||||
"storage": "160GB",
|
|
||||||
"vm_type": "cx-xlarge"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "cx-42-gawa-9",
|
|
||||||
"location": "Helsinki",
|
|
||||||
"cpu": 8,
|
|
||||||
"memory": "16GB",
|
|
||||||
"storage": "160GB",
|
|
||||||
"vm_type": "cx-xlarge"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "cx-42-gawa-10",
|
|
||||||
"location": "Helsinki",
|
|
||||||
"cpu": 8,
|
|
||||||
"memory": "16GB",
|
|
||||||
"storage": "160GB",
|
|
||||||
"vm_type": "cx-xlarge"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "cx-42-yama-1",
|
|
||||||
"location": "Helsinki",
|
|
||||||
"cpu": 8,
|
|
||||||
"memory": "16GB",
|
|
||||||
"storage": "160GB",
|
|
||||||
"vm_type": "cx-xlarge"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "cx-42-yama-2",
|
|
||||||
"location": "Helsinki",
|
|
||||||
"cpu": 8,
|
|
||||||
"memory": "16GB",
|
|
||||||
"storage": "160GB",
|
|
||||||
"vm_type": "cx-xlarge"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "cx-42-yama-3",
|
|
||||||
"location": "Helsinki",
|
|
||||||
"cpu": 8,
|
|
||||||
"memory": "16GB",
|
|
||||||
"storage": "160GB",
|
|
||||||
"vm_type": "cx-xlarge"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "cx-42-yama-4",
|
|
||||||
"location": "Helsinki",
|
|
||||||
"cpu": 8,
|
|
||||||
"memory": "16GB",
|
|
||||||
"storage": "160GB",
|
|
||||||
"vm_type": "cx-xlarge"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "cx-42-yama-5",
|
|
||||||
"location": "Helsinki",
|
|
||||||
"cpu": 8,
|
|
||||||
"memory": "16GB",
|
|
||||||
"storage": "160GB",
|
|
||||||
"vm_type": "cx-xlarge"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "cx-42-yama-6",
|
|
||||||
"location": "Helsinki",
|
|
||||||
"cpu": 8,
|
|
||||||
"memory": "16GB",
|
|
||||||
"storage": "160GB",
|
|
||||||
"vm_type": "cx-xlarge"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "cx-42-yama-7",
|
|
||||||
"location": "Helsinki",
|
|
||||||
"cpu": 8,
|
|
||||||
"memory": "16GB",
|
|
||||||
"storage": "160GB",
|
|
||||||
"vm_type": "cx-xlarge"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "cx-42-yama-8",
|
|
||||||
"location": "Helsinki",
|
|
||||||
"cpu": 8,
|
|
||||||
"memory": "16GB",
|
|
||||||
"storage": "160GB",
|
|
||||||
"vm_type": "cx-xlarge"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "cx-42-yama-9",
|
|
||||||
"location": "Helsinki",
|
|
||||||
"cpu": 8,
|
|
||||||
"memory": "16GB",
|
|
||||||
"storage": "160GB",
|
|
||||||
"vm_type": "cx-xlarge"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "cx-42-yama-10",
|
|
||||||
"location": "Helsinki",
|
|
||||||
"cpu": 8,
|
|
||||||
"memory": "16GB",
|
|
||||||
"storage": "160GB",
|
|
||||||
"vm_type": "cx-xlarge"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "cx-52-1",
|
|
||||||
"location": "Helsinki",
|
|
||||||
"cpu": 16,
|
|
||||||
"memory": "32GB",
|
|
||||||
"storage": "320GB",
|
|
||||||
"vm_type": "cx-xlarge"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "cx-52-2",
|
|
||||||
"location": "Helsinki",
|
|
||||||
"cpu": 16,
|
|
||||||
"memory": "32GB",
|
|
||||||
"storage": "320GB",
|
|
||||||
"vm_type": "cx-xlarge"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "cx-52-3",
|
|
||||||
"location": "Helsinki",
|
|
||||||
"cpu": 16,
|
|
||||||
"memory": "32GB",
|
|
||||||
"storage": "320GB",
|
|
||||||
"vm_type": "cx-xlarge"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "cx-52-4",
|
|
||||||
"location": "Helsinki",
|
|
||||||
"cpu": 16,
|
|
||||||
"memory": "32GB",
|
|
||||||
"storage": "320GB",
|
|
||||||
"vm_type": "cx-xlarge"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "cx-52-5",
|
|
||||||
"location": "Helsinki",
|
|
||||||
"cpu": 16,
|
|
||||||
"memory": "32GB",
|
|
||||||
"storage": "320GB",
|
|
||||||
"vm_type": "cx-xlarge"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "cx-52-6",
|
|
||||||
"location": "Helsinki",
|
|
||||||
"cpu": 16,
|
|
||||||
"memory": "32GB",
|
|
||||||
"storage": "320GB",
|
|
||||||
"vm_type": "cx-xlarge"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -79,14 +79,6 @@ app.include_router(k8s.router)
|
|||||||
app.include_router(export.router)
|
app.include_router(export.router)
|
||||||
app.include_router(think.router)
|
app.include_router(think.router)
|
||||||
|
|
||||||
#app.add_middleware(
|
|
||||||
# CORSMiddleware,
|
|
||||||
# allow_origins=["http://localhost:3000"],
|
|
||||||
# allow_credentials=True,
|
|
||||||
# allow_methods=["*"],
|
|
||||||
# allow_headers=["*"],
|
|
||||||
#)
|
|
||||||
|
|
||||||
@app.get("/")
|
@app.get("/")
|
||||||
def root():
|
def root():
|
||||||
return {"message": "Welcome to Metal Check API"}
|
return {"message": "Welcome to Metal Check API"}
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import json
|
|||||||
|
|
||||||
router = APIRouter()
|
router = APIRouter()
|
||||||
|
|
||||||
# Helper functions for conversions
|
|
||||||
def calculate_time_on_duty(creation_timestamp):
|
def calculate_time_on_duty(creation_timestamp):
|
||||||
"""
|
"""
|
||||||
Calculate the time on duty in hours, days, or minutes from the creation timestamp.
|
Calculate the time on duty in hours, days, or minutes from the creation timestamp.
|
||||||
@@ -25,7 +24,6 @@ def calculate_time_on_duty(creation_timestamp):
|
|||||||
hours = delta.seconds // 3600
|
hours = delta.seconds // 3600
|
||||||
return f"{hours} hours" if hours > 1 else "1 hour"
|
return f"{hours} hours" if hours > 1 else "1 hour"
|
||||||
|
|
||||||
# Otherwise, return days
|
|
||||||
return f"{delta.days} days" if delta.days > 1 else "1 day"
|
return f"{delta.days} days" if delta.days > 1 else "1 day"
|
||||||
|
|
||||||
def convert_memory_to_gb(memory):
|
def convert_memory_to_gb(memory):
|
||||||
@@ -58,21 +56,19 @@ def convert_cpu_to_cores(cpu):
|
|||||||
Handles units: n (nano), u (micro), m (milli), or none (cores).
|
Handles units: n (nano), u (micro), m (milli), or none (cores).
|
||||||
Returns float values for cores, rounded appropriately.
|
Returns float values for cores, rounded appropriately.
|
||||||
"""
|
"""
|
||||||
if "n" in cpu: # Nanocores to cores
|
if "n" in cpu:
|
||||||
return round(int(cpu.replace("n", "")) / 1e9, 4)
|
return round(int(cpu.replace("n", "")) / 1e9, 4)
|
||||||
elif "u" in cpu: # Microcores to cores
|
elif "u" in cpu:
|
||||||
return round(int(cpu.replace("u", "")) / 1e6, 4)
|
return round(int(cpu.replace("u", "")) / 1e6, 4)
|
||||||
elif "m" in cpu: # Millicores to cores
|
elif "m" in cpu:
|
||||||
return round(int(cpu.replace("m", "")) / 1000, 4)
|
return round(int(cpu.replace("m", "")) / 1000, 4)
|
||||||
return float(cpu) # Already in cores
|
return float(cpu)
|
||||||
|
|
||||||
# Fetch Kubernetes data with namespace resource usage
|
|
||||||
def fetch_k8s_data_with_usage():
|
def fetch_k8s_data_with_usage():
|
||||||
config.load_incluster_config()
|
config.load_incluster_config()
|
||||||
v1 = client.CoreV1Api()
|
v1 = client.CoreV1Api()
|
||||||
metrics_client = client.CustomObjectsApi()
|
metrics_client = client.CustomObjectsApi()
|
||||||
|
|
||||||
# Fetch nodes
|
|
||||||
nodes = []
|
nodes = []
|
||||||
for node in v1.list_node().items:
|
for node in v1.list_node().items:
|
||||||
# Extract storage (ephemeral-storage) and instance type
|
# Extract storage (ephemeral-storage) and instance type
|
||||||
@@ -80,7 +76,6 @@ def fetch_k8s_data_with_usage():
|
|||||||
instance_type = node.metadata.labels.get("beta.kubernetes.io/instance-type", "N/A")
|
instance_type = node.metadata.labels.get("beta.kubernetes.io/instance-type", "N/A")
|
||||||
creation_timestamp = node.metadata.creation_timestamp
|
creation_timestamp = node.metadata.creation_timestamp
|
||||||
|
|
||||||
# Calculate time on duty
|
|
||||||
time_on_duty = calculate_time_on_duty(creation_timestamp) if creation_timestamp else "N/A"
|
time_on_duty = calculate_time_on_duty(creation_timestamp) if creation_timestamp else "N/A"
|
||||||
|
|
||||||
nodes.append({
|
nodes.append({
|
||||||
@@ -93,10 +88,8 @@ def fetch_k8s_data_with_usage():
|
|||||||
"time_on_duty": time_on_duty, # Add time on duty
|
"time_on_duty": time_on_duty, # Add time on duty
|
||||||
})
|
})
|
||||||
|
|
||||||
# Fetch namespaces
|
|
||||||
namespaces = [ns.metadata.name for ns in v1.list_namespace().items]
|
namespaces = [ns.metadata.name for ns in v1.list_namespace().items]
|
||||||
|
|
||||||
# Fetch pod metrics and calculate namespace resource usage
|
|
||||||
namespace_usage = {}
|
namespace_usage = {}
|
||||||
pod_metrics = metrics_client.list_cluster_custom_object(
|
pod_metrics = metrics_client.list_cluster_custom_object(
|
||||||
group="metrics.k8s.io", version="v1beta1", plural="pods"
|
group="metrics.k8s.io", version="v1beta1", plural="pods"
|
||||||
@@ -110,22 +103,19 @@ def fetch_k8s_data_with_usage():
|
|||||||
cpu_usage = container["usage"]["cpu"]
|
cpu_usage = container["usage"]["cpu"]
|
||||||
memory_usage = container["usage"]["memory"]
|
memory_usage = container["usage"]["memory"]
|
||||||
|
|
||||||
# Convert CPU to cores and memory to MiB
|
|
||||||
namespace_usage[pod_namespace]["cpu"] += convert_cpu_to_cores(cpu_usage)
|
namespace_usage[pod_namespace]["cpu"] += convert_cpu_to_cores(cpu_usage)
|
||||||
namespace_usage[pod_namespace]["memory"] += convert_memory_to_mib(memory_usage)
|
namespace_usage[pod_namespace]["memory"] += convert_memory_to_mib(memory_usage)
|
||||||
|
|
||||||
# Round and format usage for readability
|
|
||||||
namespace_usage = {
|
namespace_usage = {
|
||||||
ns: {
|
ns: {
|
||||||
"cpu": round(usage["cpu"], 4), # Round to 4 decimal places
|
"cpu": round(usage["cpu"], 4),
|
||||||
"memory": round(usage["memory"], 2), # Memory in MiB
|
"memory": round(usage["memory"], 2),
|
||||||
}
|
}
|
||||||
for ns, usage in namespace_usage.items()
|
for ns, usage in namespace_usage.items()
|
||||||
}
|
}
|
||||||
|
|
||||||
return {"nodes": nodes, "namespaces": namespaces, "namespace_usage": namespace_usage}
|
return {"nodes": nodes, "namespaces": namespaces, "namespace_usage": namespace_usage}
|
||||||
|
|
||||||
# Export endpoint
|
|
||||||
@router.get("/export")
|
@router.get("/export")
|
||||||
def export_data(format: str = "yaml"):
|
def export_data(format: str = "yaml"):
|
||||||
data = {
|
data = {
|
||||||
|
|||||||
@@ -9,14 +9,12 @@ def fetch_k8s_data_with_usage():
|
|||||||
v1 = client.CoreV1Api()
|
v1 = client.CoreV1Api()
|
||||||
metrics_client = client.CustomObjectsApi()
|
metrics_client = client.CustomObjectsApi()
|
||||||
|
|
||||||
# Fetch nodes
|
|
||||||
nodes = []
|
nodes = []
|
||||||
for node in v1.list_node().items:
|
for node in v1.list_node().items:
|
||||||
# Extract storage (ephemeral-storage) and instance type
|
# Extract storage (ephemeral-storage) and instance type
|
||||||
ephemeral_storage = node.status.capacity.get("ephemeral-storage", "0")
|
ephemeral_storage = node.status.capacity.get("ephemeral-storage", "0")
|
||||||
instance_type = node.metadata.labels.get("beta.kubernetes.io/instance-type", "N/A")
|
instance_type = node.metadata.labels.get("beta.kubernetes.io/instance-type", "N/A")
|
||||||
|
|
||||||
# Calculate time on duty
|
|
||||||
creation_timestamp = node.metadata.creation_timestamp
|
creation_timestamp = node.metadata.creation_timestamp
|
||||||
if creation_timestamp:
|
if creation_timestamp:
|
||||||
time_on_duty = calculate_time_on_duty(creation_timestamp)
|
time_on_duty = calculate_time_on_duty(creation_timestamp)
|
||||||
@@ -26,17 +24,15 @@ def fetch_k8s_data_with_usage():
|
|||||||
nodes.append({
|
nodes.append({
|
||||||
"node_name": node.metadata.name,
|
"node_name": node.metadata.name,
|
||||||
"cpu": node.status.capacity.get("cpu"),
|
"cpu": node.status.capacity.get("cpu"),
|
||||||
"memory": round(convert_memory_to_mib(node.status.capacity.get("memory")), 2), # Convert to MiB
|
"memory": round(convert_memory_to_mib(node.status.capacity.get("memory")), 2),
|
||||||
"storage": f"{round(convert_memory_to_gb(ephemeral_storage), 2)} GB",
|
"storage": f"{round(convert_memory_to_gb(ephemeral_storage), 2)} GB",
|
||||||
"instance_type": instance_type,
|
"instance_type": instance_type,
|
||||||
"pods_allocatable": node.status.allocatable.get("pods"),
|
"pods_allocatable": node.status.allocatable.get("pods"),
|
||||||
"time_on_duty": time_on_duty, # Add time on duty
|
"time_on_duty": time_on_duty,
|
||||||
})
|
})
|
||||||
|
|
||||||
# Fetch namespaces
|
|
||||||
namespaces = [ns.metadata.name for ns in v1.list_namespace().items]
|
namespaces = [ns.metadata.name for ns in v1.list_namespace().items]
|
||||||
|
|
||||||
# Fetch pod metrics and calculate namespace resource usage
|
|
||||||
namespace_usage = {}
|
namespace_usage = {}
|
||||||
pod_metrics = metrics_client.list_cluster_custom_object(
|
pod_metrics = metrics_client.list_cluster_custom_object(
|
||||||
group="metrics.k8s.io", version="v1beta1", plural="pods"
|
group="metrics.k8s.io", version="v1beta1", plural="pods"
|
||||||
@@ -50,15 +46,13 @@ def fetch_k8s_data_with_usage():
|
|||||||
cpu_usage = container["usage"]["cpu"]
|
cpu_usage = container["usage"]["cpu"]
|
||||||
memory_usage = container["usage"]["memory"]
|
memory_usage = container["usage"]["memory"]
|
||||||
|
|
||||||
# Convert CPU to cores and memory to MiB
|
|
||||||
namespace_usage[pod_namespace]["cpu"] += convert_cpu_to_cores(cpu_usage)
|
namespace_usage[pod_namespace]["cpu"] += convert_cpu_to_cores(cpu_usage)
|
||||||
namespace_usage[pod_namespace]["memory"] += convert_memory_to_mib(memory_usage)
|
namespace_usage[pod_namespace]["memory"] += convert_memory_to_mib(memory_usage)
|
||||||
|
|
||||||
# Round and format usage for readability
|
|
||||||
namespace_usage = {
|
namespace_usage = {
|
||||||
ns: {
|
ns: {
|
||||||
"cpu": round(usage["cpu"], 4), # Round to 4 decimal places
|
"cpu": round(usage["cpu"], 4),
|
||||||
"memory": round(usage["memory"], 2), # Memory in MiB
|
"memory": round(usage["memory"], 2),
|
||||||
}
|
}
|
||||||
for ns, usage in namespace_usage.items()
|
for ns, usage in namespace_usage.items()
|
||||||
}
|
}
|
||||||
@@ -73,17 +67,14 @@ def calculate_time_on_duty(creation_timestamp):
|
|||||||
now = datetime.now(timezone.utc)
|
now = datetime.now(timezone.utc)
|
||||||
delta = now - creation_timestamp
|
delta = now - creation_timestamp
|
||||||
|
|
||||||
# If less than an hour, return minutes
|
|
||||||
if delta.days < 1 and delta.seconds < 3600:
|
if delta.days < 1 and delta.seconds < 3600:
|
||||||
minutes = delta.seconds // 60
|
minutes = delta.seconds // 60
|
||||||
return f"{minutes} minutes" if minutes > 1 else "less than a minute"
|
return f"{minutes} minutes" if minutes > 1 else "less than a minute"
|
||||||
|
|
||||||
# If less than a day, return hours
|
|
||||||
if delta.days < 1:
|
if delta.days < 1:
|
||||||
hours = delta.seconds // 3600
|
hours = delta.seconds // 3600
|
||||||
return f"{hours} hours" if hours > 1 else "1 hour"
|
return f"{hours} hours" if hours > 1 else "1 hour"
|
||||||
|
|
||||||
# Otherwise, return days
|
|
||||||
return f"{delta.days} days" if delta.days > 1 else "1 day"
|
return f"{delta.days} days" if delta.days > 1 else "1 day"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,6 @@ def think_k8s():
|
|||||||
|
|
||||||
cluster_name = "eks-staging"
|
cluster_name = "eks-staging"
|
||||||
|
|
||||||
# Format node data
|
|
||||||
nodes = []
|
nodes = []
|
||||||
for node in v1.list_node().items:
|
for node in v1.list_node().items:
|
||||||
# Fetch ephemeral-storage and instance type
|
# Fetch ephemeral-storage and instance type
|
||||||
@@ -61,7 +60,6 @@ def think_k8s():
|
|||||||
"namespaces": [ns.metadata.name for ns in v1.list_namespace().items]
|
"namespaces": [ns.metadata.name for ns in v1.list_namespace().items]
|
||||||
})
|
})
|
||||||
|
|
||||||
# Fetch environment variables
|
|
||||||
api_url = os.getenv("AI_API_URL")
|
api_url = os.getenv("AI_API_URL")
|
||||||
auth_token = os.getenv("AI_API_TOKEN")
|
auth_token = os.getenv("AI_API_TOKEN")
|
||||||
|
|
||||||
|
|||||||
6
helm/Chart.yaml
Normal file
6
helm/Chart.yaml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
apiVersion: v2
|
||||||
|
name: metalcheck-backend
|
||||||
|
description: A Helm chart for deploying the MetalCheck backend application.
|
||||||
|
type: application
|
||||||
|
version: 0.1.0
|
||||||
|
appVersion: "latest"
|
||||||
7
helm/templates/_helpers.tpl
Normal file
7
helm/templates/_helpers.tpl
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
{{/*
|
||||||
|
Expand common labels.
|
||||||
|
*/}}
|
||||||
|
{{- define "metalcheck-backend.labels" -}}
|
||||||
|
app: {{ .Chart.Name }}
|
||||||
|
release: {{ .Release.Name }}
|
||||||
|
{{- end }}
|
||||||
8
helm/templates/configmap.yaml
Normal file
8
helm/templates/configmap.yaml
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
name: {{ .Release.Name }}-config
|
||||||
|
labels:
|
||||||
|
app: {{ .Chart.Name }}
|
||||||
|
data:
|
||||||
|
HETZNER_TOKEN: {{ .Values.env.HETZNER_TOKEN | quote }}
|
||||||
30
helm/templates/deployment.yaml
Normal file
30
helm/templates/deployment.yaml
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: {{ .Release.Name }}-backend
|
||||||
|
labels:
|
||||||
|
app: {{ .Chart.Name }}
|
||||||
|
release: {{ .Release.Name }}
|
||||||
|
spec:
|
||||||
|
replicas: {{ .Values.replicaCount }}
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: {{ .Chart.Name }}
|
||||||
|
release: {{ .Release.Name }}
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: {{ .Chart.Name }}
|
||||||
|
release: {{ .Release.Name }}
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: backend
|
||||||
|
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
|
||||||
|
imagePullPolicy: {{ .Values.image.pullPolicy }}
|
||||||
|
ports:
|
||||||
|
- containerPort: 80
|
||||||
|
env:
|
||||||
|
- name: HETZNER_TOKEN
|
||||||
|
value: "{{ .Values.env.HETZNER_TOKEN }}"
|
||||||
|
resources:
|
||||||
|
{{- toYaml .Values.resources | nindent 12 }}
|
||||||
26
helm/templates/ingress.yaml
Normal file
26
helm/templates/ingress.yaml
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
{{- if .Values.ingress.enabled }}
|
||||||
|
apiVersion: networking.k8s.io/v1
|
||||||
|
kind: Ingress
|
||||||
|
metadata:
|
||||||
|
name: {{ .Release.Name }}-ingress
|
||||||
|
annotations:
|
||||||
|
{{ toYaml .Values.ingress.annotations | indent 4 }}
|
||||||
|
spec:
|
||||||
|
rules:
|
||||||
|
{{- range .Values.ingress.hosts }}
|
||||||
|
- host: {{ .host }}
|
||||||
|
http:
|
||||||
|
paths:
|
||||||
|
{{- range .paths }}
|
||||||
|
- path: {{ .path }}
|
||||||
|
pathType: {{ .pathType }}
|
||||||
|
backend:
|
||||||
|
service:
|
||||||
|
name: {{ $.Release.Name }}-service
|
||||||
|
port:
|
||||||
|
number: {{ $.Values.service.port }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
tls:
|
||||||
|
{{ toYaml .Values.ingress.tls | indent 4 }}
|
||||||
|
{{- end }}
|
||||||
49
helm/templates/rbac.yaml
Normal file
49
helm/templates/rbac.yaml
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: ServiceAccount
|
||||||
|
metadata:
|
||||||
|
name: {{ .Release.Name }}-sa
|
||||||
|
namespace: {{ .Release.Namespace }}
|
||||||
|
---
|
||||||
|
apiVersion: rbac.authorization.k8s.io/v1
|
||||||
|
kind: ClusterRole
|
||||||
|
metadata:
|
||||||
|
name: {{ .Release.Name }}-clusterrole
|
||||||
|
rules:
|
||||||
|
- apiGroups: [""]
|
||||||
|
resources: ["pods", "nodes", "namespaces"]
|
||||||
|
verbs: ["get", "list", "watch"]
|
||||||
|
---
|
||||||
|
apiVersion: rbac.authorization.k8s.io/v1
|
||||||
|
kind: ClusterRoleBinding
|
||||||
|
metadata:
|
||||||
|
name: {{ .Release.Name }}-clusterrolebinding
|
||||||
|
subjects:
|
||||||
|
- kind: ServiceAccount
|
||||||
|
name: {{ .Release.Name }}-sa
|
||||||
|
namespace: {{ .Release.Namespace }}
|
||||||
|
roleRef:
|
||||||
|
kind: ClusterRole
|
||||||
|
name: {{ .Release.Name }}-clusterrole
|
||||||
|
apiGroup: rbac.authorization.k8s.io
|
||||||
|
---
|
||||||
|
apiVersion: rbac.authorization.k8s.io/v1
|
||||||
|
kind: ClusterRole
|
||||||
|
metadata:
|
||||||
|
name: {{ .Release.Name }}-metrics-reader
|
||||||
|
rules:
|
||||||
|
- apiGroups: ["metrics.k8s.io"]
|
||||||
|
resources: ["pods"]
|
||||||
|
verbs: ["get", "list", "watch"]
|
||||||
|
---
|
||||||
|
apiVersion: rbac.authorization.k8s.io/v1
|
||||||
|
kind: ClusterRoleBinding
|
||||||
|
metadata:
|
||||||
|
name: {{ .Release.Name }}-metrics-reader-binding
|
||||||
|
subjects:
|
||||||
|
- kind: ServiceAccount
|
||||||
|
name: {{ .Release.Name }}-sa
|
||||||
|
namespace: {{ .Release.Namespace }}
|
||||||
|
roleRef:
|
||||||
|
kind: ClusterRole
|
||||||
|
name: {{ .Release.Name }}-metrics-reader
|
||||||
|
apiGroup: rbac.authorization.k8s.io
|
||||||
14
helm/templates/service.yaml
Normal file
14
helm/templates/service.yaml
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: {{ .Release.Name }}-service
|
||||||
|
labels:
|
||||||
|
app: {{ .Chart.Name }}
|
||||||
|
spec:
|
||||||
|
type: {{ .Values.service.type }}
|
||||||
|
ports:
|
||||||
|
- port: {{ .Values.service.port }}
|
||||||
|
targetPort: 80
|
||||||
|
selector:
|
||||||
|
app: {{ .Chart.Name }}
|
||||||
|
release: {{ .Release.Name }}
|
||||||
35
helm/values.yaml
Normal file
35
helm/values.yaml
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
replicaCount: 2
|
||||||
|
|
||||||
|
image:
|
||||||
|
repository: ghcr.io/terghalin/metalcheck-backend
|
||||||
|
tag: latest
|
||||||
|
pullPolicy: IfNotPresent
|
||||||
|
|
||||||
|
service:
|
||||||
|
type: LoadBalancer
|
||||||
|
port: 80
|
||||||
|
|
||||||
|
ingress:
|
||||||
|
enabled: false
|
||||||
|
annotations: {}
|
||||||
|
hosts:
|
||||||
|
- host: metalcheck.local
|
||||||
|
paths:
|
||||||
|
- path: /
|
||||||
|
pathType: ImplementationSpecific
|
||||||
|
tls: []
|
||||||
|
|
||||||
|
resources:
|
||||||
|
limits:
|
||||||
|
cpu: "500m"
|
||||||
|
memory: "512Mi"
|
||||||
|
requests:
|
||||||
|
cpu: "250m"
|
||||||
|
memory: "256Mi"
|
||||||
|
|
||||||
|
env:
|
||||||
|
HETZNER_TOKEN: ""
|
||||||
|
|
||||||
|
nodeSelector: {}
|
||||||
|
tolerations: []
|
||||||
|
affinity: {}
|
||||||
Reference in New Issue
Block a user