From bd3c6b5e255ee6798c5c69ffdc7b3e89492c716c Mon Sep 17 00:00:00 2001 From: rod Date: Sun, 17 May 2026 12:06:17 +0200 Subject: [PATCH] Fix .gitignore and add Helm chart --- .gitignore | 2 +- helm/hello-svc/Chart.yaml | 6 +++ helm/hello-svc/templates/_helpers.tpl | 20 ++++++++++ helm/hello-svc/templates/deployment.yaml | 39 ++++++++++++++++++++ helm/hello-svc/templates/service.yaml | 13 +++++++ helm/hello-svc/templates/servicemonitor.yaml | 16 ++++++++ helm/hello-svc/values.yaml | 28 ++++++++++++++ 7 files changed, 123 insertions(+), 1 deletion(-) create mode 100644 helm/hello-svc/Chart.yaml create mode 100644 helm/hello-svc/templates/_helpers.tpl create mode 100644 helm/hello-svc/templates/deployment.yaml create mode 100644 helm/hello-svc/templates/service.yaml create mode 100644 helm/hello-svc/templates/servicemonitor.yaml create mode 100644 helm/hello-svc/values.yaml diff --git a/.gitignore b/.gitignore index 56cc09a..11f083b 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -hello-svc +/hello-svc diff --git a/helm/hello-svc/Chart.yaml b/helm/hello-svc/Chart.yaml new file mode 100644 index 0000000..79ccd21 --- /dev/null +++ b/helm/hello-svc/Chart.yaml @@ -0,0 +1,6 @@ +apiVersion: v2 +name: hello-svc +description: A minimal Go HTTP service for platform engineering practice +type: application +version: 0.1.0 +appVersion: "0.1.0" diff --git a/helm/hello-svc/templates/_helpers.tpl b/helm/hello-svc/templates/_helpers.tpl new file mode 100644 index 0000000..5fd1d05 --- /dev/null +++ b/helm/hello-svc/templates/_helpers.tpl @@ -0,0 +1,20 @@ +{{- define "hello-svc.name" -}} +{{- .Chart.Name }} +{{- end }} + +{{- define "hello-svc.fullname" -}} +{{- .Release.Name }} +{{- end }} + +{{- define "hello-svc.labels" -}} +helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }} +app.kubernetes.io/name: {{ include "hello-svc.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{- define "hello-svc.selectorLabels" -}} +app.kubernetes.io/name: {{ include "hello-svc.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} diff --git a/helm/hello-svc/templates/deployment.yaml b/helm/hello-svc/templates/deployment.yaml new file mode 100644 index 0000000..d9ceae5 --- /dev/null +++ b/helm/hello-svc/templates/deployment.yaml @@ -0,0 +1,39 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "hello-svc.fullname" . }} + labels: + {{- include "hello-svc.labels" . | nindent 4 }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + {{- include "hello-svc.selectorLabels" . | nindent 6 }} + template: + metadata: + labels: + {{- include "hello-svc.selectorLabels" . | nindent 8 }} + spec: + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - containerPort: {{ .Values.service.targetPort }} + env: + {{- range $k, $v := .Values.env }} + - name: {{ $k }} + value: {{ $v | quote }} + {{- end }} + resources: + {{- toYaml .Values.resources | nindent 12 }} + livenessProbe: + httpGet: + path: /healthz + port: {{ .Values.service.targetPort }} + initialDelaySeconds: 5 + readinessProbe: + httpGet: + path: /healthz + port: {{ .Values.service.targetPort }} + initialDelaySeconds: 5 diff --git a/helm/hello-svc/templates/service.yaml b/helm/hello-svc/templates/service.yaml new file mode 100644 index 0000000..bbadd13 --- /dev/null +++ b/helm/hello-svc/templates/service.yaml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "hello-svc.fullname" . }} + labels: + {{- include "hello-svc.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + selector: + {{- include "hello-svc.selectorLabels" . | nindent 4 }} + ports: + - port: {{ .Values.service.port }} + targetPort: {{ .Values.service.targetPort }} diff --git a/helm/hello-svc/templates/servicemonitor.yaml b/helm/hello-svc/templates/servicemonitor.yaml new file mode 100644 index 0000000..344d082 --- /dev/null +++ b/helm/hello-svc/templates/servicemonitor.yaml @@ -0,0 +1,16 @@ +{{- if .Values.serviceMonitor.enabled }} +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: {{ include "hello-svc.fullname" . }} + labels: + {{- include "hello-svc.labels" . | nindent 4 }} +spec: + selector: + matchLabels: + {{- include "hello-svc.selectorLabels" . | nindent 6 }} + endpoints: + - port: {{ .Values.service.port | toString }} + path: /metrics + interval: {{ .Values.serviceMonitor.interval }} +{{- end }} diff --git a/helm/hello-svc/values.yaml b/helm/hello-svc/values.yaml new file mode 100644 index 0000000..e244849 --- /dev/null +++ b/helm/hello-svc/values.yaml @@ -0,0 +1,28 @@ +replicaCount: 1 + +image: + repository: git.samidare.dev/rod/hello-svc + pullPolicy: Always + tag: "latest" + +env: + APP_ENV: production + LOG_LEVEL: info + APP_VERSION: unknown + +service: + type: ClusterIP + port: 80 + targetPort: 8080 + +resources: + requests: + cpu: 100m + memory: 64Mi + limits: + cpu: 500m + memory: 128Mi + +serviceMonitor: + enabled: true + interval: 30s