Skip to content

Commit 3a7c86d

Browse files
committed
Allow opensearch deployement, resolving app to storage cluster connection issues still
1 parent dd32cf0 commit 3a7c86d

File tree

7 files changed

+69
-12
lines changed

7 files changed

+69
-12
lines changed

helm-chart/stac-fastapi/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,6 @@ opensearch:
169169
persistence:
170170
enabled: true
171171
size: 100Gi
172-
storageClass: "fast-ssd"
173172
```
174173

175174
#### External Database

helm-chart/stac-fastapi/templates/_helpers.tpl

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,29 @@ Create the database host based on backend selection
6969
{{- .Values.externalDatabase.host }}
7070
{{- else if eq .Values.backend "elasticsearch" }}
7171
{{- if .Values.elasticsearch.enabled }}
72+
{{- if .Values.elasticsearch.masterService }}
73+
{{- .Values.elasticsearch.masterService }}
74+
{{- else if .Values.elasticsearch.fullnameOverride }}
75+
{{- printf "%s-master" .Values.elasticsearch.fullnameOverride }}
76+
{{- else if .Values.elasticsearch.clusterName }}
77+
{{- printf "%s-master" .Values.elasticsearch.clusterName }}
78+
{{- else }}
7279
{{- printf "%s-%s" .Release.Name "elasticsearch-master" }}
80+
{{- end }}
7381
{{- else }}
7482
{{- fail "Elasticsearch is not enabled but backend is set to elasticsearch" }}
7583
{{- end }}
7684
{{- else if eq .Values.backend "opensearch" }}
7785
{{- if .Values.opensearch.enabled }}
86+
{{- if .Values.opensearch.masterService }}
87+
{{- .Values.opensearch.masterService }}
88+
{{- else if .Values.opensearch.fullnameOverride }}
89+
{{- printf "%s-master" .Values.opensearch.fullnameOverride }}
90+
{{- else if .Values.opensearch.clusterName }}
91+
{{- printf "%s-master" .Values.opensearch.clusterName }}
92+
{{- else }}
7893
{{- printf "%s-%s" .Release.Name "opensearch-cluster-master" }}
94+
{{- end }}
7995
{{- else }}
8096
{{- fail "OpenSearch is not enabled but backend is set to opensearch" }}
8197
{{- end }}
@@ -168,4 +184,28 @@ Determine if OpenSearch should be enabled based on backend selection
168184
{{- else }}
169185
{{- false }}
170186
{{- end }}
187+
{{- end }}
188+
189+
{{/*
190+
Determine PodDisruptionBudget apiVersion based on cluster capabilities
191+
*/}}
192+
{{- define "stac-fastapi.pdb.apiVersion" -}}
193+
{{- if semverCompare ">=1.21-0" .Capabilities.KubeVersion.GitVersion }}
194+
policy/v1
195+
{{- else }}
196+
policy/v1beta1
197+
{{- end }}
198+
{{- end }}
199+
200+
{{/*
201+
Determine HorizontalPodAutoscaler apiVersion based on cluster capabilities
202+
*/}}
203+
{{- define "stac-fastapi.hpa.apiVersion" -}}
204+
{{- if .Capabilities.APIVersions.Has "autoscaling/v2" }}
205+
autoscaling/v2
206+
{{- else if .Capabilities.APIVersions.Has "autoscaling/v2beta2" }}
207+
autoscaling/v2beta2
208+
{{- else }}
209+
autoscaling/v2beta1
210+
{{- end }}
171211
{{- end }}

helm-chart/stac-fastapi/templates/hpa.yaml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{{- if .Values.app.autoscaling.enabled }}
2-
apiVersion: autoscaling/v2beta1
2+
{{- $hpaApiVersion := (include "stac-fastapi.hpa.apiVersion" . | trim) }}
3+
apiVersion: {{ $hpaApiVersion }}
34
kind: HorizontalPodAutoscaler
45
metadata:
56
name: {{ include "stac-fastapi.fullname" . }}
@@ -17,12 +18,24 @@ spec:
1718
- type: Resource
1819
resource:
1920
name: cpu
21+
{{- if or (eq $hpaApiVersion "autoscaling/v2") (eq $hpaApiVersion "autoscaling/v2beta2") }}
22+
target:
23+
type: Utilization
24+
averageUtilization: {{ .Values.app.autoscaling.targetCPUUtilizationPercentage }}
25+
{{- else }}
2026
targetAverageUtilization: {{ .Values.app.autoscaling.targetCPUUtilizationPercentage }}
27+
{{- end }}
2128
{{- end }}
2229
{{- if .Values.app.autoscaling.targetMemoryUtilizationPercentage }}
2330
- type: Resource
2431
resource:
2532
name: memory
33+
{{- if or (eq $hpaApiVersion "autoscaling/v2") (eq $hpaApiVersion "autoscaling/v2beta2") }}
34+
target:
35+
type: Utilization
36+
averageUtilization: {{ .Values.app.autoscaling.targetMemoryUtilizationPercentage }}
37+
{{- else }}
2638
targetAverageUtilization: {{ .Values.app.autoscaling.targetMemoryUtilizationPercentage }}
39+
{{- end }}
2740
{{- end }}
2841
{{- end }}

helm-chart/stac-fastapi/templates/poddisruptionbudget.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{{- if .Values.podDisruptionBudget.enabled }}
2-
apiVersion: policy/v1beta1
2+
{{- $pdbApiVersion := (include "stac-fastapi.pdb.apiVersion" . | trim) }}
3+
apiVersion: {{ $pdbApiVersion }}
34
kind: PodDisruptionBudget
45
metadata:
56
name: {{ include "stac-fastapi.fullname" . }}

helm-chart/stac-fastapi/values-elasticsearch.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ elasticsearch:
104104
# Persistent storage
105105
volumeClaimTemplate:
106106
accessModes: ["ReadWriteOnce"]
107-
storageClassName: "fast-ssd" # Use high-performance storage class
107+
# storageClassName: "fast-ssd" # Use high-performance storage class
108108
resources:
109109
requests:
110110
storage: 100Gi

helm-chart/stac-fastapi/values-opensearch.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ opensearch:
7575

7676
# Cluster configuration
7777
clusterName: "stac-opensearch-prod"
78+
masterService: "opensearch-cluster-master"
7879
replicas: 3
7980

8081
# OpenSearch roles for each node
@@ -116,7 +117,7 @@ opensearch:
116117
# Persistent storage
117118
persistence:
118119
enabled: true
119-
storageClass: "fast-ssd" # Use high-performance storage class
120+
# storageClass: "fast-ssd" # Use high-performance storage class
120121
accessModes:
121122
- ReadWriteOnce
122123
size: 100Gi

helm-chart/stac-fastapi/values.yaml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,13 @@ app:
8181
# - stac-fastapi.local
8282

8383
# Resource limits and requests
84-
resources: {}
85-
# limits:
86-
# cpu: 100m
87-
# memory: 128Mi
88-
# requests:
89-
# cpu: 100m
90-
# memory: 128Mi
84+
resources:
85+
requests:
86+
cpu: 250m
87+
memory: 512Mi
88+
limits:
89+
cpu: 1000m
90+
memory: 1Gi
9191

9292
# Horizontal Pod Autoscaler
9393
autoscaling:
@@ -245,6 +245,9 @@ opensearch:
245245
# OpenSearch cluster name
246246
clusterName: "stac-opensearch"
247247

248+
# Service name used to expose the master nodes
249+
masterService: "opensearch-cluster-master"
250+
248251
# Node group configuration
249252
nodeGroup: "master"
250253

0 commit comments

Comments
 (0)