Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

service deployment makefile cleanup #921

Merged
merged 1 commit into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
136 changes: 45 additions & 91 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
14 changes: 7 additions & 7 deletions dev-infrastructure/docs/development-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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
Expand Down
18 changes: 12 additions & 6 deletions svc-deploy.sh
Original file line number Diff line number Diff line change
@@ -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 <deploy-env> <dir> <cluster> [target]
# this script expects the <dir> 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}"
Loading