From 7b124b66fde5dfbd92c7de385d41c5b1703c8e30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Bukatovi=C4=8D?= Date: Tue, 3 Dec 2024 00:46:47 +0100 Subject: [PATCH] service deployment makefile cleanup User visible changes in Makefile targets deploying service components: - cs.deploy becomes cluster-service.deploy - rp.frontend.deploy becomes frontend.deploy - rp.backend.deploy becomes backend.deploy - hypershift.deploy becomes hypershiftoperator.deploy - maestro target no longer exists - deploy.svc.all becomes svc.deployall (the same goes with mgmt target) - deploy.all becomes just deployall So that: - all targets deploying single service ends with .deploy and use the service name matching the component directory name - all targets deploying all services ends with deployall --- Makefile | 136 ++++++------------- dev-infrastructure/docs/development-setup.md | 14 +- svc-deploy.sh | 18 ++- 3 files changed, 64 insertions(+), 104 deletions(-) diff --git a/Makefile b/Makefile index c9b405af9..080091fb4 100644 --- a/Makefile +++ b/Makefile @@ -82,97 +82,51 @@ infra.clean: .PHONY: infra.clean # -# Istio -# - -isto.deploy: - @./svc-deploy.sh $(DEPLOY_ENV) istio svc -.PHONY: isto.deploy - -# -# Metrics -# - -metrics.deploy: - @./svc-deploy.sh $(DEPLOY_ENV) metrics svc -.PHONY: metrics.deploy - -# -# Cluster Service -# - -cs.deploy: - @./svc-deploy.sh $(DEPLOY_ENV) cluster-service svc -.PHONY: cs.deploy - -# -# Maestro -# - -maestro.server.deploy: - @./svc-deploy.sh $(DEPLOY_ENV) maestro/server svc -.PHONY: maestro.server.deploy - -maestro.agent.deploy: - @./svc-deploy.sh $(DEPLOY_ENV) maestro/agent mgmt -.PHONY: maestro.agent.deploy - -maestro.registration.deploy: - @./svc-deploy.sh $(DEPLOY_ENV) maestro/registration svc -.PHONY: maestro.registration.deploy - -maestro: maestro.server.deploy maestro.agent.deploy maestro.registration.deploy -.PHONY: maestro - -# -# Resource Provider -# - -rp.frontend.deploy: - @./svc-deploy.sh $(DEPLOY_ENV) frontend svc -.PHONY: rp.frontend.deploy - -rp.backend.deploy: - @./svc-deploy.sh $(DEPLOY_ENV) backend svc -.PHONY: rp.backend.deploy - -# -# PKO -# - -pko.deploy: - @./svc-deploy.sh $(DEPLOY_ENV) pko mgmt -.PHONY: pko.deploy - -# -# ACM -# - -acm.deploy: - @./svc-deploy.sh $(DEPLOY_ENV) acm mgmt -.PHONY: acm.deploy - -# -# Hypershift -# - -hypershift.deploy: - @./svc-deploy.sh $(DEPLOY_ENV) hypershiftoperator mgmt -.PHONY: hypershift.deploy - -# -# Deploy ALL components -# - -deploy.svc.all: isto.deploy metrics.deploy maestro.server.deploy maestro.registration.deploy cs.deploy rp.frontend.deploy rp.backend.deploy -.PHONY: deploy.svc.all - -deploy.mgmt.all: acm.deploy maestro.agent.deploy hypershift.deploy -.PHONY: deploy.mgmt.all - -deploy.all: deploy.svc.all deploy.mgmt.all -.PHONY: deploy.all +# Services +# + +# Service Deployment Conventions: +# +# - Services are deployed in aks clusters (either svc or mgmt), which are +# provisioned via infra section above +# - Makefile targets to deploy services ends with ".deploy" suffix +# - To deploy all services on svc or mgmt cluster, we have special targets +# `svc.deployall` and `mgmt.deployall`, and `deployall` deploys everithing. +# - Placement of a service is controlled via services_svc and services_mgmt +# variables +# - If the name of the service contains a dot, it's interpreted as directory +# separator "/" (used for maestro only). + +# Services deployed on "svc" aks cluster +services_svc = istio metrics maestro.server maestro.registration cluster-service frontend backend +# Services deployed on "mgmt" aks cluster(s) +services_mgmt = acm maestro.agent pko hypershiftoperator +# List of all services +services_all = $(join services_svc,services_mgmt) + +.PHONY: $(addsuffix .deploy, $(services_all)) deployall svc.deployall mgmt.deployall listall list clean + +# Service deployment on either svc or mgmt aks cluster, a service name +# needs to be listed either in services_svc or services_mgmt variable (wich +# defines where it will be deployed). +%.deploy: + $(eval export dirname=$(subst .,/,$(basename $@))) + @if [ $(words $(filter $(basename $@), $(services_svc))) = 1 ]; then\ + ./svc-deploy.sh $(DEPLOY_ENV) $(dirname) svc;\ + elif [ $(words $(filter $(basename $@), $(services_mgmt))) = 1 ]; then\ + ./svc-deploy.sh $(DEPLOY_ENV) $(dirname) mgmt;\ + else\ + echo "'$(basename $@)' is not to be deployed on neither svc nor mgmt cluster";\ + exit 1;\ + fi + +svc.deployall: $(addsuffix .deploy, $(services_svc)) +mgmt.deployall: $(addsuffix .deploy, $(services_mgmt)) +deployall: svc.deployall mgmt.deployall + +listall: + @echo svc: ${services_svc} + @echo mgmt: ${services_mgmt} list: @grep '^[^#[:space:]].*:' Makefile -.PHONY: list diff --git a/dev-infrastructure/docs/development-setup.md b/dev-infrastructure/docs/development-setup.md index 662a3ef49..bb9a87c8d 100644 --- a/dev-infrastructure/docs/development-setup.md +++ b/dev-infrastructure/docs/development-setup.md @@ -239,14 +239,14 @@ There are more fine grained cleanup tasks available as well To followup sections describe how to deploy the components individually. But if you are looking for a quick and easy way to install or update ALL components on both clusters with one command, then run this: ```bash - make deploy.svc.all - make deploy.mgmt.all + make svc.deployall + make mgmt.deployall ``` Or even simpler with ```bash - make deploy.all + make deployall ``` ## Deploy Services to the service cluster @@ -273,7 +273,7 @@ To access the HTTP and GRPC endpoints of maestro, run > This might not work with `oc` 4.17.0, please use oc 4.16.x until this is fixed in 4.17 ```bash - make cs.deploy + make cluster-service.deploy ``` To validate, have a look at the `cluster-service` namespace or the service cluster. @@ -283,8 +283,8 @@ To validate, have a look at the `cluster-service` namespace or the service clust The ARO-HCP resource provider consists of independent frontend and backend components. ```bash - make rp.frontend.deploy - make rp.backend.deploy + make frontend.deploy + make backend.deploy ``` To validate, have a look at the `aro-hcp` namespace on the service cluster. @@ -300,7 +300,7 @@ To validate, have a look at the `aro-hcp` namespace on the service cluster. ### Hypershift Operator and External DNS ```bash - make hypershift.deploy + make hypershiftoperator.deploy ``` ### Maestro Agent diff --git a/svc-deploy.sh b/svc-deploy.sh index c71af31d5..0aeb109fe 100755 --- a/svc-deploy.sh +++ b/svc-deploy.sh @@ -1,23 +1,29 @@ #!/bin/bash +# bash will report what is happening and stop in case of non zero return code +set -xe + # deploy a service to a cluster # ./svc-deploy [target] # this script expects the to contain a Makefile that takes care # of processing any config.mk template on its own -cd $(dirname "$(realpath "${BASH_SOURCE[0]}")") || exit +cd "$(dirname "$(realpath "${BASH_SOURCE[0]}")")" export DEPLOY_ENV=$1 export DIR=$2 export CLUSTER=$3 export TARGET=${4:-deploy} -if [[ "$CLUSTER" != "svc" && "$CLUSTER" != "mgmt" ]]; then - echo "Error: CLUSTER must be either 'svc' or 'mgmt'." +if [[ "${CLUSTER}" != "svc" && "${CLUSTER}" != "mgmt" ]]; then + echo "Error: CLUSTER must be either 'svc' or 'mgmt'." >&2 exit 1 fi -export KUBECONFIG=$(cd dev-infrastructure || exit ; make --no-print-directory $CLUSTER.aks.kubeconfigfile) +cd dev-infrastructure +KUBECONFIG=$(make --no-print-directory "${CLUSTER}.aks.kubeconfigfile") +export KUBECONFIG +cd - -cd ${DIR} || exit -make $TARGET +cd "${DIR}" +make "${TARGET}"