Skip to content

Commit f13e4f3

Browse files
committed
Temporarily patch stac-auth-proxy chart until PR comes in.
1 parent baa26db commit f13e4f3

File tree

2 files changed

+88
-0
lines changed

2 files changed

+88
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{{- if index .Values "stac-auth-proxy" "enabled" }}
2+
{{- if index .Values "stac-auth-proxy" "initContainers" }}
3+
---
4+
apiVersion: rbac.authorization.k8s.io/v1
5+
kind: Role
6+
metadata:
7+
name: {{ .Release.Name }}-stac-auth-proxy-patch
8+
namespace: {{ .Release.Namespace }}
9+
labels:
10+
{{- include "eoapi.labels" . | nindent 4 }}
11+
rules:
12+
- apiGroups: ["apps"]
13+
resources: ["deployments"]
14+
verbs: ["get", "patch"]
15+
resourceNames:
16+
- {{ .Release.Name }}-stac-auth-proxy
17+
---
18+
apiVersion: rbac.authorization.k8s.io/v1
19+
kind: RoleBinding
20+
metadata:
21+
name: {{ .Release.Name }}-stac-auth-proxy-patch
22+
namespace: {{ .Release.Namespace }}
23+
labels:
24+
{{- include "eoapi.labels" . | nindent 4 }}
25+
subjects:
26+
- kind: ServiceAccount
27+
name: {{ include "eoapi.serviceAccountName" . }}
28+
namespace: {{ .Release.Namespace }}
29+
roleRef:
30+
kind: Role
31+
name: {{ .Release.Name }}-stac-auth-proxy-patch
32+
apiGroup: rbac.authorization.k8s.io
33+
{{- end }}
34+
{{- end }}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{{- if index .Values "stac-auth-proxy" "enabled" }}
2+
{{- if index .Values "stac-auth-proxy" "initContainers" }}
3+
# NOTE: This hook patches the stac-auth-proxy deployment to add initContainers.
4+
# Since Helm hooks run AFTER all resources (including subcharts) are installed,
5+
# the deployment will start once without initContainers, then be patched and rolled out.
6+
# This is a temporary workaround until upstream stac-auth-proxy chart adds native initContainers support.
7+
apiVersion: batch/v1
8+
kind: Job
9+
metadata:
10+
name: {{ .Release.Name }}-stac-auth-proxy-patch
11+
namespace: {{ .Release.Namespace }}
12+
labels:
13+
{{- include "eoapi.labels" . | nindent 4 }}
14+
annotations:
15+
helm.sh/hook: "post-install,post-upgrade"
16+
helm.sh/hook-weight: "5"
17+
helm.sh/hook-delete-policy: "before-hook-creation,hook-succeeded"
18+
spec:
19+
template:
20+
metadata:
21+
labels:
22+
{{- include "eoapi.labels" . | nindent 8 }}
23+
spec:
24+
restartPolicy: Never
25+
serviceAccountName: {{ include "eoapi.serviceAccountName" . }}
26+
containers:
27+
- name: patch-deployment
28+
image: bitnami/kubectl:latest
29+
imagePullPolicy: IfNotPresent
30+
command:
31+
- /bin/bash
32+
- -c
33+
- |
34+
set -e
35+
DEPLOYMENT_NAME="{{ .Release.Name }}-stac-auth-proxy"
36+
NAMESPACE="{{ .Release.Namespace }}"
37+
echo "Waiting for deployment $DEPLOYMENT_NAME..."
38+
for i in {1..30}; do
39+
kubectl get deployment "$DEPLOYMENT_NAME" -n "$NAMESPACE" &>/dev/null && break
40+
sleep 2
41+
done
42+
EXISTING_INIT=$(kubectl get deployment "$DEPLOYMENT_NAME" -n "$NAMESPACE" -o jsonpath='{.spec.template.spec.initContainers}' 2>/dev/null || echo "")
43+
if [ -n "$EXISTING_INIT" ] && [ "$EXISTING_INIT" != "null" ]; then
44+
echo "Deployment already has initContainers, skipping"
45+
exit 0
46+
fi
47+
echo "Patching deployment with initContainers..."
48+
INIT_CONTAINERS_JSON='{{ index .Values "stac-auth-proxy" "initContainers" | toJson }}'
49+
kubectl patch deployment "$DEPLOYMENT_NAME" -n "$NAMESPACE" --type='json' -p="[{\"op\":\"add\",\"path\":\"/spec/template/spec/initContainers\",\"value\":$INIT_CONTAINERS_JSON}]"
50+
echo "Waiting for rollout..."
51+
kubectl rollout status deployment/"$DEPLOYMENT_NAME" -n "$NAMESPACE" --timeout=300s
52+
backoffLimit: 2
53+
{{- end }}
54+
{{- end }}

0 commit comments

Comments
 (0)