Skip to content

Commit bbef8d6

Browse files
committed
Adding command to install crds for traefik
ref: FORGEOPS-6697
1 parent 2ee8da0 commit bbef8d6

2 files changed

Lines changed: 22 additions & 6 deletions

File tree

bin/commands/prereqs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,18 @@ applyChart() {
8484
local version=$5
8585
local opts=$6
8686
local installed=$7
87+
local crd_cmd=$8
8788
local chart_repo="$chart_name $chart_name --repo $repo"
8889
local msg="$pretty not found. Installing..."
8990

9091
if [[ "$repo" =~ ^oci:// ]] ; then
9192
chart_repo="$chart_name $repo"
9293
fi
9394

95+
if [ -n "$crd_cmd" ] ; then
96+
runOrPrint $crd_cmd
97+
fi
98+
9499
if [ -n "$installed" ] && [ "$UPGRADE" = false ] ; then
95100
echo "$pretty has already been installed."
96101
else
@@ -151,13 +156,16 @@ CM_OPTS="--set crds.enabled=true \
151156
--set webhook.tolerations[0].'effect'='NoSchedule' \
152157
--set webhook.tolerations[0].'operator'='Exists'"
153158

159+
ING_CRD_CMD=""
154160
if [ "$INGRESS" = "traefik" ]; then
155161
ING_PRETTY="Traefik Proxy (Ingress/Gateway API)"
156162
ING_REPO=https://traefik.github.io/charts
157163
ING_CHART_NAME=traefik
158164
ING_NAMESPACE=${TRAEFIK_NAMESPACE:-traefik}
159165
ING_VERSION=${TRAEFIK_VERSION:-}
160166
ING_INSTALLED=$(kubectl get clusterroles -l app.kubernetes.io/name=traefik 2>/dev/null)
167+
ING_CRD_CMD="helm show crds traefik --repo $ING_REPO | kubectl apply --server-side --force-conflicts -f - && \
168+
kubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.5.1/standard-install.yaml"
161169
NGINX_COMPAT_VALUES="\
162170
--set providers.kubernetesIngressNGINX.enabled=true \
163171
--set providers.kubernetesIngressNGINX.ingressClassByName=true \
@@ -264,10 +272,10 @@ for c in ${COMPONENTS[@]} ; do
264272
message "c=${c}" "debug"
265273
case "$c" in
266274
cert-manager)
267-
applyChart "$CM_PRETTY" "$CM_REPO" "$CM_CHART_NAME" "$CM_NAMESPACE" "$CM_VERSION" "$CM_OPTS" "$CM_INSTALLED"
275+
applyChart "$CM_PRETTY" "$CM_REPO" "$CM_CHART_NAME" "$CM_NAMESPACE" "$CM_VERSION" "$CM_OPTS" "$CM_INSTALLED" ""
268276
;;
269277
ingress)
270-
applyChart "$ING_PRETTY" "$ING_REPO" "$ING_CHART_NAME" "$ING_NAMESPACE" "$ING_VERSION" "$ING_OPTS" "$ING_INSTALLED"
278+
applyChart "$ING_PRETTY" "$ING_REPO" "$ING_CHART_NAME" "$ING_NAMESPACE" "$ING_VERSION" "$ING_OPTS" "$ING_INSTALLED" "$ING_CRD_CMD"
271279
if [ "$INGRESS" = "traefik" ]; then
272280
NGINX_CURRENT_CONTROLLER=$(kubectl get ingressclass nginx -o="jsonpath={.spec.controller}" 2>/dev/null || true)
273281
if [ -z "$NGINX_CURRENT_CONTROLLER" ]; then
@@ -278,7 +286,7 @@ for c in ${COMPONENTS[@]} ; do
278286
fi
279287
;;
280288
secrets)
281-
applyChart "$SEC_PRETTY" "$SEC_REPO" "$SEC_CHART_NAME" "$SEC_NAMESPACE" "$SEC_VERSION" "$SEC_OPTS" "$SEC_INSTALLED"
289+
applyChart "$SEC_PRETTY" "$SEC_REPO" "$SEC_CHART_NAME" "$SEC_NAMESPACE" "$SEC_VERSION" "$SEC_OPTS" "$SEC_INSTALLED" ""
282290
;;
283291
esac
284292
done

