Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,17 @@ lint:
test-unit:
@cd app && go test ./... -cover;

.PHONY: preview
preview:
@helm template ./helm/pi-agent

.PHONY: deploy
deploy:
@source venv/activate > /dev/null; \
git fetch origin main --quiet; \
IMAGE_TAG=$$(git rev-parse --short origin/main); \
echo "Deploying image tag: $$IMAGE_TAG"; \
helm upgrade --install pi-agent helm/pi-agent \
--set image.tag=$(shell git rev-parse --short origin/main);
--set image.tag=$$IMAGE_TAG \
--namespace=pi-agent \
--create-namespace;
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ WORKDIR /app
COPY . .
RUN CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} go build -o pi-agent .

FROM alpine:3.21
FROM scratch
COPY --from=builder /app/pi-agent /pi-agent
ENTRYPOINT ["/pi-agent"]
4 changes: 2 additions & 2 deletions helm/pi-agent/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v2
name: pi-agent
description: A Helm chart for Kubernetes
description: Collects basic Raspberry Pi metrics

# A chart can be either an 'application' or a 'library' chart.
#
Expand All @@ -21,4 +21,4 @@ version: 0.1.0
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "1.16.0"
appVersion: "1.0.0"
13 changes: 13 additions & 0 deletions helm/pi-agent/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# templates/_helpers.tpl

# Standard labels applied to all resources
{{- define "pi-agent.labels" -}}
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }}
app.kubernetes.io/name: {{ .Chart.Name }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

# Metric collector selector labels
{{- define "pi-agent.collector.selectorLabels" -}}
app.kubernetes.io/component: {{ .Values.collector.name }}
{{- end }}
16 changes: 0 additions & 16 deletions helm/pi-agent/templates/cronjob.yaml

This file was deleted.

31 changes: 31 additions & 0 deletions helm/pi-agent/templates/daemonset.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Metric collector template
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: {{ .Values.collector.name }}
namespace: {{ .Release.namespace }}
labels: {{- include "pi-agent.labels" . | nindent 4 }}
spec:
selector:
matchLabels:
{{- include "pi-agent.collector.selectorLabels" . | nindent 6 }}
template:
metadata:
labels:
{{- include "pi-agent.collector.selectorLabels" . | nindent 8 }}
spec:
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
volumeMounts:
- name: sysfs
mountPath: /host/sys
readOnly: true
tolerations:
# Run on all nodes including control plane
- operator: Exists
volumes:
- name: sysfs
hostPath:
path: /sys
15 changes: 13 additions & 2 deletions helm/pi-agent/values.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
schedule: "*/5 * * * *"

# Image configuration
image:
repository: ghcr.io/amfelso/pi-agent
tag: latest
pullPolicy: IfNotPresent

# Metric collector configuration
collector:
name: metric-collector
schedule: 300 # Default collection interval = every 5 minutes
resources:
limits:
cpu: 500m
memory: 256Mi
requests:
cpu: 100m
memory: 128Mi
Loading