From d9a32e3bc3623b404e96cc7ac0472e2af9abe143 Mon Sep 17 00:00:00 2001 From: dvirlabs Date: Tue, 24 Mar 2026 10:31:01 +0200 Subject: [PATCH] Update oramap --- charts/oramap-chart-old/.helmignore | 23 +++ charts/oramap-chart-old/Chart.yaml | 24 +++ .../oramap-chart-old/templates/_helpers.tpl | 11 ++ .../templates/deployment.yaml | 42 +++++ .../oramap-chart-old/templates/ingress.yaml | 33 ++++ .../oramap-chart-old/templates/service.yaml | 19 ++ charts/oramap-chart-old/values.yaml | 24 +++ charts/oramap-chart/Chart.yaml | 23 +-- charts/oramap-chart/README.md | 169 ++++++++++++++++++ charts/oramap-chart/templates/configmap.yaml | 45 +++++ charts/oramap-chart/templates/deployment.yaml | 93 ++++++++-- charts/oramap-chart/templates/ingress.yaml | 4 +- charts/oramap-chart/templates/service.yaml | 37 +++- charts/oramap-chart/values.yaml | 44 ++++- manifests/oramap/values.yaml | 51 ++++-- 15 files changed, 584 insertions(+), 58 deletions(-) create mode 100644 charts/oramap-chart-old/.helmignore create mode 100644 charts/oramap-chart-old/Chart.yaml create mode 100644 charts/oramap-chart-old/templates/_helpers.tpl create mode 100644 charts/oramap-chart-old/templates/deployment.yaml create mode 100644 charts/oramap-chart-old/templates/ingress.yaml create mode 100644 charts/oramap-chart-old/templates/service.yaml create mode 100644 charts/oramap-chart-old/values.yaml create mode 100644 charts/oramap-chart/README.md create mode 100644 charts/oramap-chart/templates/configmap.yaml diff --git a/charts/oramap-chart-old/.helmignore b/charts/oramap-chart-old/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/charts/oramap-chart-old/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/charts/oramap-chart-old/Chart.yaml b/charts/oramap-chart-old/Chart.yaml new file mode 100644 index 0000000..c7a98b5 --- /dev/null +++ b/charts/oramap-chart-old/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: oramap +description: A Helm chart for Kubernetes + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +# Versions are expected to follow Semantic Versioning (https://semver.org/) +version: 0.1.0 + +# This is the version number of the application being deployed. This version number should be +# 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" diff --git a/charts/oramap-chart-old/templates/_helpers.tpl b/charts/oramap-chart-old/templates/_helpers.tpl new file mode 100644 index 0000000..1767bb5 --- /dev/null +++ b/charts/oramap-chart-old/templates/_helpers.tpl @@ -0,0 +1,11 @@ +{{- define "oramap.name" -}} +{{ .Chart.Name }} +{{- end }} + +{{- define "oramap.fullname" -}} +{{ include "oramap.name" . }}-{{ .Release.Name }} +{{- end }} + +{{- define "oramap.chart" -}} +{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} +{{- end }} \ No newline at end of file diff --git a/charts/oramap-chart-old/templates/deployment.yaml b/charts/oramap-chart-old/templates/deployment.yaml new file mode 100644 index 0000000..6db6c8d --- /dev/null +++ b/charts/oramap-chart-old/templates/deployment.yaml @@ -0,0 +1,42 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "oramap.fullname" . }} + labels: + app: {{ include "oramap.name" . }} + chart: {{ include "oramap.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + app: {{ include "oramap.name" . }} + release: {{ .Release.Name }} + template: + metadata: + labels: + app: {{ include "oramap.name" . }} + release: {{ .Release.Name }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - containerPort: {{ .Values.containerPort }} + name: http + livenessProbe: + httpGet: + path: / + port: http + readinessProbe: + httpGet: + path: / + port: http + resources: + {{- toYaml .Values.resources | nindent 12 }} diff --git a/charts/oramap-chart-old/templates/ingress.yaml b/charts/oramap-chart-old/templates/ingress.yaml new file mode 100644 index 0000000..04dabe8 --- /dev/null +++ b/charts/oramap-chart-old/templates/ingress.yaml @@ -0,0 +1,33 @@ +{{- if .Values.ingress.enabled }} +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ include "oramap.fullname" . }} + annotations: + {{- if .Values.ingress.className }} + 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 "oramap.fullname" $ }} + port: + number: {{ $.Values.service.port }} + {{- end }} + {{- end }} + {{- if .Values.ingress.tls }} + tls: + {{- toYaml .Values.ingress.tls | nindent 4 }} + {{- end }} +{{- end }} diff --git a/charts/oramap-chart-old/templates/service.yaml b/charts/oramap-chart-old/templates/service.yaml new file mode 100644 index 0000000..da296c8 --- /dev/null +++ b/charts/oramap-chart-old/templates/service.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "oramap.fullname" . }} + labels: + app: {{ include "oramap.name" . }} + chart: {{ include "oramap.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: {{ .Values.containerPort }} + protocol: TCP + name: http + selector: + app: {{ include "oramap.name" . }} + release: {{ .Release.Name }} diff --git a/charts/oramap-chart-old/values.yaml b/charts/oramap-chart-old/values.yaml new file mode 100644 index 0000000..afafa2c --- /dev/null +++ b/charts/oramap-chart-old/values.yaml @@ -0,0 +1,24 @@ +replicaCount: 1 + +imagePullSecrets: [] + +image: + repository: harbor.dvirlabs.com/shay/oramap + tag: "1" + pullPolicy: IfNotPresent + +containerPort: 3000 + +service: + type: ClusterIP + port: 80 + +ingress: + enabled: true + className: "traefik" + hosts: + - host: oramap.dvirlabs.com + paths: + - path: / + pathType: Prefix + tls: [] diff --git a/charts/oramap-chart/Chart.yaml b/charts/oramap-chart/Chart.yaml index c7a98b5..8e91c0a 100644 --- a/charts/oramap-chart/Chart.yaml +++ b/charts/oramap-chart/Chart.yaml @@ -1,24 +1,11 @@ apiVersion: v2 name: oramap -description: A Helm chart for Kubernetes +description: Ora Map - Family Location Mapping Application (Microservices Architecture) -# A chart can be either an 'application' or a 'library' chart. -# -# Application charts are a collection of templates that can be packaged into versioned archives -# to be deployed. -# -# Library charts provide useful utilities or functions for the chart developer. They're included as -# a dependency of application charts to inject those utilities and functions into the rendering -# pipeline. Library charts do not define any templates and therefore cannot be deployed. type: application -# This is the chart version. This version number should be incremented each time you make changes -# to the chart and its templates, including the app version. -# Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.1.0 +# Chart version +version: 0.2.0 -# This is the version number of the application being deployed. This version number should be -# 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" +# Application version +appVersion: "1.0.0" diff --git a/charts/oramap-chart/README.md b/charts/oramap-chart/README.md new file mode 100644 index 0000000..7693ff5 --- /dev/null +++ b/charts/oramap-chart/README.md @@ -0,0 +1,169 @@ +# Ora Map Helm Chart + +Helm chart for deploying Ora Map application in Kubernetes with microservices architecture. + +## Architecture + +This chart deploys two main components: + +- **Backend**: Node.js Express API server (Port 3000) +- **Frontend**: Nginx serving static files (Port 80) + +## Installation + +### Prerequisites + +- Kubernetes cluster 1.19+ +- Helm 3.0+ +- Docker images built and pushed to Harbor registry + +### Install Chart + +```bash +# From the repository root +helm install oramap ./oramap + +# Or with custom values +helm install oramap ./oramap -f custom-values.yaml + +# Install in a specific namespace +helm install oramap ./oramap -n my-namespace --create-namespace +``` + +### Upgrade Chart + +```bash +helm upgrade oramap ./oramap +``` + +### Uninstall Chart + +```bash +helm uninstall oramap +``` + +## Configuration + +The following table lists the configurable parameters and their default values: + +| Parameter | Description | Default | +|-----------|-------------|---------| +| `backend.image.repository` | Backend image repository | `harbor.dvirlabs.com/my-apps/oramap-backend` | +| `backend.image.tag` | Backend image tag | `latest` | +| `backend.replicaCount` | Number of backend replicas | `1` | +| `backend.containerPort` | Backend container port | `3000` | +| `backend.resources.limits.cpu` | Backend CPU limit | `500m` | +| `backend.resources.limits.memory` | Backend memory limit | `512Mi` | +| `frontend.image.repository` | Frontend image repository | `harbor.dvirlabs.com/my-apps/oramap-frontend` | +| `frontend.image.tag` | Frontend image tag | `latest` | +| `frontend.replicaCount` | Number of frontend replicas | `1` | +| `frontend.containerPort` | Frontend container port | `80` | +| `service.type` | Kubernetes service type | `ClusterIP` | +| `ingress.enabled` | Enable ingress | `true` | +| `ingress.className` | Ingress class name | `traefik` | +| `ingress.hosts[0].host` | Ingress hostname | `oramap.dvirlabs.com` | + +### Example Custom Values + +```yaml +# custom-values.yaml +backend: + image: + tag: "v1.0.0" + replicaCount: 3 + +frontend: + image: + tag: "v1.0.0" + replicaCount: 2 + +ingress: + hosts: + - host: oramap.example.com + paths: + - path: / + pathType: Prefix + tls: + - secretName: oramap-tls + hosts: + - oramap.example.com +``` + +## Deployment Components + +### Backend Deployment + +- Runs Express.js API server +- Health checks on `/api/health` +- Configurable resources and replicas + +### Frontend Deployment + +- Runs Nginx serving static files +- Proxies `/api/*` requests to backend service +- Uses ConfigMap for nginx configuration +- Health checks on `/` + +### Services + +- **Backend Service**: Internal ClusterIP service on port 3000 +- **Frontend Service**: ClusterIP service on port 80 (exposed via Ingress) + +### Ingress + +- Routes external traffic to frontend service +- TLS/SSL termination support +- Configurable hostname and paths + +## CI/CD Integration + +The Woodpecker CI pipeline automatically: + +1. Builds backend and frontend Docker images +2. Tags with branch name and commit SHA +3. Pushes to Harbor registry +4. Updates this chart's values in the GitOps repository + +## Accessing the Application + +After installation, the application will be available at: + +- **External**: https://oramap.dvirlabs.com (via Ingress) +- **Internal Backend API**: http://oramap-backend:3000 +- **Internal Frontend**: http://oramap-frontend:80 + +## Troubleshooting + +### Check Pod Status + +```bash +kubectl get pods -l release=oramap +``` + +### View Logs + +```bash +# Backend logs +kubectl logs -l app=oramap-backend + +# Frontend logs +kubectl logs -l app=oramap-frontend +``` + +### Check Services + +```bash +kubectl get svc -l release=oramap +``` + +### Test Backend Health + +```bash +kubectl port-forward svc/oramap-backend 3000:3000 +curl http://localhost:3000/api/health +``` + +## Version History + +- **0.2.0**: Microservices architecture with separate backend and frontend +- **0.1.0**: Initial monolithic deployment diff --git a/charts/oramap-chart/templates/configmap.yaml b/charts/oramap-chart/templates/configmap.yaml new file mode 100644 index 0000000..ce380bc --- /dev/null +++ b/charts/oramap-chart/templates/configmap.yaml @@ -0,0 +1,45 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ include "oramap.fullname" . }}-nginx-config + labels: + app: {{ include "oramap.name" . }}-frontend + chart: {{ include "oramap.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +data: + default.conf: | + server { + listen 80; + server_name _; + root /usr/share/nginx/html; + index index.html; + + # Gzip compression + gzip on; + gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript; + + # Main location + location / { + try_files $uri $uri/ /index.html; + } + + # API proxy to backend service in Kubernetes + location /api/ { + proxy_pass http://{{ include "oramap.fullname" . }}-backend:{{ .Values.service.backend.port }}; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection 'upgrade'; + proxy_set_header Host $host; + proxy_cache_bypass $http_upgrade; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + # Cache static assets + location ~* \.(jpg|jpeg|png|gif|ico|css|js|svg)$ { + expires 1y; + add_header Cache-Control "public, immutable"; + } + } diff --git a/charts/oramap-chart/templates/deployment.yaml b/charts/oramap-chart/templates/deployment.yaml index 6db6c8d..d8ee38a 100644 --- a/charts/oramap-chart/templates/deployment.yaml +++ b/charts/oramap-chart/templates/deployment.yaml @@ -1,42 +1,107 @@ +--- +# Backend Deployment apiVersion: apps/v1 kind: Deployment metadata: - name: {{ include "oramap.fullname" . }} + name: {{ include "oramap.fullname" . }}-backend labels: - app: {{ include "oramap.name" . }} + app: {{ include "oramap.name" . }}-backend chart: {{ include "oramap.chart" . }} release: {{ .Release.Name }} heritage: {{ .Release.Service }} + component: backend spec: - replicas: {{ .Values.replicaCount }} + replicas: {{ .Values.backend.replicaCount }} selector: matchLabels: - app: {{ include "oramap.name" . }} + app: {{ include "oramap.name" . }}-backend release: {{ .Release.Name }} + component: backend template: metadata: labels: - app: {{ include "oramap.name" . }} + app: {{ include "oramap.name" . }}-backend release: {{ .Release.Name }} + component: backend spec: - {{- with .Values.imagePullSecrets }} - imagePullSecrets: - {{- toYaml . | nindent 8 }} - {{- end }} containers: - - name: {{ .Chart.Name }} - image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" - imagePullPolicy: {{ .Values.image.pullPolicy }} + - name: backend + image: "{{ .Values.backend.image.repository }}:{{ .Values.backend.image.tag }}" + imagePullPolicy: {{ .Values.backend.image.pullPolicy }} ports: - - containerPort: {{ .Values.containerPort }} + - containerPort: {{ .Values.backend.containerPort }} name: http + env: + - name: NODE_ENV + value: "production" + - name: PORT + value: "{{ .Values.backend.containerPort }}" + livenessProbe: + httpGet: + path: /api/health + port: http + initialDelaySeconds: 10 + periodSeconds: 30 + readinessProbe: + httpGet: + path: /api/health + port: http + initialDelaySeconds: 5 + periodSeconds: 10 + resources: + {{- toYaml .Values.backend.resources | nindent 12 }} +--- +# Frontend Deployment +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "oramap.fullname" . }}-frontend + labels: + app: {{ include "oramap.name" . }}-frontend + chart: {{ include "oramap.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} + component: frontend +spec: + replicas: {{ .Values.frontend.replicaCount }} + selector: + matchLabels: + app: {{ include "oramap.name" . }}-frontend + release: {{ .Release.Name }} + component: frontend + template: + metadata: + labels: + app: {{ include "oramap.name" . }}-frontend + release: {{ .Release.Name }} + component: frontend + spec: + containers: + - name: frontend + image: "{{ .Values.frontend.image.repository }}:{{ .Values.frontend.image.tag }}" + imagePullPolicy: {{ .Values.frontend.image.pullPolicy }} + ports: + - containerPort: {{ .Values.frontend.containerPort }} + name: http + volumeMounts: + - name: nginx-config + mountPath: /etc/nginx/conf.d/default.conf + subPath: default.conf livenessProbe: httpGet: path: / port: http + initialDelaySeconds: 10 + periodSeconds: 30 readinessProbe: httpGet: path: / port: http + initialDelaySeconds: 5 + periodSeconds: 10 resources: - {{- toYaml .Values.resources | nindent 12 }} + {{- toYaml .Values.frontend.resources | nindent 12 }} + volumes: + - name: nginx-config + configMap: + name: {{ include "oramap.fullname" . }}-nginx-config diff --git a/charts/oramap-chart/templates/ingress.yaml b/charts/oramap-chart/templates/ingress.yaml index 04dabe8..47ad0d8 100644 --- a/charts/oramap-chart/templates/ingress.yaml +++ b/charts/oramap-chart/templates/ingress.yaml @@ -21,9 +21,9 @@ spec: pathType: {{ .pathType }} backend: service: - name: {{ include "oramap.fullname" $ }} + name: {{ include "oramap.fullname" $ }}-frontend port: - number: {{ $.Values.service.port }} + number: {{ $.Values.service.frontend.port }} {{- end }} {{- end }} {{- if .Values.ingress.tls }} diff --git a/charts/oramap-chart/templates/service.yaml b/charts/oramap-chart/templates/service.yaml index da296c8..f6da8d6 100644 --- a/charts/oramap-chart/templates/service.yaml +++ b/charts/oramap-chart/templates/service.yaml @@ -1,19 +1,46 @@ +--- +# Backend Service apiVersion: v1 kind: Service metadata: - name: {{ include "oramap.fullname" . }} + name: {{ include "oramap.fullname" . }}-backend labels: - app: {{ include "oramap.name" . }} + app: {{ include "oramap.name" . }}-backend chart: {{ include "oramap.chart" . }} release: {{ .Release.Name }} heritage: {{ .Release.Service }} + component: backend spec: type: {{ .Values.service.type }} ports: - - port: {{ .Values.service.port }} - targetPort: {{ .Values.containerPort }} + - port: {{ .Values.service.backend.port }} + targetPort: {{ .Values.service.backend.targetPort }} protocol: TCP name: http selector: - app: {{ include "oramap.name" . }} + app: {{ include "oramap.name" . }}-backend release: {{ .Release.Name }} + component: backend +--- +# Frontend Service +apiVersion: v1 +kind: Service +metadata: + name: {{ include "oramap.fullname" . }}-frontend + labels: + app: {{ include "oramap.name" . }}-frontend + chart: {{ include "oramap.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} + component: frontend +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.frontend.port }} + targetPort: {{ .Values.service.frontend.targetPort }} + protocol: TCP + name: http + selector: + app: {{ include "oramap.name" . }}-frontend + release: {{ .Release.Name }} + component: frontend diff --git a/charts/oramap-chart/values.yaml b/charts/oramap-chart/values.yaml index afafa2c..a171e88 100644 --- a/charts/oramap-chart/values.yaml +++ b/charts/oramap-chart/values.yaml @@ -1,17 +1,45 @@ replicaCount: 1 -imagePullSecrets: [] +# Backend API configuration +backend: + image: + repository: harbor.dvirlabs.com/my-apps/oramap-backend + tag: "latest" + pullPolicy: IfNotPresent + containerPort: 3000 + replicaCount: 1 + resources: + limits: + cpu: 500m + memory: 512Mi + requests: + cpu: 100m + memory: 128Mi -image: - repository: harbor.dvirlabs.com/shay/oramap - tag: "1" - pullPolicy: IfNotPresent - -containerPort: 3000 +# Frontend Nginx configuration +frontend: + image: + repository: harbor.dvirlabs.com/my-apps/oramap-frontend + tag: "latest" + pullPolicy: IfNotPresent + containerPort: 80 + replicaCount: 1 + resources: + limits: + cpu: 200m + memory: 256Mi + requests: + cpu: 50m + memory: 64Mi service: type: ClusterIP - port: 80 + backend: + port: 3000 + targetPort: 3000 + frontend: + port: 80 + targetPort: 80 ingress: enabled: true diff --git a/manifests/oramap/values.yaml b/manifests/oramap/values.yaml index e448a5b..a171e88 100644 --- a/manifests/oramap/values.yaml +++ b/manifests/oramap/values.yaml @@ -1,14 +1,46 @@ -imagePullSecrets: - - name: harbor-regcred replicaCount: 1 -image: - repository: harbor.dvirlabs.com/shay/oramap - tag: "3" - pullPolicy: IfNotPresent -containerPort: 3000 + +# Backend API configuration +backend: + image: + repository: harbor.dvirlabs.com/my-apps/oramap-backend + tag: "latest" + pullPolicy: IfNotPresent + containerPort: 3000 + replicaCount: 1 + resources: + limits: + cpu: 500m + memory: 512Mi + requests: + cpu: 100m + memory: 128Mi + +# Frontend Nginx configuration +frontend: + image: + repository: harbor.dvirlabs.com/my-apps/oramap-frontend + tag: "latest" + pullPolicy: IfNotPresent + containerPort: 80 + replicaCount: 1 + resources: + limits: + cpu: 200m + memory: 256Mi + requests: + cpu: 50m + memory: 64Mi + service: type: ClusterIP - port: 80 + backend: + port: 3000 + targetPort: 3000 + frontend: + port: 80 + targetPort: 80 + ingress: enabled: true className: "traefik" @@ -18,6 +50,3 @@ ingress: - path: / pathType: Prefix tls: [] -backend: - image: - tag: master-fccd8a0