@@ -398,6 +398,7 @@ DEV_VERSION ?= 0.0.1
398
398
PROD_VERSION ?= 0.0.0
399
399
IMAGE_TAG_BASE ?= quay.io/vllm-d/$(PROJECT_NAME ) /epp
400
400
IMG = $(IMAGE_TAG_BASE ) :$(DEV_VERSION )
401
+ NAMESPACE ?= hc4ai-operator
401
402
402
403
# CONTAINER_TOOL := $(shell command -v docker >/dev/null 2>&1 && echo docker || command -v podman >/dev/null 2>&1 && echo podman || echo "")
403
404
BUILDER := $(shell command -v buildah >/dev/null 2>&1 && echo buildah || echo $(CONTAINER_TOOL ) )
@@ -448,22 +449,15 @@ buildah-build: check-builder load-version-json ## Build and push image (multi-ar
448
449
@echo " ✅ Using builder: $( BUILDER) "
449
450
@if [ " $( BUILDER) " = " buildah" ]; then \
450
451
echo " 🔧 Buildah detected: Performing multi-arch build..." ; \
451
- FINAL_TAG=$(IMG ) ; \
452
452
for arch in amd64; do \
453
- ARCH_TAG=$$ FINAL_TAG-$$ arch; \
454
453
echo " 📦 Building for architecture: $$ arch" ; \
455
454
buildah build --arch=$$ arch --os=linux -t $(IMG ) -$$ arch . || exit 1; \
456
455
echo " 🚀 Pushing image: $( IMG) -$$ arch" ; \
457
456
buildah push $(IMG ) -$$ arch docker://$(IMG ) -$$ arch || exit 1; \
458
457
done ; \
459
- echo " 🧼 Removing existing manifest (if any)..." ; \
460
- buildah manifest rm $$ FINAL_TAG || true ; \
461
458
echo " 🧱 Creating and pushing manifest list: $( IMG) " ; \
462
459
buildah manifest create $(IMG ) ; \
463
- for arch in amd64; do \
464
- ARCH_TAG=$$ FINAL_TAG-$$ arch; \
465
- buildah manifest add $$ FINAL_TAG $$ ARCH_TAG; \
466
- done ; \
460
+ buildah manifest add $(IMG ) $(IMG ) -amd64; \
467
461
buildah manifest push --all $(IMG ) docker://$(IMG ) ; \
468
462
elif [ " $( BUILDER) " = " docker" ]; then \
469
463
echo " 🐳 Docker detected: Building with buildx..." ; \
@@ -485,7 +479,12 @@ buildah-build: check-builder load-version-json ## Build and push image (multi-ar
485
479
.PHONY : image-build
486
480
image-build : check-container-tool load-version-json # # Build container image using $(CONTAINER_TOOL)
487
481
@printf " \033[33;1m==== Building container image $( IMG) ====\033[0m\n"
488
- $(CONTAINER_TOOL ) build --build-arg TARGETOS=$(TARGETOS ) --build-arg TARGETARCH=$(TARGETARCH ) -t $(IMG ) .
482
+ $(CONTAINER_TOOL ) build --platform=$(TARGETOS ) /$(TARGETARCH ) \
483
+ --build-arg TARGETOS=$(TARGETOS) \
484
+ --build-arg TARGETARCH=$(TARGETARCH) \
485
+ --build-arg GIT_NM_USER=$(GIT_NM_USER)\
486
+ --build-arg NM_TOKEN=$(NM_TOKEN) \
487
+ -t $(IMG) .
489
488
490
489
.PHONY : image-push
491
490
image-push : check-container-tool load-version-json # # Push container image $(IMG) to registry
@@ -517,6 +516,142 @@ uninstall-docker: check-container-tool ## Uninstall app from $(CONTAINER_TOOL)
517
516
-$(CONTAINER_TOOL ) stop $(PROJECT_NAME ) -container && $(CONTAINER_TOOL ) rm $(PROJECT_NAME ) -container
518
517
@echo "$(CONTAINER_TOOL ) uninstallation complete. Remove alias if set : unalias $(PROJECT_NAME ) "
519
518
519
+ # ## Kubernetes Targets (kubectl)
520
+
521
+ # TODO: currently incorrect because it depends on OpenShift APIs.
522
+ # See: https://github.com/neuralmagic/gateway-api-inference-extension/issues/14
523
+ .PHONY : install-k8s
524
+ install-k8s : check-kubectl check-kustomize check-envsubst # # Install on Kubernetes
525
+ export PROJECT_NAME=${PROJECT_NAME}
526
+ export NAMESPACE=${NAMESPACE}
527
+ @echo " Creating namespace (if needed) and setting context to $( NAMESPACE) ..."
528
+ kubectl create namespace $(NAMESPACE ) 2> /dev/null || true
529
+ kubectl config set-context --current --namespace=$(NAMESPACE )
530
+ @echo " Deploying resources from deploy/ ..."
531
+ # Build the kustomization from deploy, substitute variables, and apply the YAML
532
+ kustomize build deploy/environments/openshift | envsubst | kubectl apply -f -
533
+ @echo " Waiting for pod to become ready..."
534
+ sleep 5
535
+ @POD=$$(kubectl get pod -l app=$(PROJECT_NAME ) -statefulset -o jsonpath='{.items[0].metadata.name}' ) ; \
536
+ echo " Kubernetes installation complete." ; \
537
+ echo " To use the app, run:" ; \
538
+ echo " alias $( PROJECT_NAME) ='kubectl exec -n $( NAMESPACE) -it $$ POD -- /app/$( PROJECT_NAME) '"
539
+
540
+ # TODO: currently incorrect because it depends on OpenShift APIs.
541
+ # See: https://github.com/neuralmagic/gateway-api-inference-extension/issues/14
542
+ .PHONY : uninstall-k8s
543
+ uninstall-k8s : check-kubectl check-kustomize check-envsubst # # Uninstall from Kubernetes
544
+ export PROJECT_NAME=${PROJECT_NAME}
545
+ export NAMESPACE=${NAMESPACE}
546
+ @echo " Removing resources from Kubernetes..."
547
+ kustomize build deploy/environments/openshift | envsubst | kubectl delete --force -f - || true
548
+ POD=$$(kubectl get pod -l app=$(PROJECT_NAME ) -statefulset -o jsonpath='{.items[0].metadata.name}' ) ; \
549
+ echo " Deleting pod: $$ POD" ; \
550
+ kubectl delete pod " $$ POD" --force --grace-period=0 || true ; \
551
+ echo " Kubernetes uninstallation complete. Remove alias if set: unalias $( PROJECT_NAME) "
552
+
553
+ # ## OpenShift Targets (oc)
554
+
555
+ # ------------------------------------------------------------------------------
556
+ # OpenShift Infrastructure Installer
557
+ #
558
+ # This target deploys infrastructure requirements for the entire cluster.
559
+ # Among other things, this includes CRDs and operators which all users of the
560
+ # cluster need for development (e.g. Gateway API, Istio, etc).
561
+ #
562
+ # **Warning**: Only run this if you're certain you should be running it. It
563
+ # has implications for all users of the cluster!
564
+ # ------------------------------------------------------------------------------
565
+ .PHONY : install-openshift-infrastructure
566
+ install-openshift-infrastructure :
567
+ ifeq ($(strip $(INFRASTRUCTURE_OVERRIDE ) ) ,true)
568
+ @echo "INFRASTRUCTURE_OVERRIDE is set to true, deploying infrastructure components"
569
+ @echo "Installing CRDs for Gateway API & GIE"
570
+ kustomize build deploy/components/crds | kubectl apply --server-side --force-conflicts -f -
571
+ @echo "Installing the Istio Sail Operator and CRDs for Istio"
572
+ kustomize build --enable-helm deploy/components/sail-operator | kubectl apply --server-side --force-conflicts -f -
573
+ @echo "Installing the Istio Control Plane"
574
+ kustomize build deploy/components/istio-control-plane | kubectl apply -f -
575
+ else
576
+ $(error "Error: The environment variable INFRASTRUCTURE_OVERRIDE must be set to true in order to run this target.")
577
+ endif
578
+
579
+ # ------------------------------------------------------------------------------
580
+ # OpenShift Infrastructure Uninstaller
581
+ #
582
+ # This target removes all infrastructure components (e.g. CRDs, operators,
583
+ # etc) for the entire cluster.
584
+ #
585
+ # **Warning**: Only run this if you're certain you should be running it. **This
586
+ # will disrupt everyone using the cluster**. Generally this should only be run
587
+ # when the infrastructure components have undergone very significant change, and
588
+ # you need to do a hard cleanup and re-deploy.
589
+ # ------------------------------------------------------------------------------
590
+ .PHONY : uninstall-openshift-infrastructure
591
+ uninstall-openshift-infrastructure :
592
+ ifeq ($(strip $(INFRASTRUCTURE_OVERRIDE ) ) ,true)
593
+ @echo "INFRASTRUCTURE_OVERRIDE is set to true, removing infrastructure components"
594
+ @echo "Uninstalling the Istio Control Plane"
595
+ kustomize build deploy/components/istio-control-plane | kubectl delete -f - || true
596
+ @echo "Uninstalling the Istio Sail Operator and CRDs for Istio"
597
+ kustomize build --enable-helm deploy/components/sail-operator | kubectl delete -f - || true
598
+ @echo "Uninstalling CRDs for Gateway API & GIE"
599
+ kustomize build deploy/components/crds | kubectl delete -f - || true
600
+ else
601
+ $(error "Error: The environment variable INFRASTRUCTURE_OVERRIDE must be set to true in order to run this target.")
602
+ endif
603
+
604
+ # ------------------------------------------------------------------------------
605
+ # OpenShift Installer
606
+ #
607
+ # This target deploys components in a namespace on an OpenShift cluster for
608
+ # a developer to do development and testing cycles.
609
+ # ------------------------------------------------------------------------------
610
+ .PHONY : install-openshift
611
+ install-openshift : check-kubectl check-kustomize check-envsubst # # Install on OpenShift
612
+ @echo $$ PROJECT_NAME $$ NAMESPACE $$ IMAGE_TAG_BASE $$ VERSION
613
+ @echo " Creating namespace $( NAMESPACE) ..."
614
+ kubectl create namespace $(NAMESPACE ) 2> /dev/null || true
615
+ @echo " Deploying common resources from deploy/ ..."
616
+ # Build and substitute the base manifests from deploy, then apply them
617
+ kustomize build deploy/environments/openshift | envsubst ' $$PROJECT_NAME $$NAMESPACE $$IMAGE_TAG_BASE $$VERSION' | kubectl apply -n $(NAMESPACE ) -f -
618
+ @echo " Waiting for pod to become ready..."
619
+ sleep 5
620
+ @POD=$$(kubectl get pod -l app=$(PROJECT_NAME ) -statefulset -n $(NAMESPACE ) -o jsonpath='{.items[0].metadata.name}' ) ; \
621
+ echo " OpenShift installation complete." ; \
622
+ echo " To use the app, run:" ; \
623
+ echo " alias $( PROJECT_NAME) ='kubectl exec -n $( NAMESPACE) -it $$ POD -- /app/$( PROJECT_NAME) '"
624
+
625
+ # ------------------------------------------------------------------------------
626
+ # OpenShift Uninstaller
627
+ #
628
+ # This target cleans up a developer's testing and development namespace,
629
+ # removing all components therein.
630
+ # ------------------------------------------------------------------------------
631
+ .PHONY : uninstall-openshift
632
+ uninstall-openshift : check-kubectl check-kustomize check-envsubst # # Uninstall from OpenShift
633
+ @echo " Removing resources from OpenShift..."
634
+ kustomize build deploy/environments/openshift | envsubst ' $$PROJECT_NAME $$NAMESPACE $$IMAGE_TAG_BASE $$VERSION' | kubectl delete --force -f - || true
635
+ # @if kubectl api-resources --api-group=route.openshift.io | grep -q Route; then \
636
+ # envsubst '$$PROJECT_NAME $$NAMESPACE $$IMAGE_TAG_BASE $$VERSION' < deploy/openshift/route.yaml | kubectl delete --force -f - || true; \
637
+ # fi
638
+ @POD=$$(kubectl get pod -l app=$(PROJECT_NAME ) -statefulset -n $(NAMESPACE ) -o jsonpath='{.items[0].metadata.name}' ) ; \
639
+ echo " Deleting pod: $$ POD" ; \
640
+ kubectl delete pod " $$ POD" --force --grace-period=0 || true ; \
641
+ echo " OpenShift uninstallation complete. Remove alias if set: unalias $( PROJECT_NAME) "
642
+
643
+ # ## RBAC Targets (using kustomize and envsubst)
644
+
645
+ .PHONY : install-rbac
646
+ install-rbac : check-kubectl check-kustomize check-envsubst # # Install RBAC
647
+ @echo " Applying RBAC configuration from deploy/rbac..."
648
+ kustomize build deploy/environments/openshift/rbac | envsubst ' $$PROJECT_NAME $$NAMESPACE $$IMAGE_TAG_BASE $$VERSION' | kubectl apply -f -
649
+
650
+ .PHONY : uninstall-rbac
651
+ uninstall-rbac : check-kubectl check-kustomize check-envsubst # # Uninstall RBAC
652
+ @echo " Removing RBAC configuration from deploy/rbac..."
653
+ kustomize build deploy/environments/openshift/rbac | envsubst ' $$PROJECT_NAME $$NAMESPACE $$IMAGE_TAG_BASE $$VERSION' | kubectl delete -f - || true
654
+
520
655
521
656
# #@ Version Extraction
522
657
.PHONY : version dev-registry prod-registry extract-version-info
@@ -652,11 +787,9 @@ check-alias: check-container-tool
652
787
echo " ✅ Alias is likely to work: alias $( PROJECT_NAME) ='$( CONTAINER_TOOL) exec -it $( PROJECT_NAME) -container /app/$( PROJECT_NAME) '" ; \
653
788
fi
654
789
655
- # This is being used for tekton builds in the CI/CD pipeline, to provide a
656
- # default namespace to do a test deployment of the Kubernetes dev environment.
657
790
.PHONY : print-namespace
658
- print-namespace :
659
- @echo " hc4ai-operator "
791
+ print-namespace : # # Print the current namespace
792
+ @echo " $( NAMESPACE ) "
660
793
661
794
.PHONY : print-project-name
662
795
print-project-name : # # Print the current project name
0 commit comments