Compare commits

..

No commits in common. "main" and "step1" have entirely different histories.
main ... step1

23 changed files with 8 additions and 1157 deletions

View File

@ -1,112 +0,0 @@
stages: [build, deploy]
variables:
IMAGE_REPO: "$CI_REGISTRY_IMAGE"
TAG: "${CI_COMMIT_REF_SLUG}-${CI_COMMIT_SHORT_SHA}"
RELEASE: "open-meteo-service-gitlab"
NAMESPACE: "sandbox"
CHART_PATH: "./open-meteo-service"
VALUES_FILE: "./values.yaml"
build:
stage: build
tags: [homelab]
script:
- whoami
- set -euo pipefail
- unset DOCKER_HOST DOCKER_TLS_VERIFY DOCKER_CERT_PATH || true
- export DOCKER_HOST=unix:///var/run/docker.sock
- docker login "$CI_REGISTRY" -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD"
- docker build -t "$IMAGE_REPO:$TAG" .
- docker push "$IMAGE_REPO:$TAG"
- docker tag "$IMAGE_REPO:$TAG" "$IMAGE_REPO:latest"
- docker push "$IMAGE_REPO:latest"
- echo "Built and pushed $IMAGE_REPO:$TAG and $IMAGE_REPO:latest"
deploy:
stage: deploy
tags: [homelab]
rules:
- if: '$CI_COMMIT_MESSAGE =~ /^ci: bump image tag/'
when: never
- when: on_success
script: |-
set -euo pipefail
# Configure kubectl for k3s cluster
export KUBECONFIG=/tmp/k3s.yaml
echo "Configured kubectl to use k3s cluster"
kubectl cluster-info || echo "Warning: Could not connect to cluster yet"
# Update values.yaml with the new tag using sed
sed -i "s/^ tag: .*/ tag: \"${TAG}\"/" "${VALUES_FILE}"
echo "Updated ${VALUES_FILE} with image.tag=${TAG}"
# Verify the change
grep -A 2 "^image:" "${VALUES_FILE}"
# Configure git identity
git config user.email "gitlab-ci@dvirlabs.com"
git config user.name "GitLab CI"
# Commit & push values bump (skip-ci to avoid loop)
git add "${VALUES_FILE}"
git commit -m "ci: bump image tag to ${TAG} [skip ci]" || echo "No changes to commit"
# Push using GITLAB_TOKEN (Project Access Token with api scope)
if [ -n "${GITLAB_TOKEN:-}" ]; then
git remote set-url origin "https://oauth2:${GITLAB_TOKEN}@${CI_SERVER_HOST}/${CI_PROJECT_PATH}.git"
git push origin "HEAD:${CI_COMMIT_REF_NAME}" && echo "Pushed values.yaml update successfully" || echo "Failed to push, continuing deployment anyway"
else
echo "GITLAB_TOKEN not set, skipping git push (values.yaml is updated locally for this deployment)"
fi
# Create namespace if it doesn't exist
kubectl create namespace "${NAMESPACE}" --dry-run=client -o yaml | kubectl apply -f -
# Create or update GitLab registry secret for pulling images
echo "Creating/updating image pull secret..."
kubectl create secret docker-registry gitlab-registry \
--docker-server="${CI_REGISTRY}" \
--docker-username="${CI_REGISTRY_USER}" \
--docker-password="${CI_REGISTRY_PASSWORD}" \
--namespace="${NAMESPACE}" \
--dry-run=client -o yaml | kubectl apply -f -
echo "Deploying with Helm..."
helm upgrade --install "${RELEASE}" "${CHART_PATH}" \
-f "${VALUES_FILE}" \
-n "${NAMESPACE}" \
--create-namespace \
--wait --timeout 10m \
--debug
echo "Waiting for deployment to be ready..."
kubectl -n "${NAMESPACE}" rollout status deploy -l app.kubernetes.io/name=open-meteo-service --timeout=180s
echo "Port-forward for tests..."
SERVICE_NAME="${RELEASE}-open-meteo-service"
kubectl -n "${NAMESPACE}" port-forward "svc/${SERVICE_NAME}" 8000:8000 >/tmp/pf.log 2>&1 &
PF_PID=$!
sleep 5
echo "Testing /healthz..."
curl -fsS http://localhost:8000/healthz >/dev/null
echo "OK /healthz"
echo "Testing /coordinates..."
COORDS_RESPONSE="$(curl -fsS http://localhost:8000/coordinates)"
echo "$COORDS_RESPONSE" | head -20
if ! echo "$COORDS_RESPONSE" | grep -q '"data"'; then
echo "ERROR: /coordinates response missing 'data' field"
kill $PF_PID || true
exit 1
fi
echo "OK /coordinates"
echo "Testing /metrics..."
curl -fsS http://localhost:8000/metrics | head -20
echo "OK /metrics"
kill $PF_PID || true
echo "All tests passed!"

