From 5daa782f0c1ac6abd295568575f6a9171940951f Mon Sep 17 00:00:00 2001 From: dvirlabs Date: Mon, 13 Apr 2026 00:21:58 +0300 Subject: [PATCH] Add errorlab app --- argocd-apps/errorlab.yaml | 21 +++++ charts/errorlab-chart/Chart.yaml | 15 ++++ charts/errorlab-chart/templates/_helpers.tpl | 49 +++++++++++ .../errorlab-chart/templates/deployment.yaml | 59 +++++++++++++ charts/errorlab-chart/templates/hpa.yaml | 22 +++++ charts/errorlab-chart/templates/ingress.yaml | 35 ++++++++ charts/errorlab-chart/templates/service.yaml | 15 ++++ charts/errorlab-chart/values.yaml | 87 +++++++++++++++++++ manifests/errorlab/values.yaml | 87 +++++++++++++++++++ 9 files changed, 390 insertions(+) create mode 100644 argocd-apps/errorlab.yaml create mode 100644 charts/errorlab-chart/Chart.yaml create mode 100644 charts/errorlab-chart/templates/_helpers.tpl create mode 100644 charts/errorlab-chart/templates/deployment.yaml create mode 100644 charts/errorlab-chart/templates/hpa.yaml create mode 100644 charts/errorlab-chart/templates/ingress.yaml create mode 100644 charts/errorlab-chart/templates/service.yaml create mode 100644 charts/errorlab-chart/values.yaml create mode 100644 manifests/errorlab/values.yaml diff --git a/argocd-apps/errorlab.yaml b/argocd-apps/errorlab.yaml new file mode 100644 index 0000000..9abe714 --- /dev/null +++ b/argocd-apps/errorlab.yaml @@ -0,0 +1,21 @@ +apiVersion: argoproj.io/v1alpha1 +kind: Application +metadata: + name: errorlab + namespace: argocd +spec: + project: my-apps + source: + repoURL: ssh://git@gitea-ssh.dev-tools.svc.cluster.local:2222/dvirlabs/my-apps.git + targetRevision: HEAD + path: charts/calink-chart + helm: + valueFiles: + - ../../manifests/errorlab/values.yaml + destination: + server: https://kubernetes.default.svc + namespace: my-apps + syncPolicy: + automated: + prune: true + selfHeal: true diff --git a/charts/errorlab-chart/Chart.yaml b/charts/errorlab-chart/Chart.yaml new file mode 100644 index 0000000..d7a3cdd --- /dev/null +++ b/charts/errorlab-chart/Chart.yaml @@ -0,0 +1,15 @@ +apiVersion: v2 +name: errorlab +description: Custom public error and landing pages for the home lab +type: application +version: 0.1.0 +appVersion: "1.0.0" +keywords: + - errorlab + - '404' + - homelab + - devops +home: "" +sources: [] +maintainers: + - name: dvirl diff --git a/charts/errorlab-chart/templates/_helpers.tpl b/charts/errorlab-chart/templates/_helpers.tpl new file mode 100644 index 0000000..618be17 --- /dev/null +++ b/charts/errorlab-chart/templates/_helpers.tpl @@ -0,0 +1,49 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "errorlab.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +*/}} +{{- define "errorlab.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart label (name + version). +*/}} +{{- define "errorlab.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels applied to every resource. +*/}} +{{- define "errorlab.labels" -}} +helm.sh/chart: {{ include "errorlab.chart" . }} +{{ include "errorlab.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels (used in spec.selector.matchLabels and pod template labels). +*/}} +{{- define "errorlab.selectorLabels" -}} +app.kubernetes.io/name: {{ include "errorlab.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} diff --git a/charts/errorlab-chart/templates/deployment.yaml b/charts/errorlab-chart/templates/deployment.yaml new file mode 100644 index 0000000..8b14f0f --- /dev/null +++ b/charts/errorlab-chart/templates/deployment.yaml @@ -0,0 +1,59 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "errorlab.fullname" . }} + labels: + {{- include "errorlab.labels" . | nindent 4 }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "errorlab.selectorLabels" . | nindent 6 }} + template: + metadata: + annotations: + {{- with .Values.podAnnotations }} + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "errorlab.selectorLabels" . | nindent 8 }} + {{- with .Values.podLabels }} + {{- toYaml . | nindent 8 }} + {{- end }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - name: http + containerPort: 80 + protocol: TCP + livenessProbe: + {{- toYaml .Values.livenessProbe | nindent 12 }} + readinessProbe: + {{- toYaml .Values.readinessProbe | nindent 12 }} + resources: + {{- toYaml .Values.resources | nindent 12 }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/charts/errorlab-chart/templates/hpa.yaml b/charts/errorlab-chart/templates/hpa.yaml new file mode 100644 index 0000000..995f2af --- /dev/null +++ b/charts/errorlab-chart/templates/hpa.yaml @@ -0,0 +1,22 @@ +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "errorlab.fullname" . }} + labels: + {{- include "errorlab.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "errorlab.fullname" . }} + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} +{{- end }} diff --git a/charts/errorlab-chart/templates/ingress.yaml b/charts/errorlab-chart/templates/ingress.yaml new file mode 100644 index 0000000..6a91791 --- /dev/null +++ b/charts/errorlab-chart/templates/ingress.yaml @@ -0,0 +1,35 @@ +{{- if .Values.ingress.enabled -}} +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ include "errorlab.fullname" . }} + labels: + {{- include "errorlab.labels" . | nindent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if .Values.ingress.className }} + ingressClassName: {{ .Values.ingress.className }} + {{- end }} + {{- if .Values.ingress.tls }} + tls: + {{- toYaml .Values.ingress.tls | nindent 4 }} + {{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ .path }} + pathType: {{ .pathType }} + backend: + service: + name: {{ include "errorlab.fullname" $ }} + port: + name: http + {{- end }} + {{- end }} +{{- end }} diff --git a/charts/errorlab-chart/templates/service.yaml b/charts/errorlab-chart/templates/service.yaml new file mode 100644 index 0000000..d89930d --- /dev/null +++ b/charts/errorlab-chart/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "errorlab.fullname" . }} + labels: + {{- include "errorlab.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "errorlab.selectorLabels" . | nindent 4 }} diff --git a/charts/errorlab-chart/values.yaml b/charts/errorlab-chart/values.yaml new file mode 100644 index 0000000..066d180 --- /dev/null +++ b/charts/errorlab-chart/values.yaml @@ -0,0 +1,87 @@ +# ── Replica count ───────────────────────────────────────────────────────────── +replicaCount: 1 + +# ── Image ───────────────────────────────────────────────────────────────────── +image: + repository: errorlab # override with your registry, e.g. ghcr.io/dvirl/errorlab + tag: latest + pullPolicy: IfNotPresent + +imagePullSecrets: [] + +# ── Service ─────────────────────────────────────────────────────────────────── +service: + type: ClusterIP + port: 80 + +# ── Ingress ─────────────────────────────────────────────────────────────────── +ingress: + enabled: true + className: nginx # set to your ingress class (e.g. "nginx", "traefik") + annotations: {} + # cert-manager.io/cluster-issuer: letsencrypt-prod + # nginx.ingress.kubernetes.io/force-ssl-redirect: "true" + hosts: + - host: errorlab.lab # replace with your actual hostname + paths: + - path: / + pathType: Prefix + tls: [] + # - secretName: errorlab-tls + # hosts: + # - errorlab.lab + +# ── Resources ───────────────────────────────────────────────────────────────── +resources: + requests: + cpu: 10m + memory: 32Mi + limits: + cpu: 100m + memory: 64Mi + +# ── Pod settings ────────────────────────────────────────────────────────────── +podAnnotations: {} +podLabels: {} + +podSecurityContext: + runAsNonRoot: true + runAsUser: 101 # nginx user in nginx:alpine + fsGroup: 101 + +securityContext: + allowPrivilegeEscalation: false + readOnlyRootFilesystem: false # nginx needs to write to /var/cache/nginx + capabilities: + drop: + - ALL + +# ── Probes ──────────────────────────────────────────────────────────────────── +livenessProbe: + httpGet: + path: / + port: http + initialDelaySeconds: 5 + periodSeconds: 20 + +readinessProbe: + httpGet: + path: / + port: http + initialDelaySeconds: 3 + periodSeconds: 10 + +# ── Autoscaling (disabled by default for a static site) ─────────────────────── +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 3 + targetCPUUtilizationPercentage: 80 + +# ── Misc ────────────────────────────────────────────────────────────────────── +nameOverride: "" +fullnameOverride: "" + +nodeSelector: {} +tolerations: [] +affinity: {} diff --git a/manifests/errorlab/values.yaml b/manifests/errorlab/values.yaml new file mode 100644 index 0000000..066d180 --- /dev/null +++ b/manifests/errorlab/values.yaml @@ -0,0 +1,87 @@ +# ── Replica count ───────────────────────────────────────────────────────────── +replicaCount: 1 + +# ── Image ───────────────────────────────────────────────────────────────────── +image: + repository: errorlab # override with your registry, e.g. ghcr.io/dvirl/errorlab + tag: latest + pullPolicy: IfNotPresent + +imagePullSecrets: [] + +# ── Service ─────────────────────────────────────────────────────────────────── +service: + type: ClusterIP + port: 80 + +# ── Ingress ─────────────────────────────────────────────────────────────────── +ingress: + enabled: true + className: nginx # set to your ingress class (e.g. "nginx", "traefik") + annotations: {} + # cert-manager.io/cluster-issuer: letsencrypt-prod + # nginx.ingress.kubernetes.io/force-ssl-redirect: "true" + hosts: + - host: errorlab.lab # replace with your actual hostname + paths: + - path: / + pathType: Prefix + tls: [] + # - secretName: errorlab-tls + # hosts: + # - errorlab.lab + +# ── Resources ───────────────────────────────────────────────────────────────── +resources: + requests: + cpu: 10m + memory: 32Mi + limits: + cpu: 100m + memory: 64Mi + +# ── Pod settings ────────────────────────────────────────────────────────────── +podAnnotations: {} +podLabels: {} + +podSecurityContext: + runAsNonRoot: true + runAsUser: 101 # nginx user in nginx:alpine + fsGroup: 101 + +securityContext: + allowPrivilegeEscalation: false + readOnlyRootFilesystem: false # nginx needs to write to /var/cache/nginx + capabilities: + drop: + - ALL + +# ── Probes ──────────────────────────────────────────────────────────────────── +livenessProbe: + httpGet: + path: / + port: http + initialDelaySeconds: 5 + periodSeconds: 20 + +readinessProbe: + httpGet: + path: / + port: http + initialDelaySeconds: 3 + periodSeconds: 10 + +# ── Autoscaling (disabled by default for a static site) ─────────────────────── +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 3 + targetCPUUtilizationPercentage: 80 + +# ── Misc ────────────────────────────────────────────────────────────────────── +nameOverride: "" +fullnameOverride: "" + +nodeSelector: {} +tolerations: [] +affinity: {}