Skip to content

Commit

Permalink
Split out clusters to its own Makefile
Browse files Browse the repository at this point in the history
To make it easy for other projects to consume, split out cluster
creation and cleanup to a `Makefile.clusters` file that can be
included by other projects that desire these capabilities.

Signed-off-by: Mike Kolesnik <mkolesni@redhat.com>
  • Loading branch information
mkolesnik committed Dec 11, 2023
1 parent c693fee commit 0935096
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 29 deletions.
60 changes: 60 additions & 0 deletions Makefile.clusters
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
### VARIABLES ###

, := ,
USING = $(subst $(,), ,$(using))
_using = ${USING}

# General make flags/variables
PARALLEL ?= true
TIMEOUT ?= 5m
export PARALLEL SETTINGS TIMEOUT

# Flags affecting `make clusters`
K8S_VERSION ?= 1.25
METALLB_VERSION ?= 0.13.5
OLM_VERSION ?= v0.18.3
PROVIDER ?= kind
export AIR_GAPPED DUAL_STACK GLOBALNET K8S_VERSION LOAD_BALANCER METALLB_VERSION OLM OLM_VERSION PROMETHEUS PROVIDER

### PROCESSING `using=` ###

ifneq (,$(filter ocp,$(_using)))
PROVIDER = ocp
endif

ifneq (,$(filter acm,$(_using)))
PROVIDER = acm
endif

ifneq (,$(filter load-balancer,$(_using)))
LOAD_BALANCER = true
endif

ifneq (,$(filter air-gap,$(_using)))
AIR_GAPPED = true
endif

ifneq (,$(filter dual-stack,$(_using)))
DUAL_STACK = true
endif

ifneq (,$(filter globalnet,$(_using)))
GLOBALNET = true
endif

ifneq (,$(filter prometheus,$(_using)))
PROMETHEUS = true
endif

### TARGETS ###

# [clean-clusters] removes running clusters
clean-clusters:
$(SCRIPTS_DIR)/cleanup.sh
cleanup: clean-clusters
clean: clean-clusters

# [clusters] creates KIND clusters that can then be used to deploy Submariner
clusters:
$(SCRIPTS_DIR)/$@.sh

34 changes: 5 additions & 29 deletions Makefile.inc
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,7 @@ DEBUG_PRINT ?= true
PARALLEL ?= true
PROVIDER ?= kind
TIMEOUT ?= 5m
export AIR_GAPPED DEBUG_PRINT DUAL_STACK GLOBALNET LOAD_BALANCER PARALLEL PLUGIN PRELOAD_IMAGES PROVIDER SETTINGS TEST_ARGS TIMEOUT

# Specific to `clusters`
K8S_VERSION ?= 1.25
METALLB_VERSION ?= 0.13.5
OLM_VERSION ?= v0.18.3
export K8S_VERSION METALLB_VERSION OLM OLM_VERSION PROMETHEUS
export AIR_GAPPED DEBUG_PRINT GLOBALNET PARALLEL PLUGIN PRELOAD_IMAGES PROVIDER SETTINGS TEST_ARGS TIMEOUT

# Specific to `deploy`
CABLE_DRIVER ?= libreswan
Expand Down Expand Up @@ -58,6 +52,7 @@ $(call check_shipyard_file,Dockerfile.linting)

##### END GLOBAL FILES STALENESS CHECK #####

include $(SHIPYARD_DIR)/Makefile.clusters
include $(SHIPYARD_DIR)/Makefile.images
include $(SHIPYARD_DIR)/Makefile.linting
include $(SHIPYARD_DIR)/Makefile.versions
Expand Down Expand Up @@ -98,22 +93,16 @@ DEPLOYTOOL = ocm
LIGHTHOUSE = true
endif

ifneq (,$(filter prometheus,$(_using)))
PROMETHEUS = true
endif

# Force running E2E with `subctl verify`
ifneq (,$(filter subctl-verify,$(_using)))
TESTDIR = non-existent-dir
endif

ifneq (,$(filter ocp,$(_using)))
PROVIDER = ocp
IMAGE_TAG = subctl
endif

ifneq (,$(filter acm,$(_using)))
PROVIDER = acm
IMAGE_TAG = subctl
endif

Expand All @@ -125,10 +114,6 @@ ifneq (,$(filter air-gap,$(_using)))
AIR_GAPPED = true
endif

ifneq (,$(filter dual-stack,$(_using)))
DUAL_STACK = true
endif

ifeq ($(LIGHTHOUSE),true)
SUBCTL_VERIFICATIONS = service-discovery
endif
Expand Down Expand Up @@ -156,32 +141,23 @@ export GO
# Shipyard provided targets

##### CLEANING TARGETS #####
.PHONY: clean clean-clusters clean-generated clean-buildx
.PHONY: clean clean-generated clean-buildx

# [clean] cleans everything (running clusters, generated files ...)
clean: clean-clusters clean-generated clean-buildx
clean: clean-generated clean-buildx

# [clean-generated] removes files we generated, by removing all files and directories ignored by git
clean-generated:
git clean -X -f -d

# [clean-clusters] removes running clusters
clean-clusters:
$(SCRIPTS_DIR)/cleanup.sh
cleanup: clean-clusters

# [clean-buildx] removes the buildx builder, if any
clean-buildx:
docker buildx version > /dev/null 2>&1 && \
docker buildx use buildx_builder > /dev/null 2>&1 && \
docker buildx rm

##### DEPLOYMENT& TESTING TARGETS #####
.PHONY: clusters cloud-prepare deploy e2e scale upgrade-e2e deploy-latest

# [clusters] creates KIND clusters that can then be used to deploy Submariner
clusters:
$(SCRIPTS_DIR)/$@.sh
.PHONY: cloud-prepare deploy e2e scale upgrade-e2e deploy-latest

# [cloud-prepare] can be run on a POC/testing cloud environment to prepare it before deploying Submariner
cloud-prepare:
Expand Down

0 comments on commit 0935096

Please sign in to comment.