139
README.md
View File

@ -32,145 +32,6 @@ A FastAPI-based microservice that queries the Open-Meteo Geocoding API to retrie
- Prometheus: http://localhost:9090
- Grafana: http://localhost:3000 (admin/admin)
## Helm (Kubernetes)
The Helm chart in the `helm` folder deploys the FastAPI app and, by default, Prometheus and Grafana.
### What it deploys
- **App**: FastAPI service with `/healthz` probes and Prometheus scrape annotations
- **Prometheus**: Scrapes the app metrics at `/metrics`
- **Grafana**: Pre-provisioned datasource and dashboard for the app metrics
### Prerequisites
- Kubernetes cluster
- Helm v3
### Install
```bash
helm install open-meteo-service ./helm
```
### Upgrade
```bash
helm upgrade open-meteo-service ./helm
```
### Access the services
```bash
kubectl port-forward svc/open-meteo-service-open-meteo-service 8080:8000
kubectl port-forward svc/open-meteo-service-open-meteo-service-prometheus 9090:9090
kubectl port-forward svc/open-meteo-service-open-meteo-service-grafana 3000:3000
```
### Values overview
You can customize the chart via `helm/values.yaml` or `--set` flags.
**App values**
- `image.repository`, `image.tag`, `image.pullPolicy`
- `service.type`, `service.port`
- `env.cacheFile`
- `persistence.enabled`, `persistence.size`, `persistence.storageClassName`
**Prometheus values**
- `prometheus.enabled`
- `prometheus.image`
- `prometheus.service.type`, `prometheus.service.port`
- `prometheus.persistence.enabled`, `prometheus.persistence.size`, `prometheus.persistence.storageClassName`
**Grafana values**
- `grafana.enabled`
- `grafana.image`
- `grafana.service.type`, `grafana.service.port`
- `grafana.adminUser`, `grafana.adminPassword`
- `grafana.persistence.enabled`, `grafana.persistence.size`, `grafana.persistence.storageClassName`
### Example: disable Grafana and Prometheus
```bash
helm install open-meteo-service ./helm \
--set grafana.enabled=false \
--set prometheus.enabled=false
```
### Example: enable persistence for all components
```bash
helm install open-meteo-service ./helm \
--set persistence.enabled=true \
--set prometheus.persistence.enabled=true \
--set grafana.persistence.enabled=true
```
## GitLab CI Workflow
This project uses a GitLab CI/CD pipeline that automates building, versioning, deployment, and testing on an external k3s cluster (homelab).
### Pipeline Overview
The pipeline consists of two stages: **build** and **deploy**.
#### 1. Build Stage
- **Docker Image Build**: Builds the application Docker image using the project Dockerfile
- **Tagging Strategy**: Tags each image with a unique identifier combining branch and commit SHA:
- Format: `<branch>-<shortsha>` (e.g., `main-a1b2c3d`, `feature-api-xyz1234`)
- Uses `CI_COMMIT_REF_SLUG` (sanitized branch name) and `CI_COMMIT_SHORT_SHA`
- **Multi-Tag Push**: Pushes two tags to GitLab Container Registry:
- `$IMAGE_REPO:<branch>-<shortsha>` - Specific version tag
- `$IMAGE_REPO:latest` - Always points to the most recent build
- **Registry Authentication**: Uses GitLab's built-in CI variables (`CI_REGISTRY`, `CI_REGISTRY_USER`, `CI_REGISTRY_PASSWORD`)
#### 2. Deploy Stage
- **Values File Update**:
- Uses `yq` to update `open-meteo-service/values.yaml`
- Sets `image.tag` to the newly built tag (`<branch>-<shortsha>`)
- Keeps `image.repository` constant in the values file
- Commits the change with message: `ci: bump image tag to <tag> [skip ci]`
- Pushes back to the repository using `CI_JOB_TOKEN` for authentication
- **Helm Deployment**:
- Deploys to namespace: `sandbox`
- Release name: `open-meteo-service-gitlab`
- Uses the updated values.yaml file from the workspace
- Waits for deployment to be ready (5-minute timeout)
- **Automated Tests**:
- Port-forwards the service to localhost:8000
- `/healthz` - Checks service health
- `/coordinates` - Validates JSON response contains `"data"` field
- `/metrics` - Ensures metrics endpoint is accessible
- All tests must pass for the pipeline to succeed
### Preventing Infinite Loops
The pipeline includes safeguards to prevent infinite pipeline triggers:
- The deploy job includes a rule: `if: '$CI_COMMIT_MESSAGE =~ /^ci: bump image tag/'` with `when: never`
- The values bump commit includes `[skip ci]` to prevent triggering a new pipeline
- The deploy job uses the already-updated values.yaml in the current workspace
### Deployment Target
- **Cluster**: External k3s homelab cluster (not ephemeral)
- **Runner**: Self-hosted GitLab runner tagged with `homelab`
- **Namespace**: `sandbox` (separate from ArgoCD/Harbor setups)
- **Ingress**: Configured for `open-meteo-gitlab.dvirlabs.com` (see values.yaml)
### Viewing Pipeline Status
1. Navigate to **CI/CD > Pipelines** in your GitLab project
2. Click on any pipeline run to see job details
3. Expand jobs to view real-time logs
4. The deploy job shows Helm output, rollout status, and test results
### Manual Deployment
To deploy manually with a specific tag:
```bash
# Option 1: Deploy using updated values.yaml
helm upgrade --install open-meteo-service-gitlab ./open-meteo-service \
-n sandbox --create-namespace
# Option 2: Override tag via --set
helm upgrade --install open-meteo-service-gitlab ./open-meteo-service \
-n sandbox --create-namespace \
--set image.tag=main-a1b2c3d
```
## API Documentation
### Endpoints