charts/scripts/install-prereqs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,18 @@ applyChart() {
8181
local version=$5
8282
local opts=$6
8383
local installed=$7
84+
local crd_cmd=$8
8485
local chart_repo="$chart_name $chart_name --repo $repo"
8586
local msg="$pretty not found. Installing..."
8687

8788
if [[ "$repo" =~ ^oci:// ]] ; then
8889
chart_repo="$chart_name $repo"
8990
fi
9091

92+
if [ -n $crd_cmd ] ; then
93+
runOrPrint $crd_cmd
94+
fi
95+
9196
if [ -n "$installed" ] && [ "$UPGRADE" = false ] ; then
9297
echo "$pretty has already been installed."
9398
else
@@ -181,13 +186,16 @@ CM_OPTS="--set crds.enabled=true \
181186
--set webhook.tolerations[0].'effect'='NoSchedule' \
182187
--set webhook.tolerations[0].'operator'='Exists'"
183188

189+
ING_CRD_CMD=""
184190
if [ "$INGRESS" = "traefik" ]; then
185191
ING_PRETTY="Traefik Proxy (Ingress/Gateway API)"
186192
ING_REPO=https://traefik.github.io/charts
187193
ING_CHART_NAME=traefik
188194
ING_NAMESPACE=${TRAEFIK_NAMESPACE:-traefik}
189195
ING_VERSION=${TRAEFIK_VERSION:-}
190196
ING_INSTALLED=$(kubectl get clusterroles -l app.kubernetes.io/name=traefik 2>/dev/null)
197+
ING_CRD_CMD="helm show crds traefik --repo $ING_REPO | kubectl apply --server-side --force-conflicts -f - && \
198+
kubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.5.1/standard-install.yaml"
191199
NGINX_COMPAT_VALUES="\
192200
--set providers.kubernetesIngressNGINX.enabled=true \
193201
--set providers.kubernetesIngressNGINX.ingressClassByName=true \
@@ -294,10 +302,10 @@ for t in ${TARGETS[@]} ; do
294302
message "t=${t}" "debug"
295303
case "$t" in
296304
cert-manager)
297-
applyChart "$CM_PRETTY" "$CM_REPO" "$CM_CHART_NAME" "$CM_NAMESPACE" "$CM_VERSION" "$CM_OPTS" "$CM_INSTALLED"
305+
applyChart "$CM_PRETTY" "$CM_REPO" "$CM_CHART_NAME" "$CM_NAMESPACE" "$CM_VERSION" "$CM_OPTS" "$CM_INSTALLED" ""
298306
;;
299307
ingress)
300-
applyChart "$ING_PRETTY" "$ING_REPO" "$ING_CHART_NAME" "$ING_NAMESPACE" "$ING_VERSION" "$ING_OPTS" "$ING_INSTALLED"
308+
applyChart "$ING_PRETTY" "$ING_REPO" "$ING_CHART_NAME" "$ING_NAMESPACE" "$ING_VERSION" "$ING_OPTS" "$ING_INSTALLED" "$ING_CRD_CMD"
301309
if [ "$INGRESS" = "traefik" ]; then
302310
NGINX_CURRENT_CONTROLLER=$(kubectl get ingressclass nginx -o="jsonpath={.spec.controller}" 2>/dev/null || true)
303311
if [ -z "$NGINX_CURRENT_CONTROLLER" ]; then
@@ -308,7 +316,7 @@ for t in ${TARGETS[@]} ; do
308316
fi
309317
;;
310318
secrets)
311-
applyChart "$SEC_PRETTY" "$SEC_REPO" "$SEC_CHART_NAME" "$SEC_NAMESPACE" "$SEC_VERSION" "$SEC_OPTS" "$SEC_INSTALLED"
319+
applyChart "$SEC_PRETTY" "$SEC_REPO" "$SEC_CHART_NAME" "$SEC_NAMESPACE" "$SEC_VERSION" "$SEC_OPTS" "$SEC_INSTALLED" ""
312320
;;
313321
esac
314322
done

0 commit comments

Comments
 (0)