@@ -28,13 +28,14 @@ help: ## Output the self-documenting make targets
2828ROOTDIR := $(shell pwd)
2929OUTPUT_DIR ?= $(ROOTDIR ) /_output
3030
31- export IMAGE_REGISTRY ?= ghcr.io/kgateway-dev
31+ # Image registry for container images. Defaults to localhost:5001 for local development with kind
32+ # Override via environment variable for releases (e.g., IMAGE_REGISTRY=ghcr.io/kgateway-dev)
33+ IMAGE_REGISTRY ?= localhost:5001
34+ export IMAGE_REGISTRY
3235
3336# Kind of a hack to make sure _output exists
3437z := $(shell mkdir -p $(OUTPUT_DIR ) )
3538
36- BUILDX_BUILD ?= docker buildx build -q
37-
3839# A semver resembling 1.0.1-dev. Most calling GHA jobs customize this. Exported for use in goreleaser.yaml.
3940VERSION ?= 1.0.1-dev
4041export VERSION
6263 endif
6364endif
6465
65- PLATFORM := --platform=linux/$(GOARCH )
66+ BUILDX_BUILDER_NAME ?= kind-builder
67+ BUILDX_BUILD ?= docker buildx build -q
68+ BUILDX_BUILD_ARGS ?= --push --builder $(BUILDX_BUILDER_NAME ) --platform=linux/$(GOARCH )
6669
6770GOOS ?= $(shell uname -s | tr '[:upper:]' '[:lower:]')
6871
@@ -417,8 +420,9 @@ kgateway: $(CONTROLLER_OUTPUT_DIR)/kgateway-linux-$(GOARCH)
417420$(CONTROLLER_OUTPUT_DIR ) /Dockerfile : cmd/kgateway/Dockerfile
418421 cp $< $@
419422
423+ .PHONY : $(CONTROLLER_OUTPUT_DIR ) /.docker-stamp-$(VERSION ) -$(GOARCH )
420424$(CONTROLLER_OUTPUT_DIR ) /.docker-stamp-$(VERSION ) -$(GOARCH ) : $(CONTROLLER_OUTPUT_DIR ) /kgateway-linux-$(GOARCH ) $(CONTROLLER_OUTPUT_DIR ) /Dockerfile
421- $(BUILDX_BUILD ) --load $( PLATFORM ) $(CONTROLLER_OUTPUT_DIR ) -f $(CONTROLLER_OUTPUT_DIR ) /Dockerfile \
425+ $(BUILDX_BUILD ) $( BUILDX_BUILD_ARGS ) $(CONTROLLER_OUTPUT_DIR ) -f $(CONTROLLER_OUTPUT_DIR ) /Dockerfile \
422426 --build-arg GOARCH=$(GOARCH ) \
423427 --build-arg ENVOY_IMAGE=$(ENVOY_IMAGE ) \
424428 -t $(IMAGE_REGISTRY ) /$(CONTROLLER_IMAGE_REPO ) :$(VERSION )
@@ -445,8 +449,9 @@ sds: $(SDS_OUTPUT_DIR)/sds-linux-$(GOARCH)
445449$(SDS_OUTPUT_DIR ) /Dockerfile.sds : cmd/sds/Dockerfile
446450 cp $< $@
447451
452+ .PHONY : $(SDS_OUTPUT_DIR ) /.docker-stamp-$(VERSION ) -$(GOARCH )
448453$(SDS_OUTPUT_DIR ) /.docker-stamp-$(VERSION ) -$(GOARCH ) : $(SDS_OUTPUT_DIR ) /sds-linux-$(GOARCH ) $(SDS_OUTPUT_DIR ) /Dockerfile.sds
449- $(BUILDX_BUILD ) --load $( PLATFORM ) $(SDS_OUTPUT_DIR ) -f $(SDS_OUTPUT_DIR ) /Dockerfile.sds \
454+ $(BUILDX_BUILD ) $( BUILDX_BUILD_ARGS ) $(SDS_OUTPUT_DIR ) -f $(SDS_OUTPUT_DIR ) /Dockerfile.sds \
450455 --build-arg GOARCH=$(GOARCH ) \
451456 --build-arg BASE_IMAGE=$(ALPINE_BASE_IMAGE ) \
452457 -t $(IMAGE_REGISTRY ) /$(SDS_IMAGE_REPO ) :$(VERSION )
@@ -486,8 +491,9 @@ $(ENVOYINIT_OUTPUT_DIR)/Dockerfile.envoyinit: $(ENVOYINIT_DOCKERFILE) $(RUSTFORM
486491$(ENVOYINIT_OUTPUT_DIR ) /docker-entrypoint.sh : cmd/envoyinit/docker-entrypoint.sh
487492 cp $< $@
488493
494+ .PHONY : $(ENVOYINIT_OUTPUT_DIR ) /.docker-stamp-$(VERSION ) -$(GOARCH )
489495$(ENVOYINIT_OUTPUT_DIR ) /.docker-stamp-$(VERSION ) -$(GOARCH ) : $(ENVOYINIT_OUTPUT_DIR ) /envoyinit-linux-$(GOARCH ) $(ENVOYINIT_OUTPUT_DIR ) /Dockerfile.envoyinit $(ENVOYINIT_OUTPUT_DIR ) /docker-entrypoint.sh
490- $(BUILDX_BUILD ) --load $( PLATFORM ) $(ENVOYINIT_OUTPUT_DIR ) -f $(ENVOYINIT_OUTPUT_DIR ) /Dockerfile.envoyinit \
496+ $(BUILDX_BUILD ) $( BUILDX_BUILD_ARGS ) $(ENVOYINIT_OUTPUT_DIR ) -f $(ENVOYINIT_OUTPUT_DIR ) /Dockerfile.envoyinit \
491497 --build-arg GOARCH=$(GOARCH ) \
492498 --build-arg ENVOY_IMAGE=$(ENVOY_IMAGE ) \
493499 --build-arg RUST_BUILD_ARCH=$(RUST_BUILD_ARCH ) \
@@ -561,6 +567,8 @@ GORELEASER_ARGS ?= --snapshot --clean
561567GORELEASER_TIMEOUT ?= 60m
562568GORELEASER_CURRENT_TAG ?= $(VERSION )
563569
570+ # When running locally, we need to set the IMAGE_REGISTRY to override the default
571+ # localhost:5001 local registry.
564572.PHONY : release
565573release : # # Create a release using goreleaser
566574 GORELEASER_CURRENT_TAG=$(GORELEASER_CURRENT_TAG ) $(GORELEASER ) release $(GORELEASER_ARGS ) --timeout $(GORELEASER_TIMEOUT )
@@ -577,9 +585,15 @@ INSTALL_NAMESPACE ?= kgateway-system
577585# This version should stay in sync with `hack/kind/setup-kind.sh`.
578586CLUSTER_NODE_VERSION ?= v1.34.0@sha256:7416a61b42b1662ca6ca89f02028ac133a309a2a30ba309614e8ec94d976dc5a
579587
588+ .PHONY : kind-create-builder
589+ kind-create-builder : # # Create a buildx builder for pushing to local registry
590+ @if ! docker buildx ls | grep -q $(BUILDX_BUILDER_NAME ) ; then \
591+ docker buildx create --name $(BUILDX_BUILDER_NAME ) --driver docker-container --driver-opt network=host --bootstrap --use; \
592+ fi
593+
580594.PHONY : kind-create
581- kind-create : # # Create a KinD cluster
582- $( KIND ) get clusters | grep $( CLUSTER_NAME ) || $( KIND ) create cluster --name $( CLUSTER_NAME ) --image kindest/node: $( CLUSTER_NODE_VERSION )
595+ kind-create : # # Create a KinD cluster with a local registry
596+ KIND_CLUSTER_NAME= $( CLUSTER_NAME ) KIND_IMAGE_VERSION= $( CLUSTER_NODE_VERSION ) ./hack/kind/setup-local-registry.sh
583597
584598CONFORMANCE_CHANNEL ?= experimental
585599CONFORMANCE_VERSION ?= v1.4.0
@@ -606,10 +620,10 @@ deploy-kgateway: package-kgateway-charts deploy-kgateway-crd-chart deploy-kgatew
606620setup-base : kind-create gw-api-crds gie-crds metallb # # Setup the base infrastructure (kind cluster, CRDs, and MetalLB)
607621
608622.PHONY : setup
609- setup : setup-base kind -build-and-load package-kgateway-charts # # Setup the complete infrastructure (base setup plus images and charts)
623+ setup : setup-base docker -build package-kgateway-charts # # Setup the complete infrastructure
610624
611625.PHONY : run
612- run : setup deploy-kgateway # # Set up complete development environment
626+ run : setup deploy-kgateway # # Set up complete development environment
613627
614628.PHONY : undeploy
615629undeploy : undeploy-kgateway undeploy-kgateway-crds # # Undeploy the application from the cluster
@@ -622,21 +636,19 @@ undeploy-kgateway: ## Undeploy the core chart from the cluster
622636undeploy-kgateway-crds : # # Undeploy the CRD chart from the cluster
623637 $(HELM ) uninstall kgateway-crds --namespace $(INSTALL_NAMESPACE ) || true
624638
639+ .PHONY : docker-build # # Build and push all docker images to local registry
640+ docker-build : kind-create-builder
641+ docker-build : kgateway-docker
642+ docker-build : envoy-wrapper-docker
643+ docker-build : sds-docker
644+
625645# ----------------------------------------------------------------------------------
626646# Build assets for kubernetes e2e tests
627647# ----------------------------------------------------------------------------------
628648
629649kind-setup : # # Set up the KinD cluster. Deprecated: use kind-create instead.
630650 VERSION=${VERSION} CLUSTER_NAME=${CLUSTER_NAME} ./hack/kind/setup-kind.sh
631651
632- kind-load-% :
633- $(KIND ) load docker-image $(IMAGE_REGISTRY ) /$* :$(VERSION ) --name $(CLUSTER_NAME )
634-
635- # Build an image and load it into the KinD cluster
636- # Depends on: IMAGE_REGISTRY, VERSION, CLUSTER_NAME
637- # Envoy image may be specified via ENVOY_IMAGE on the command line or at the top of this file
638- kind-build-and-load-% : % -docker kind-load-% ; # # Use to build specified image and load it into kind
639-
640652# Update the docker image used by a deployment
641653# This works for most of our deployments because the deployment name and container name both match
642654# NOTE TO DEVS:
@@ -649,24 +661,6 @@ kind-set-image-%:
649661 kubectl patch deployment $* -n $(INSTALL_NAMESPACE ) -p ' {"spec": {"template":{"metadata":{"annotations":{"kgateway-kind-last-update":"$(shell date)"}}}} }'
650662 kubectl rollout resume deployment $* -n $(INSTALL_NAMESPACE )
651663
652- # Reload an image in KinD
653- # This is useful to developers when changing a single component
654- # You can reload an image, which means it will be rebuilt and reloaded into the kind cluster, and the deployment
655- # will be updated to reference it
656- # Depends on: IMAGE_REGISTRY, VERSION, INSTALL_NAMESPACE , CLUSTER_NAME
657- # Envoy image may be specified via ENVOY_IMAGE on the command line or at the top of this file
658- kind-reload-% : kind-build-and-load-% kind-set-image-% ; # # Use to build specified image, load it into kind, and restart its deployment
659-
660- .PHONY : kind-build-and-load # # Use to build all images and load them into kind
661- kind-build-and-load : kind-build-and-load-kgateway
662- kind-build-and-load : kind-build-and-load-envoy-wrapper
663- kind-build-and-load : kind-build-and-load-sds
664-
665- .PHONY : kind-load # # Use to load all images into kind
666- kind-load : kind-load-kgateway
667- kind-load : kind-load-envoy-wrapper
668- kind-load : kind-load-sds
669-
670664# ----------------------------------------------------------------------------------
671665# Load Testing
672666# ----------------------------------------------------------------------------------
0 commit comments