View File

@ -26,76 +26,6 @@ def coordinates_for_city(city: str):
t.set_status("500")
raise
@app.get("/help")
def help_endpoint():
return {
"api_name": "Open-Meteo Coordinates Service",
"description": "Get geographical coordinates for cities",
"available_cities": ["Tel Aviv", "Beersheba", "Jerusalem", "Szeged"],
"endpoints": [
{
"path": "/coordinates",
"method": "GET",
"description": "Get coordinates for all available cities",
"example_request": "GET https://open-meteo.dvirlabs.com/coordinates",
"example_response": {
"source": "cache",
"data": {
"Tel Aviv": {
"name": "Tel Aviv",
"latitude": 32.08088,
"longitude": 34.78057,
"country": "Israel"
},
"Beersheba": {
"name": "Beersheba",
"latitude": 31.25181,
"longitude": 34.7913,
"country": "Israel"
}
}
}
},
{
"path": "/coordinates/{city}",
"method": "GET",
"description": "Get coordinates for a specific city",
"example_request": "GET https://open-meteo.dvirlabs.com/coordinates/Tel Aviv",
"example_response": {
"source": "cache",
"data": {
"name": "Tel Aviv",
"latitude": 32.08088,
"longitude": 34.78057,
"country": "Israel"
}
}
},
{
"path": "/healthz",
"method": "GET",
"description": "Health check endpoint",
"example_request": "GET https://open-meteo.dvirlabs.com/healthz",
"example_response": {
"status": "ok"
}
},
{
"path": "/metrics",
"method": "GET",
"description": "Prometheus metrics endpoint",
"example_request": "GET https://open-meteo.dvirlabs.com/metrics"
}
],
"usage_examples": {
"curl_all_cities": "curl https://open-meteo.dvirlabs.com/coordinates",
"curl_single_city": "curl https://open-meteo.dvirlabs.com/coordinates/Jerusalem",
"curl_with_spaces": "curl 'https://open-meteo.dvirlabs.com/coordinates/Tel%20Aviv'",
"python": "import requests\nresponse = requests.get('https://open-meteo.dvirlabs.com/coordinates/Jerusalem')\ndata = response.json()"
}
}
@app.get("/metrics")
def metrics():
return Response(generate_latest(), media_type=CONTENT_TYPE_LATEST)

View File

