Files
kserve/hack/setup/infra/manage.envoy-gateway-helm.sh
2026-06-24 20:38:08 -04:00

96 lines
3.2 KiB
Bash
Executable File

#!/bin/bash
# Copyright 2025 The KServe Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Install Envoy Gateway using Helm
# Usage: install-helm.sh [--reinstall|--uninstall]
# or: REINSTALL=true install-helm.sh
# or: UNINSTALL=true install-helm.sh
# INIT
SCRIPT_DIR="$(cd "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" && pwd)"
source "${SCRIPT_DIR}/../common.sh"
REINSTALL="${REINSTALL:-false}"
UNINSTALL="${UNINSTALL:-false}"
if [[ "$*" == *"--uninstall"* ]]; then
UNINSTALL=true
elif [[ "$*" == *"--reinstall"* ]]; then
REINSTALL=true
fi
# INIT END
check_cli_exist helm kubectl yq
uninstall() {
log_info "Uninstalling Envoy Gateway..."
kubectl delete gatewayclass envoy --ignore-not-found=true --force --grace-period=0 2>/dev/null || true
helm uninstall eg -n envoy-gateway-system 2>/dev/null || true
kubectl delete all --all -n envoy-gateway-system --force --grace-period=0 2>/dev/null || true
kubectl delete namespace envoy-gateway-system --wait=true --timeout=60s --force --grace-period=0 2>/dev/null || true
log_success "Envoy Gateway uninstalled"
}
install() {
if helm list -n envoy-gateway-system 2>/dev/null | grep -q "eg"; then
if [ "$REINSTALL" = false ]; then
log_info "Envoy Gateway is already installed. Use --reinstall to reinstall."
return 0
else
log_info "Reinstalling Envoy Gateway..."
uninstall
fi
fi
log_info "Installing Envoy Gateway CRDs ${ENVOY_GATEWAY_VERSION}..."
helm show crds oci://docker.io/envoyproxy/gateway-helm \
--version "${ENVOY_GATEWAY_VERSION}" \
| yq 'select(.spec.group == "gateway.envoyproxy.io")' \
| kubectl apply --server-side --force-conflicts -f -
wait_for_crds "60s" \
"backends.gateway.envoyproxy.io" \
"backendtrafficpolicies.gateway.envoyproxy.io" \
"clienttrafficpolicies.gateway.envoyproxy.io" \
"envoyextensionpolicies.gateway.envoyproxy.io" \
"envoypatchpolicies.gateway.envoyproxy.io" \
"envoyproxies.gateway.envoyproxy.io" \
"httproutefilters.gateway.envoyproxy.io" \
"securitypolicies.gateway.envoyproxy.io"
log_info "Installing Envoy Gateway ${ENVOY_GATEWAY_VERSION}..."
helm upgrade -i eg oci://docker.io/envoyproxy/gateway-helm \
--version "${ENVOY_GATEWAY_VERSION}" \
-n envoy-gateway-system \
--create-namespace \
--skip-crds \
--wait
log_success "Successfully installed Envoy Gateway ${ENVOY_GATEWAY_VERSION} via Helm"
wait_for_pods "envoy-gateway-system" "control-plane=envoy-gateway" "300s"
log_success "Envoy Gateway is ready!"
}
if [ "$UNINSTALL" = true ]; then
uninstall
exit 0
fi
install