From 5e2e13f20088c90d0c79c795038d9f3316333264 Mon Sep 17 00:00:00 2001 From: Tom Hodson Date: Thu, 21 Nov 2024 13:53:58 +0000 Subject: [PATCH] add initial chart --- chart/.helmignore | 23 +++++++++++++ chart/Chart.yaml | 24 ++++++++++++++ chart/templates/configmap.yaml | 7 ++++ chart/templates/ingress.yaml | 18 ++++++++++ chart/templates/redis-deployment.yaml | 28 ++++++++++++++++ chart/templates/redis-load-data-job.yaml | 33 +++++++++++++++++++ chart/templates/redis-pvc.yaml | 14 ++++++++ chart/templates/redis-service.yaml | 11 +++++++ .../stac-server-deployment.yaml.yaml | 33 +++++++++++++++++++ chart/templates/stac-server-service.yaml | 12 +++++++ chart/values.yaml | 25 ++++++++++++++ 11 files changed, 228 insertions(+) create mode 100644 chart/.helmignore create mode 100644 chart/Chart.yaml create mode 100644 chart/templates/configmap.yaml create mode 100644 chart/templates/ingress.yaml create mode 100644 chart/templates/redis-deployment.yaml create mode 100644 chart/templates/redis-load-data-job.yaml create mode 100644 chart/templates/redis-pvc.yaml create mode 100644 chart/templates/redis-service.yaml create mode 100644 chart/templates/stac-server-deployment.yaml.yaml create mode 100644 chart/templates/stac-server-service.yaml create mode 100644 chart/values.yaml diff --git a/chart/.helmignore b/chart/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/chart/.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/chart/Chart.yaml b/chart/Chart.yaml new file mode 100644 index 0000000..f1b3f41 --- /dev/null +++ b/chart/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: stac-server +description: A Helm chart for the STAC Server with frontend, STAC API and caching service. + +# 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: "0.1.0" diff --git a/chart/templates/configmap.yaml b/chart/templates/configmap.yaml new file mode 100644 index 0000000..f283e5e --- /dev/null +++ b/chart/templates/configmap.yaml @@ -0,0 +1,7 @@ +# apiVersion: v1 +# kind: ConfigMap +# metadata: +# name: redis-init-data +# data: +# compressed_tree.json: |- +# {{ .Files.Get "files/compressed_tree.json" | indent 4 }} \ No newline at end of file diff --git a/chart/templates/ingress.yaml b/chart/templates/ingress.yaml new file mode 100644 index 0000000..7058f6c --- /dev/null +++ b/chart/templates/ingress.yaml @@ -0,0 +1,18 @@ +{{- if .Values.stacServer.ingress.enabled }} +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: stac-server-ingress +spec: + rules: + - host: {{ .Values.stacServer.ingress.hostname }} + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: stac-server + port: + number: {{ .Values.stacServer.servicePort }} +{{- end }} \ No newline at end of file diff --git a/chart/templates/redis-deployment.yaml b/chart/templates/redis-deployment.yaml new file mode 100644 index 0000000..c437d80 --- /dev/null +++ b/chart/templates/redis-deployment.yaml @@ -0,0 +1,28 @@ +# templates/redis-deployment.yaml + +apiVersion: apps/v1 +kind: Deployment +metadata: + name: redis +spec: + selector: + matchLabels: + app: redis + template: + metadata: + labels: + app: redis + spec: + containers: + - name: redis + image: "redis:alpine" + command: ["redis-server", "--appendonly", "yes"] + ports: + - containerPort: {{ .Values.redis.servicePort }} + # volumeMounts: + # - mountPath: /data + # name: redis-data + # volumes: + # - name: redis-data + # persistentVolumeClaim: + # claimName: redis-data diff --git a/chart/templates/redis-load-data-job.yaml b/chart/templates/redis-load-data-job.yaml new file mode 100644 index 0000000..4078c69 --- /dev/null +++ b/chart/templates/redis-load-data-job.yaml @@ -0,0 +1,33 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: redis-load-data + annotations: + "helm.sh/hook": post-install,post-upgrade + "helm.sh/hook-weight": "1" + "helm.sh/hook-delete-policy": before-hook-creation +spec: + template: + spec: + containers: + - name: load-data + image: redis:alpine + command: + - sh + - -c + - | + # Wait for Redis to be ready + until redis-cli -h redis ping | grep PONG; do + echo "Waiting for Redis..."; + sleep 2; + done; + # Load data into Redis + redis-cli -h redis set compressed_catalog "$(cat /data/compressed_tree.json)" + volumeMounts: + - name: redis-init-data + mountPath: /data + volumes: + - name: redis-init-data + configMap: + name: redis-init-data + restartPolicy: OnFailure \ No newline at end of file diff --git a/chart/templates/redis-pvc.yaml b/chart/templates/redis-pvc.yaml new file mode 100644 index 0000000..0b843d4 --- /dev/null +++ b/chart/templates/redis-pvc.yaml @@ -0,0 +1,14 @@ +# templates/redis-pvc.yaml + +{{- if .Values.redis.pvc.enabled }} +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: redis-data +spec: + accessModes: {{ .Values.redis.pvc.accessModes }} + resources: + requests: + storage: {{ .Values.redis.pvc.size }} + storageClassName: {{ .Values.redis.pvc.storageClassName | quote }} +{{- end }} diff --git a/chart/templates/redis-service.yaml b/chart/templates/redis-service.yaml new file mode 100644 index 0000000..c82669a --- /dev/null +++ b/chart/templates/redis-service.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: Service +metadata: + name: redis +spec: + selector: + app: redis + ports: + - protocol: TCP + port: {{ .Values.redis.servicePort }} + targetPort: {{ .Values.redis.servicePort }} diff --git a/chart/templates/stac-server-deployment.yaml.yaml b/chart/templates/stac-server-deployment.yaml.yaml new file mode 100644 index 0000000..5a553c5 --- /dev/null +++ b/chart/templates/stac-server-deployment.yaml.yaml @@ -0,0 +1,33 @@ +# templates/stac-server-deployment.yaml + +apiVersion: apps/v1 +kind: Deployment +metadata: + name: stac-server +spec: + replicas: 1 # Adjust as needed + selector: + matchLabels: + app: stac-server + template: + metadata: + labels: + app: stac-server + spec: + initContainers: + - name: wait-for-redis + image: busybox + command: + [ + 'sh', '-c', + 'until nc -z -v -w30 {{ .Values.stacServer.environment.REDIS_HOST }} {{ .Values.redis.service.port }}; do echo "Waiting for Redis..."; sleep 5; done;' + ] + containers: + - name: stac-server + image: "{{ .Values.stacServer.image.repository }}:{{ .Values.stacServer.image.tag }}" + imagePullPolicy: {{ .Values.stacServer.image.pullPolicy }} + env: + - name: REDIS_HOST + value: "{{ .Values.stacServer.environment.REDIS_HOST }}" + ports: + - containerPort: {{ .Values.stacServer.servicePort }} diff --git a/chart/templates/stac-server-service.yaml b/chart/templates/stac-server-service.yaml new file mode 100644 index 0000000..5503e5a --- /dev/null +++ b/chart/templates/stac-server-service.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: Service +metadata: + name: stac-server +spec: + selector: + app: stac-server + ports: + - protocol: TCP + port: {{ .Values.stacServer.servicePort }} + targetPort: {{ .Values.stacServer.servicePort }} + type: ClusterIP diff --git a/chart/values.yaml b/chart/values.yaml new file mode 100644 index 0000000..1edbecf --- /dev/null +++ b/chart/values.yaml @@ -0,0 +1,25 @@ +# values.yaml + +redis: + servicePort: 6379 + pvc: + enabled: true + storageClassName: "" + accessModes: + - ReadWriteOnce + size: 1Gi + service: + port: 6379 + +# See https://eccr.ecmwf.int/harbor/projects/258/repositories +stacServer: + image: + repository: "eccr.ecmwf.int/stac_server/stac_server" + tag: "latest" + pullPolicy: IfNotPresent + servicePort: 8080 + environment: + REDIS_HOST: "redis" + ingress: + enabled: True + hostname: "stac-server.lumi-vip.apps.dte.destination-earth.eu " \ No newline at end of file