@ -6,7 +6,7 @@ import requests
from .metrics import CACHE_HITS_TOTAL, CACHE_MISSES_TOTAL, OPENMETEO_CALLS_TOTAL
API_URL = "https://geocoding-api.open-meteo.com/v1/search"
CITIES = ["Tel Aviv", "Beersheba", "Jerusalem", "Szeged"]
CITIES = ["Tel Aviv", "Beer Sheva", "Jerusalem", "Szeged"]
CACHE_FILE = os.environ.get("CACHE_FILE", "coordinates_cache.json")
@ -45,26 +45,18 @@ def _save_cache(data: Dict[str, Any]) -> None:
def get_all_coordinates() -> Dict[str, Any]:
cached = _load_cache()
# Check if all cities from CITIES list are in cache
if cached and all(city in cached for city in CITIES):
if cached:
CACHE_HITS_TOTAL.inc()
# Filter cache to only include cities from CITIES list
filtered_data = {city: cached[city] for city in CITIES}
return {"source": "cache", "data": filtered_data}
return {"source": "cache", "data": cached}
CACHE_MISSES_TOTAL.inc()
# Fetch missing cities
results = cached if cached else {}
results: Dict[str, Any] = {}
for city in CITIES:
if city not in results:
results[city] = _fetch_coordinates(city)
_save_cache(results)
# Return only cities from CITIES list
filtered_data = {city: results[city] for city in CITIES}
return {"source": "open-meteo", "data": filtered_data}
return {"source": "open-meteo", "data": results}
def get_coordinates_for_city(city: str) -> Dict[str, Any]:

View File

@ -1,6 +0,0 @@
apiVersion: v2
name: open-meteo-service
description: A FastAPI service that provides city coordinates with Prometheus metrics
type: application
version: 0.1.0
appVersion: "1.0.0"

View File

@ -1,107 +0,0 @@
{
"uid": "open-meteo-service",
"title": "Open-Meteo Service",
"timezone": "browser",
"schemaVersion": 38,
"version": 1,
"refresh": "10s",
"time": {
"from": "now-15m",
"to": "now"
},
"panels": [
{
"id": 1,
"type": "timeseries",
"title": "Request Rate",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": { "x": 0, "y": 0, "w": 12, "h": 8 },
"targets": [
{
"expr": "sum(rate(http_requests_total[5m])) by (endpoint, method)",
"legendFormat": "{{endpoint}} {{method}}",
"refId": "A"
}
]
},
{
"id": 2,
"type": "timeseries",
"title": "Request Duration p95",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": { "x": 12, "y": 0, "w": 12, "h": 8 },
"targets": [
{
"expr": "histogram_quantile(0.95, sum(rate(http_request_duration_seconds_bucket[5m])) by (le, endpoint, method))",
"legendFormat": "{{endpoint}} {{method}}",
"refId": "A"
}
]
},
{
"id": 3,
"type": "timeseries",
"title": "Cache Hits vs Misses",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": { "x": 0, "y": 8, "w": 12, "h": 8 },
"targets": [
{
"expr": "rate(coordinates_cache_hits_total[5m])",
"legendFormat": "hits",
"refId": "A"
},
{
"expr": "rate(coordinates_cache_misses_total[5m])",
"legendFormat": "misses",
"refId": "B"
}
]
},
{
"id": 4,
"type": "timeseries",
"title": "Open-Meteo Calls by City",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": { "x": 12, "y": 8, "w": 12, "h": 8 },
"targets": [
{
"expr": "sum(rate(openmeteo_api_calls_total[5m])) by (city)",
"legendFormat": "{{city}}",
"refId": "A"
}
]
},
{
"id": 5,
"type": "timeseries",
"title": "Requests by Status",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": { "x": 0, "y": 16, "w": 24, "h": 8 },
"targets": [
{
"expr": "sum(rate(http_requests_total[5m])) by (status)",
"legendFormat": "{{status}}",
"refId": "A"
}
]
}
],
"templating": {
"list": []
}
}

View File

@ -1,10 +0,0 @@
apiVersion: 1
providers:
- name: default
type: file
disableDeletion: false
editable: true
updateIntervalSeconds: 10
options:
path: /var/lib/grafana/dashboards

View File

