add initial chart

This commit is contained in:
Tom Hodson 2024-11-21 13:53:58 +00:00
parent 2f077bd522
commit 5e2e13f200
11 changed files with 228 additions and 0 deletions

23
chart/.helmignore Normal file
View File

@ -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/

24
chart/Chart.yaml Normal file
View File

@ -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"

View File

@ -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 }}

View File

@ -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 }}

View File

@ -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

View File

@ -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

View File

@ -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 }}

View File

@ -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 }}

View File

@ -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 }}

View File

@ -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

25
chart/values.yaml Normal file
View File

@ -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 "