Skip to content

Commit 7275019

Browse files
committed
feat: add script for kubernetes dev env
Signed-off-by: Shane Utt <[email protected]>
1 parent 6836a23 commit 7275019

File tree

2 files changed

+59
-27
lines changed

2 files changed

+59
-27
lines changed

Makefile

+10-27
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,11 @@ clean.environment.dev.kind:
721721
environment.dev.kubernetes.infrastructure:
722722
ifeq ($(strip $(INFRASTRUCTURE_OVERRIDE)),true)
723723
@echo "Deploying OpenShift Infrastructure Components"
724-
kustomize build deploy/environments/dev/kubernetes-kgateway-infra | kubectl apply --server-side --force-conflicts -f -
724+
kustomize build deploy/components/crds-gateway-api | kubectl apply --server-side --force-conflicts -f -
725+
kustomize build deploy/components/crds-gie | kubectl apply --server-side --force-conflicts -f -
726+
kustomize build --enable-helm deploy/components/crds-kgateway | kubectl apply --server-side --force-conflicts -f -
727+
kustomize build --enable-helm deploy/environments/dev/kubernetes-kgateway-infra | kubectl apply --server-side --force-conflicts -f -
728+
kubectl -n kgateway-system wait deployment/kgateway --for=condition=Available --timeout=60s
725729
else
726730
$(error "Error: The environment variable INFRASTRUCTURE_OVERRIDE must be set to true in order to run this target.")
727731
endif
@@ -743,7 +747,10 @@ ifeq ($(strip $(INFRASTRUCTURE_OVERRIDE)),true)
743747
@echo "This is extremely destructive. We'll provide 5 seconds before starting to give you a chance to cancel."
744748
sleep 5
745749
@echo "Tearing Down OpenShift Infrastructure Components"
746-
kustomize build deploy/environments/dev/kubernetes-kgateway-infra | kubectl delete -f - || true
750+
kustomize build --enable-helm deploy/environments/dev/kubernetes-kgateway-infra | kubectl delete -f - || true
751+
kustomize build --enable-helm deploy/components/crds-kgateway | kubectl delete -f - || true
752+
kustomize build deploy/components/crds-gie | kubectl delete -f - || true
753+
kustomize build deploy/components/crds-gateway-api | kubectl delete -f - || true
747754
else
748755
$(error "Error: The environment variable INFRASTRUCTURE_OVERRIDE must be set to true in order to run this target.")
749756
endif
@@ -754,33 +761,9 @@ endif
754761
# This target deploys the GIE stack in a specific namespace for development and
755762
# testing.
756763
# ------------------------------------------------------------------------------
757-
VLLM_SIM_IMAGE ?= quay.io/vllm-d/vllm-sim
758-
VLLM_SIM_TAG ?= 0.0.2
759-
EPP_IMAGE ?= us-central1-docker.pkg.dev/k8s-staging-images/gateway-api-inference-extension/epp
760-
EPP_TAG ?= main
761764
.PHONY: environment.dev.kubernetes
762765
environment.dev.kubernetes: check-kubectl check-kustomize check-envsubst
763-
@echo "INFO: checking required vars"
764-
ifndef NAMESPACE
765-
$(error "Error: NAMESPACE is required but not set")
766-
endif
767-
export NAMESPACE=$(NAMESPACE)
768-
ifndef REGISTRY_SECRET
769-
$(error "Error: REGISTRY_SECRET is required but not set")
770-
endif
771-
export REGISTRY_SECRET=$(REGISTRY_SECRET)
772-
export VLLM_SIM_IMAGE=$(VLLM_SIM_IMAGE)
773-
export VLLM_SIM_TAG=$(VLLM_SIM_TAG)
774-
export EPP_IMAGE=$(EPP_IMAGE)
775-
export EPP_TAG=$(EPP_TAG)
776-
@echo "INFO: Creating namespace (if needed) and setting context to $(NAMESPACE)..."
777-
kubectl create namespace $(NAMESPACE) 2>/dev/null || true
778-
@echo "INFO: Deploying Development Environment in namespace $(NAMESPACE)"
779-
kustomize build deploy/environments/dev/kubernetes-kgateway | envsubst | kubectl -n $(NAMESPACE) apply -f -
780-
@echo "INFO: Waiting for Pods in namespace $(NAMESPACE) to become ready"
781-
kubectl -n $(NAMESPACE) wait --for=condition=Ready --all pods --timeout=300s
782-
@echo "INFO: Waiting for Gateway in namespace $(NAMESPACE) to become ready"
783-
kubectl -n $(NAMESPACE) wait gateway/inference-gateway --for=condition=Programmed --timeout=60s
766+
./scripts/kubernetes-dev-env.sh 2>&1
784767
@echo "INFO: Development environment deployed to namespace $(NAMESPACE)"
785768

786769
# ------------------------------------------------------------------------------

scripts/kubernetes-dev-env.sh

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/bin/bash
2+
3+
# This shell script deploys a Kubernetes or OpenShift cluster with an
4+
# KGateway-based Gateway API implementation fully configured. It deploys the
5+
# vllm simulator, which it exposes with a Gateway -> HTTPRoute -> InferencePool.
6+
# The Gateway is configured with the a filter for the ext_proc endpoint picker.
7+
8+
set -eux
9+
10+
# ------------------------------------------------------------------------------
11+
# Variables
12+
# ------------------------------------------------------------------------------
13+
14+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
15+
16+
# Set a default VLLM_SIM_IMAGE if not provided
17+
: "${VLLM_SIM_IMAGE:=quay.io/vllm-d/vllm-sim}"
18+
19+
# Set a default VLLM_SIM_TAG if not provided
20+
: "${VLLM_SIM_TAG:=0.0.2}"
21+
22+
# Set a default EPP_IMAGE if not provided
23+
: "${EPP_IMAGE:=us-central1-docker.pkg.dev/k8s-staging-images/gateway-api-inference-extension/epp}"
24+
25+
# Set a default EPP_TAG if not provided
26+
: "${EPP_TAG:=main}"
27+
28+
# ------------------------------------------------------------------------------
29+
# Deployment
30+
# ------------------------------------------------------------------------------
31+
32+
kubectl create namespace ${NAMESPACE} 2>/dev/null || true
33+
34+
# Hack to deal with KGateways broken OpenShift support
35+
export PROXY_UID=$(kubectl get namespace ${NAMESPACE} -o json | jq -e -r '.metadata.annotations["openshift.io/sa.scc.uid-range"]' | perl -F'/' -lane 'print $F[0]+1');
36+
37+
set -o pipefail
38+
39+
echo "INFO: Deploying Development Environment in namespace ${NAMESPACE}"
40+
41+
kustomize build deploy/environments/dev/kubernetes-kgateway | envsubst | kubectl -n ${NAMESPACE} apply -f -
42+
43+
echo "INFO: Waiting for resources in namespace ${NAMESPACE} to become ready"
44+
45+
kubectl -n ${NAMESPACE} wait deployment/endpoint-picker --for=condition=Available --timeout=60s
46+
kubectl -n ${NAMESPACE} wait deployment/vllm-sim --for=condition=Available --timeout=60s
47+
kubectl -n ${NAMESPACE} wait gateway/inference-gateway --for=condition=Programmed --timeout=60s
48+
kubectl -n ${NAMESPACE} wait deployment/inference-gateway --for=condition=Available --timeout=60s
49+

0 commit comments

Comments
 (0)