@ -1,20 +0,0 @@
1. Get the application URL by running these commands:
{{- if contains "NodePort" .Values.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "open-meteo-service.fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT/docs
{{- else if contains "LoadBalancer" .Values.service.type }}
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "open-meteo-service.fullname" . }} -o jsonpath="{.status.loadBalancer.ingress[0].ip}")
echo http://$SERVICE_IP:{{ .Values.service.port }}/docs
{{- else }}
kubectl port-forward --namespace {{ .Release.Namespace }} svc/{{ include "open-meteo-service.fullname" . }} 8080:{{ .Values.service.port }}
echo http://127.0.0.1:8080/docs
{{- end }}
2. Prometheus (if enabled):
kubectl port-forward --namespace {{ .Release.Namespace }} svc/{{ include "open-meteo-service.prometheusFullname" . }} 9090:{{ .Values.prometheus.service.port }}
echo http://127.0.0.1:9090
3. Grafana (if enabled):
kubectl port-forward --namespace {{ .Release.Namespace }} svc/{{ include "open-meteo-service.grafanaFullname" . }} 3000:{{ .Values.grafana.service.port }}
echo http://127.0.0.1:3000 ({{ .Values.grafana.adminUser }}/{{ .Values.grafana.adminPassword }})

View File

@ -1,36 +0,0 @@
{{- define "open-meteo-service.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- define "open-meteo-service.fullname" -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
{{- define "open-meteo-service.labels" -}}
app.kubernetes.io/name: {{ include "open-meteo-service.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/version: {{ .Chart.AppVersion }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end -}}
{{- define "open-meteo-service.prometheusFullname" -}}
{{- printf "%s-prometheus" (include "open-meteo-service.fullname" .) | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- define "open-meteo-service.grafanaFullname" -}}
{{- printf "%s-grafana" (include "open-meteo-service.fullname" .) | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Selector labels for API component
*/}}
{{- define "open-meteo-service.selectorLabels" -}}
app.kubernetes.io/name: {{ include "open-meteo-service.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: api
{{- end -}}

View File

@ -1,75 +0,0 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "open-meteo-service.fullname" . }}
annotations:
argocd.argoproj.io/sync-options: Replace=true,Force=true
argocd.argoproj.io/sync-wave: "1"
labels:
{{- include "open-meteo-service.labels" . | nindent 4 }}
app.kubernetes.io/component: api
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
{{- include "open-meteo-service.selectorLabels" . | nindent 6 }}
template:
metadata:
labels:
{{- include "open-meteo-service.labels" . | nindent 8 }}
app.kubernetes.io/component: api
annotations:
{{- toYaml .Values.podAnnotations | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: {{ include "open-meteo-service.name" . }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: {{ .Values.service.port }}
protocol: TCP
env:
- name: CACHE_FILE
value: {{ .Values.env.cacheFile | quote }}
livenessProbe:
httpGet:
path: /healthz
port: http
initialDelaySeconds: 5
periodSeconds: 10
readinessProbe:
httpGet:
path: /healthz
port: http
initialDelaySeconds: 5
periodSeconds: 10
volumeMounts:
- name: cache-data
mountPath: /data
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumes:
- name: cache-data
{{- if .Values.persistence.enabled }}
persistentVolumeClaim:
claimName: {{ include "open-meteo-service.fullname" . }}
{{- else }}
emptyDir: {}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}

View File

@ -1,24 +0,0 @@
{{- if .Values.grafana.enabled }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "open-meteo-service.grafanaFullname" . }}-config
labels:
{{- include "open-meteo-service.labels" . | nindent 4 }}
app.kubernetes.io/component: grafana
data:
datasource.yml: |-
apiVersion: 1
datasources:
- name: Prometheus
type: prometheus
access: proxy
url: http://{{ include "open-meteo-service.prometheusFullname" . }}:{{ .Values.prometheus.service.port }}
isDefault: true
uid: prometheus
dashboard.yml: |-
{{ .Files.Get "files/grafana/provisioning/dashboards/dashboard.yml" | nindent 4 }}
open-meteo-service.json: |-
{{ .Files.Get "files/grafana/dashboards/open-meteo-service.json" | nindent 4 }}
{{- end }}

View File

@ -1,59 +0,0 @@
{{- if .Values.grafana.enabled }}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "open-meteo-service.grafanaFullname" . }}
labels:
{{- include "open-meteo-service.labels" . | nindent 4 }}
app.kubernetes.io/component: grafana
spec:
replicas: {{ .Values.grafana.replicaCount }}
selector:
matchLabels:
app.kubernetes.io/name: {{ include "open-meteo-service.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: grafana
template:
metadata:
labels:
{{- include "open-meteo-service.labels" . | nindent 8 }}
app.kubernetes.io/component: grafana
spec:
containers:
- name: grafana
image: {{ .Values.grafana.image | quote }}
ports:
- name: http
containerPort: {{ .Values.grafana.service.port }}
protocol: TCP
env:
- name: GF_SECURITY_ADMIN_USER
value: {{ .Values.grafana.adminUser | quote }}
- name: GF_SECURITY_ADMIN_PASSWORD
value: {{ .Values.grafana.adminPassword | quote }}
volumeMounts:
- name: grafana-config
mountPath: /etc/grafana/provisioning/datasources/datasource.yml
subPath: datasource.yml
- name: grafana-config
mountPath: /etc/grafana/provisioning/dashboards/dashboard.yml
subPath: dashboard.yml
- name: grafana-config
mountPath: /var/lib/grafana/dashboards/open-meteo-service.json
subPath: open-meteo-service.json
- name: grafana-data
mountPath: /var/lib/grafana
resources:
{{- toYaml .Values.grafana.resources | nindent 12 }}
volumes:
- name: grafana-config
configMap:
name: {{ include "open-meteo-service.grafanaFullname" . }}-config
- name: grafana-data
{{- if .Values.grafana.persistence.enabled }}
persistentVolumeClaim:
claimName: {{ include "open-meteo-service.grafanaFullname" . }}
{{- else }}
emptyDir: {}
{{- end }}
{{- end }}

View File

@ -1,33 +0,0 @@
{{- if and .Values.grafana.enabled .Values.grafana.ingress.enabled }}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ include "open-meteo-service.grafanaFullname" . }}
{{- if .Values.grafana.ingress.className }}
annotations:
kubernetes.io/ingress.class: {{ .Values.grafana.ingress.className }}
{{- end }}
spec:
{{- if .Values.grafana.ingress.className }}
ingressClassName: {{ .Values.grafana.ingress.className }}
{{- end }}
rules:
{{- range .Values.grafana.ingress.hosts }}
- host: {{ .host }}
http:
paths:
{{- range .paths }}
- path: {{ .path }}
pathType: {{ .pathType }}
backend:
service:
name: {{ include "open-meteo-service.grafanaFullname" $ }}
port:
number: {{ $.Values.grafana.service.port }}
{{- end }}
{{- end }}
{{- if .Values.grafana.ingress.tls }}
tls:
{{- toYaml .Values.grafana.ingress.tls | nindent 4 }}
{{- end }}
{{- end }}

View File

@ -1,20 +0,0 @@
{{- if .Values.grafana.enabled }}
apiVersion: v1
kind: Service
metadata:
name: {{ include "open-meteo-service.grafanaFullname" . }}
labels:
{{- include "open-meteo-service.labels" . | nindent 4 }}
app.kubernetes.io/component: grafana
spec:
type: {{ .Values.grafana.service.type }}
ports:
- port: {{ .Values.grafana.service.port }}
targetPort: http
protocol: TCP
name: http
selector:
app.kubernetes.io/name: {{ include "open-meteo-service.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: grafana
{{- end }}

View File

@ -1,33 +0,0 @@
{{- if .Values.ingress.enabled }}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ include "open-meteo-service.fullname" . }}
{{- if .Values.ingress.className }}
annotations:
kubernetes.io/ingress.class: {{ .Values.ingress.className }}
{{- end }}
spec:
{{- if .Values.ingress.className }}
ingressClassName: {{ .Values.ingress.className }}
{{- end }}
rules:
{{- range .Values.ingress.hosts }}
- host: {{ .host }}
http:
paths:
{{- range .paths }}
- path: {{ .path }}
pathType: {{ .pathType }}
backend:
service:
name: {{ include "open-meteo-service.fullname" $ }}
port:
number: {{ $.Values.service.port }}
{{- end }}
{{- end }}
{{- if .Values.ingress.tls }}
tls:
{{- toYaml .Values.ingress.tls | nindent 4 }}
{{- end }}
{{- end }}

View File

@ -1,23 +0,0 @@
{{- if .Values.prometheus.enabled }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "open-meteo-service.prometheusFullname" . }}
labels:
{{- include "open-meteo-service.labels" . | nindent 4 }}
app.kubernetes.io/component: prometheus
data:
prometheus.yml: |-
global:
scrape_interval: 15s
scrape_configs:
- job_name: "prometheus"
static_configs:
- targets: ["{{ include "open-meteo-service.prometheusFullname" . }}:{{ .Values.prometheus.service.port }}"]
- job_name: "open-meteo-service"
metrics_path: "/metrics"
static_configs:
- targets: ["{{ include "open-meteo-service.fullname" . }}:{{ .Values.service.port }}"]
{{- end }}

View File

@ -1,54 +0,0 @@
{{- if .Values.prometheus.enabled }}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "open-meteo-service.prometheusFullname" . }}
labels:
{{- include "open-meteo-service.labels" . | nindent 4 }}
app.kubernetes.io/component: prometheus
spec:
replicas: {{ .Values.prometheus.replicaCount }}
selector:
matchLabels:
app.kubernetes.io/name: {{ include "open-meteo-service.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: prometheus
template:
metadata:
labels:
{{- include "open-meteo-service.labels" . | nindent 8 }}
app.kubernetes.io/component: prometheus
spec:
containers:
- name: prometheus
image: {{ .Values.prometheus.image | quote }}
ports:
- name: http
containerPort: {{ .Values.prometheus.service.port }}
protocol: TCP
args:
- "--config.file=/etc/prometheus/prometheus.yml"
- "--storage.tsdb.path=/prometheus"
{{- range .Values.prometheus.extraArgs }}
- {{ . | quote }}
{{- end }}
volumeMounts:
- name: prometheus-config
mountPath: /etc/prometheus/prometheus.yml
subPath: prometheus.yml
- name: prometheus-data
mountPath: /prometheus
resources:
{{- toYaml .Values.prometheus.resources | nindent 12 }}
volumes:
- name: prometheus-config
configMap:
name: {{ include "open-meteo-service.prometheusFullname" . }}
- name: prometheus-data
{{- if .Values.prometheus.persistence.enabled }}
persistentVolumeClaim:
claimName: {{ include "open-meteo-service.prometheusFullname" . }}
{{- else }}
emptyDir: {}
{{- end }}
{{- end }}

View File

@ -1,33 +0,0 @@
{{- if and .Values.prometheus.enabled .Values.prometheus.ingress.enabled }}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ include "open-meteo-service.prometheusFullname" . }}
{{- if .Values.prometheus.ingress.className }}
annotations:
kubernetes.io/ingress.class: {{ .Values.prometheus.ingress.className }}
{{- end }}
spec:
{{- if .Values.prometheus.ingress.className }}
ingressClassName: {{ .Values.prometheus.ingress.className }}
{{- end }}
rules:
{{- range .Values.prometheus.ingress.hosts }}
- host: {{ .host }}
http:
paths:
{{- range .paths }}
- path: {{ .path }}
pathType: {{ .pathType }}
backend:
service:
name: {{ include "open-meteo-service.prometheusFullname" $ }}
port:
number: {{ $.Values.prometheus.service.port }}
{{- end }}
{{- end }}
{{- if .Values.prometheus.ingress.tls }}
tls:
{{- toYaml .Values.prometheus.ingress.tls | nindent 4 }}
{{- end }}
{{- end }}

View File

@ -1,20 +0,0 @@
{{- if .Values.prometheus.enabled }}
apiVersion: v1
kind: Service
metadata:
name: {{ include "open-meteo-service.prometheusFullname" . }}
labels:
{{- include "open-meteo-service.labels" . | nindent 4 }}
app.kubernetes.io/component: prometheus
spec:
type: {{ .Values.prometheus.service.type }}
ports:
- port: {{ .Values.prometheus.service.port }}
targetPort: http
protocol: TCP
name: http
selector:
app.kubernetes.io/name: {{ include "open-meteo-service.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: prometheus
{{- end }}

View File

@ -1,57 +0,0 @@
{{- if .Values.persistence.enabled }}
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ include "open-meteo-service.fullname" . }}
labels:
{{- include "open-meteo-service.labels" . | nindent 4 }}
spec:
accessModes:
{{- toYaml .Values.persistence.accessModes | nindent 4 }}
resources:
requests:
storage: {{ .Values.persistence.size }}
{{- if .Values.persistence.storageClassName }}
storageClassName: {{ .Values.persistence.storageClassName | quote }}
{{- end }}
{{- end }}
{{- if .Values.prometheus.persistence.enabled }}
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ include "open-meteo-service.prometheusFullname" . }}
labels:
{{- include "open-meteo-service.labels" . | nindent 4 }}
app.kubernetes.io/component: prometheus
spec:
accessModes:
{{- toYaml .Values.prometheus.persistence.accessModes | nindent 4 }}
resources:
requests:
storage: {{ .Values.prometheus.persistence.size }}
{{- if .Values.prometheus.persistence.storageClassName }}
storageClassName: {{ .Values.prometheus.persistence.storageClassName | quote }}
{{- end }}
{{- end }}
{{- if .Values.grafana.persistence.enabled }}
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ include "open-meteo-service.grafanaFullname" . }}
labels:
{{- include "open-meteo-service.labels" . | nindent 4 }}
app.kubernetes.io/component: grafana
spec:
accessModes:
{{- toYaml .Values.grafana.persistence.accessModes | nindent 4 }}
resources:
requests:
storage: {{ .Values.grafana.persistence.size }}
{{- if .Values.grafana.persistence.storageClassName }}
storageClassName: {{ .Values.grafana.persistence.storageClassName | quote }}
{{- end }}
{{- end }}

View File

@ -1,16 +0,0 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "open-meteo-service.fullname" . }}
labels:
{{- include "open-meteo-service.labels" . | nindent 4 }}
app.kubernetes.io/component: api
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: http
protocol: TCP
name: http
selector:
{{- include "open-meteo-service.selectorLabels" . | nindent 4 }}

View File

@ -1,97 +0,0 @@
replicaCount: 1
image:
repository: registry.gitlab.com/dvirlabs/open-meteo-service
tag: "latest"
pullPolicy: IfNotPresent
imagePullSecrets:
- name: gitlab-registry
service:
type: ClusterIP
port: 8000
ingress:
enabled: false
className: ""
hosts:
- host: open-meteo-gitlab.dvirlabs.com
paths:
- path: /
pathType: Prefix
tls: []
podAnnotations:
prometheus.io/scrape: "true"
prometheus.io/path: /metrics
prometheus.io/port: "8000"
env:
cacheFile: /data/coordinates_cache.json
persistence:
enabled: false
accessModes:
- ReadWriteOnce
size: 1Gi
storageClassName: ""
resources: {}
nodeSelector: {}
tolerations: []
affinity: {}
prometheus:
enabled: true
replicaCount: 1
image: prom/prometheus:latest
service:
type: ClusterIP
port: 9090
ingress:
enabled: false
className: ""
hosts:
- host: prometheus.local
paths:
- path: /
pathType: Prefix
tls: []
persistence:
enabled: false
accessModes:
- ReadWriteOnce
size: 5Gi
storageClassName: ""
resources: {}
extraArgs: []
grafana:
enabled: true
replicaCount: 1
image: grafana/grafana:latest
service:
type: ClusterIP
port: 3000
adminUser: admin
adminPassword: admin
ingress:
enabled: false
className: ""
hosts:
- host: grafana.local
paths:
- path: /
pathType: Prefix
tls: []
persistence:
enabled: false
accessModes:
- ReadWriteOnce
size: 5Gi
storageClassName: ""
resources: {}

View File

@ -1,97 +0,0 @@
replicaCount: 1
image:
repository: registry.gitlab.com/dvirlabs-group/open-meteo-service
tag: "main-5bc9ffce"
pullPolicy: IfNotPresent
imagePullSecrets:
- name: gitlab-registry
service:
type: ClusterIP
port: 8000
ingress:
enabled: true
className: "traefik"
hosts:
- host: open-meteo-gitlab.dvirlabs.com
paths:
- path: /
pathType: Prefix
tls: []
podAnnotations:
prometheus.io/scrape: "true"
prometheus.io/path: /metrics
prometheus.io/port: "8000"
env:
cacheFile: /data/coordinates_cache.json
persistence:
enabled: true
accessModes:
- ReadWriteOnce
size: 1Gi
storageClassName: "nfs-client"
resources: {}
nodeSelector: {}
tolerations: []
affinity: {}
prometheus:
enabled: true
replicaCount: 1
image: prom/prometheus:latest
service:
type: ClusterIP
port: 9090
ingress:
enabled: true
className: "traefik"
hosts:
- host: open-meteo-prometheus-gitlab.dvirlabs.com
paths:
- path: /
pathType: Prefix
tls: []
persistence:
enabled: true
accessModes:
- ReadWriteOnce
size: 5Gi
storageClassName: "nfs-client"
resources: {}
extraArgs: []
grafana:
enabled: true
replicaCount: 1
image: grafana/grafana:latest
service:
type: ClusterIP
port: 3000
adminUser: admin
adminPassword: admin
ingress:
enabled: true
className: "traefik"
hosts:
- host: open-meteo-grafana-gitlab.dvirlabs.com
paths:
- path: /
pathType: Prefix
tls: []
persistence:
enabled: true
accessModes:
- ReadWriteOnce
size: 5Gi
storageClassName: "nfs-client"
resources: {}