Skip to content

Commit

Permalink
templatize only Makefile include not makefile itself
Browse files Browse the repository at this point in the history
Signed-off-by: Gerd Oberlechner <[email protected]>
  • Loading branch information
geoberle committed Oct 25, 2024
1 parent 3830101 commit aeff941
Show file tree
Hide file tree
Showing 24 changed files with 153 additions and 153 deletions.
2 changes: 1 addition & 1 deletion backend/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Makefile
config.mk
17 changes: 10 additions & 7 deletions backend/Makefile.tmpl.mk → backend/Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
SHELL = /bin/bash
DEPLOY_ENV ?= personal-dev
$(shell ../templatize.sh $(DEPLOY_ENV) config.tmpl.mk config.mk)
include config.mk

COMMIT = $(shell git rev-parse --short=7 HEAD)
ARO_HCP_BASE_IMAGE ?= {{ .acrName }}.azurecr.io
ARO_HCP_BASE_IMAGE ?= ${ARO_HCP_IMAGE_ACR}.azurecr.io
ARO_HCP_BACKEND_IMAGE ?= $(ARO_HCP_BASE_IMAGE)/arohcpbackend:$(COMMIT)

backend:
go build -o aro-hcp-backend .

run:
./aro-hcp-backend --location {{ .region }} \
./aro-hcp-backend --location ${LOCATION} \
--clusters-service-url http://localhost:8000

clean:
Expand All @@ -24,20 +27,20 @@ push: image

deploy:
BACKEND_MI_CLIENT_ID=$(shell az identity show \
-g {{ .serviceClusterRG }} \
-g ${RESOURCEGROUP} \
-n backend \
--query clientId);\
ISTO_VERSION=$(shell az aks show -n {{ .aksName }} -g {{ .serviceClusterRG }} --query serviceMeshProfile.istio.revisions[-1] -o tsv) && \
ISTO_VERSION=$(shell az aks show -n ${AKS_NAME} -g ${RESOURCEGROUP} --query serviceMeshProfile.istio.revisions[-1] -o tsv) && \
kubectl create namespace aro-hcp --dry-run=client -o json | kubectl apply -f - && \
kubectl label namespace aro-hcp "istio.io/rev=$${ISTO_VERSION}" --overwrite=true && \
helm upgrade --install aro-hcp-backend-dev \
deploy/helm/backend/ \
--set configMap.databaseName={{ .frontendCosmosDBName }} \
--set configMap.databaseUrl="https://{{ .frontendCosmosDBName }}.documents.azure.com:443/" \
--set configMap.databaseName=${DB_NAME} \
--set configMap.databaseUrl="https://${DB_NAME}.documents.azure.com:443/" \
--set configMap.backendMiClientId="$${BACKEND_MI_CLIENT_ID}" \
--set serviceAccount.workloadIdentityClientId="$${BACKEND_MI_CLIENT_ID}" \
--set configMap.currentVersion=${ARO_HCP_BACKEND_IMAGE} \
--set configMap.location={{ .region }} \
--set configMap.location=${LOCATION} \
--set deployment.imageName=${ARO_HCP_BACKEND_IMAGE} \
--namespace aro-hcp

Expand Down
11 changes: 0 additions & 11 deletions backend/README.md

This file was deleted.

5 changes: 5 additions & 0 deletions backend/config.tmpl.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ARO_HCP_IMAGE_ACR ?= {{ .acrName }}
LOCATION ?= {{ .region }}
RESOURCEGROUP ?= {{ .serviceClusterRG }}
AKS_NAME ?= {{ .aksName }}
DB_NAME ?= {{ .frontendCosmosDBName }}
12 changes: 0 additions & 12 deletions backend/generate-makefile.sh

This file was deleted.

2 changes: 1 addition & 1 deletion cluster-service/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
deploy/tmp-provisioning-shard.yml
Makefile
config.mk
44 changes: 44 additions & 0 deletions cluster-service/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
SHELL = /bin/bash
DEPLOY_ENV ?= personal-dev
$(shell ../templatize.sh $(DEPLOY_ENV) config.tmpl.mk config.mk)
include config.mk

deploy:
sed -e "s#ZONE_RESOURCE_ID#${ZONE_RESOURCE_ID}#g" -e "s/REGION/${REGION}/g" -e "s/CONSUMER_NAME/${CONSUMER_NAME}/g" deploy/mvp-provisioning-shards.yml > deploy/tmp-provisioning-shard.yml

ISTO_VERSION=$(shell az aks show -n ${AKS_NAME} -g ${RESOURCEGROUP} --query serviceMeshProfile.istio.revisions[-1] -o tsv) && \
oc process --local -f deploy/openshift-templates/arohcp-namespace-template.yml \
-p ISTIO_VERSION=$${ISTO_VERSION} | oc apply -f -
kubectl apply -f deploy/istio.yml

oc process --local -f deploy/openshift-templates/arohcp-db-template.yml | oc apply -f -
oc process --local -f deploy/openshift-templates/arohcp-secrets-template.yml \
-p PROVISION_SHARDS_CONFIG="$$( base64 -i deploy/tmp-provisioning-shard.yml)" | oc apply -f -

AZURE_CS_MI_CLIENT_ID=$(shell az identity show -g ${RESOURCEGROUP} -n clusters-service --query clientId -o tsv) && \
CS_SERVICE_PRINCIPAL_CREDS_BASE64='$(shell az keyvault secret show --vault-name "${SERVICE_KV}" --name "aro-hcp-dev-sp-cs" | jq .value -r | base64 | tr -d '\n')' && \
TENANT_ID=$(shell az account show --query tenantId --output tsv) && \
OIDC_BLOB_SERVICE_ENDPOINT=$(shell az storage account show -n ${OIDC_STORAGE_ACCOUNT} -g ${RESOURCEGROUP} --query primaryEndpoints.blob -o tsv) && \
OIDC_WEB_SERVICE_ENDPOINT=$(shell az storage account show -n ${OIDC_STORAGE_ACCOUNT} -g ${RESOURCEGROUP} --query primaryEndpoints.web -o tsv) && \
oc process --local -f deploy/openshift-templates/arohcp-service-template.yml \
-p AZURE_CS_MI_CLIENT_ID=$${AZURE_CS_MI_CLIENT_ID} \
-p TENANT_ID=$${TENANT_ID} \
-p REGION=${REGION} \
-p SERVICE_KEYVAULT_NAME=${SERVICE_KV} \
-p CS_SERVICE_PRINCIPAL_CREDS_BASE64=$${CS_SERVICE_PRINCIPAL_CREDS_BASE64} \
-p IMAGE_REGISTRY=${ACR_NAME}.azurecr.io \
-p IMAGE_REPOSITORY=${IMAGE_REPO} \
-p AZURE_FIRST_PARTY_APPLICATION_CLIENT_ID=${FPA_CLIENT_ID} \
-p FPA_CERT_NAME=${FPA_CERT_NAME} \
-p IMAGE_TAG=${IMAGE_TAG} | oc apply -f -

deploy-pr-env-deps:
AZURE_CS_MI_CLIENT_ID=$(shell az identity show -g ${RESOURCEGROUP} -n clusters-service --query clientId -o tsv) && \
oc process --local -f deploy/integration/cluster-service-namespace.yaml \
-p CLIENT_ID=${AZURE_CS_MI_CLIENT_ID} | oc apply -f -

# for local development
provision-shard:
sed -e "s#ZONE_RESOURCE_ID#${ZONE_RESOURCE_ID}#g" -e "s/REGION/${REGION}/g" -e "s/CONSUMER_NAME/${CONSUMER_NAME}/g" deploy/dev-provisioning-shards.yml

.PHONY: deploy deploy-integ provision-shard
44 changes: 0 additions & 44 deletions cluster-service/Makefile.tmpl.mk

This file was deleted.

13 changes: 13 additions & 0 deletions cluster-service/config.tmpl.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
REGION ?= {{ .region }}
CONSUMER_NAME ?= {{ .maestroConsumerName }}
RESOURCEGROUP ?= {{ .serviceClusterRG }}
REGIONAL_RESOURCEGROUP ?= {{ .regionRG }}
AKS_NAME ?= {{ .aksName }}
SERVICE_KV ?= {{ .serviceKeyVaultName }}
OIDC_STORAGE_ACCOUNT ?= {{ .oidcStorageAccountName }}
IMAGE_REPO ?= {{ .clusterServiceImageRepo }}
IMAGE_TAG ?= {{ .clusterServiceImageTag }}
ACR_NAME ?= {{ .acrName }}
FPA_CLIENT_ID ?= {{ .firstPartyAppClientId }}
FPA_CERT_NAME ?= firstPartyCert
ZONE_RESOURCE_ID ?= $(shell az network dns zone show -n {{ .regionalDNSSubdomain }}.{{ .baseDnsZoneName }} -g {{ .regionRG }} --query id -o tsv)
2 changes: 1 addition & 1 deletion frontend/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Makefile
config.mk
17 changes: 10 additions & 7 deletions frontend/Makefile.tmpl.mk → frontend/Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
SHELL = /bin/bash
DEPLOY_ENV ?= personal-dev
$(shell ../templatize.sh $(DEPLOY_ENV) config.tmpl.mk config.mk)
include config.mk

COMMIT = $(shell git rev-parse --short=7 HEAD)
ARO_HCP_BASE_IMAGE ?= {{ .acrName }}.azurecr.io
ARO_HCP_BASE_IMAGE ?= ${ARO_HCP_IMAGE_ACR}.azurecr.io
ARO_HCP_FRONTEND_IMAGE ?= $(ARO_HCP_BASE_IMAGE)/arohcpfrontend:$(COMMIT)

frontend:
go build -o aro-hcp-frontend .

run:
./aro-hcp-frontend --use-cache --location {{ .region }} \
./aro-hcp-frontend --use-cache --location ${LOCATION} \
--clusters-service-url http://localhost:8000 \
--cluster-service-provision-shard 1 \
--cluster-service-noop-provision \
Expand All @@ -29,20 +32,20 @@ push: image

deploy:
FRONTEND_MI_CLIENT_ID=$(shell az identity show \
-g {{ .serviceClusterRG }} \
-g ${RESOURCEGROUP} \
-n frontend \
--query clientId);\
ISTO_VERSION=$(shell az aks show -n {{ .aksName }} -g {{ .serviceClusterRG }} --query serviceMeshProfile.istio.revisions[-1] -o tsv) && \
ISTO_VERSION=$(shell az aks show -n ${AKS_NAME} -g ${RESOURCEGROUP} --query serviceMeshProfile.istio.revisions[-1] -o tsv) && \
kubectl create namespace aro-hcp --dry-run=client -o json | kubectl apply -f - && \
kubectl label namespace aro-hcp "istio.io/rev=$${ISTO_VERSION}" --overwrite=true && \
helm upgrade --install aro-hcp-frontend-dev \
deploy/helm/frontend/ \
--set configMap.databaseName={{ .frontendCosmosDBName }} \
--set configMap.databaseUrl="https://{{ .frontendCosmosDBName }}.documents.azure.com:443/" \
--set configMap.databaseName=${DB_NAME} \
--set configMap.databaseUrl="https://${DB_NAME}.documents.azure.com:443/" \
--set configMap.frontendMiClientId="$${FRONTEND_MI_CLIENT_ID}" \
--set serviceAccount.workloadIdentityClientId="$${FRONTEND_MI_CLIENT_ID}" \
--set configMap.currentVersion=${ARO_HCP_FRONTEND_IMAGE} \
--set configMap.location={{ .region }} \
--set configMap.location=${LOCATION} \
--set deployment.imageName=${ARO_HCP_FRONTEND_IMAGE} \
--namespace aro-hcp

Expand Down
10 changes: 0 additions & 10 deletions frontend/README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
# ARO-HCP-FRONTEND

## Prerequisite

The `Makefile` is templated based on the ARO HCP environment to interact with.

Run the following command to generate a `Makefile` for personal development.

```bash
./generate-makefile.sh personal-dev
```

## Build frontend binary for local testing
```
make frontend
Expand Down
5 changes: 5 additions & 0 deletions frontend/config.tmpl.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ARO_HCP_IMAGE_ACR ?= {{ .acrName }}
LOCATION ?= {{ .region }}
RESOURCEGROUP ?= {{ .serviceClusterRG }}
AKS_NAME ?= {{ .aksName }}
DB_NAME ?= {{ .frontendCosmosDBName }}
12 changes: 0 additions & 12 deletions frontend/generate-makefile.sh

This file was deleted.

2 changes: 1 addition & 1 deletion maestro/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
**/Makefile
**/config.mk
17 changes: 17 additions & 0 deletions maestro/agent/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
SHELL = /bin/bash
DEPLOY_ENV ?= personal-dev
$(shell ../../templatize.sh $(DEPLOY_ENV) config.tmpl.mk config.mk)
include config.mk

deploy:
helm upgrade --install maestro-agent ./helm \
--create-namespace --namespace maestro \
--set consumerName=${CONSUMER_NAME} \
--set broker.host=${EVENTGRID_HOSTNAME} \
--set credsKeyVault.name=${KEYVAULT_NAME} \
--set credsKeyVault.secret=${CONSUMER_NAME} \
--set azure.clientId=${MAESTRO_MI_CLIENT_ID} \
--set azure.tenantId=${TENANT_ID} \
--set image.base=${IMAGE_BASE} \
--set image.tag=${IMAGE_TAG}
.PHONY: deploy
18 changes: 0 additions & 18 deletions maestro/agent/Makefile.tmpl.mk

This file was deleted.

7 changes: 7 additions & 0 deletions maestro/agent/config.tmpl.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
TENANT_ID=$(shell az account show --query tenantId --output tsv)
CONSUMER_NAME ?= {{ .maestroConsumerName }}
EVENTGRID_HOSTNAME=$(shell az resource show -n {{ .maestroEventgridName }} -g {{ .regionRG }} --resource-type "Microsoft.EventGrid/namespaces" --query properties.topicSpacesConfiguration.hostname -o tsv)
MAESTRO_MI_CLIENT_ID=$(shell az identity show -g "{{ .managementClusterRG }}" -n maestro-consumer --query clientId -o tsv)
KEYVAULT_NAME ?= {{ .maestroKeyVaultName }}
IMAGE_BASE ?= {{ .maestroImageBase }}
IMAGE_TAG ?= {{ .maestroImageTag }}
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
SHELL = /bin/bash
DEPLOY_ENV ?= personal-dev
$(shell ../../templatize.sh $(DEPLOY_ENV) config.tmpl.mk config.mk)
include config.mk

deploy:
@if ! kubectl get service maestro -n maestro > /dev/null 2>&1; then \
echo "Error: Service 'maestro' not found in namespace 'maestro'"; \
exit 1; \
fi
helm upgrade --install {{ .maestroConsumerName }} ./helm \
helm upgrade --install ${CONSUMER_NAME} ./helm \
--namespace maestro \
--set consumerName={{ .maestroConsumerName }}
--set consumerName=${CONSUMER_NAME}
.PHONY: deploy
1 change: 1 addition & 0 deletions maestro/registration/config.tmpl.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CONSUMER_NAME ?= {{ .maestroConsumerName }}
20 changes: 20 additions & 0 deletions maestro/server/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
SHELL = /bin/bash
DEPLOY_ENV ?= personal-dev
$(shell ../../templatize.sh $(DEPLOY_ENV) config.tmpl.mk config.mk)
include config.mk

deploy:
kubectl create namespace maestro --dry-run=client -o json | kubectl apply -f -
kubectl label namespace maestro "istio.io/rev=${ISTO_VERSION}" --overwrite=true
helm upgrade --install maestro-server ./helm \
--namespace maestro \
--set broker.host=${EVENTGRID_HOSTNAME} \
--set credsKeyVault.name=${KEYVAULT_NAME} \
--set azure.clientId=${MAESTRO_MI_CLIENT_ID} \
--set azure.tenantId=${TENANT_ID} \
--set istio.restrictIngress=${ISTIO_RESTRICT_INGRESS} \
--set image.base=${IMAGE_BASE} \
--set image.tag=${IMAGE_TAG} \
--set database.containerizedDb=${USE_CONTAINERIZED_DB} \
--set database.ssl='${USE_DATABASE_SSL}'
.PHONY: deploy
22 changes: 0 additions & 22 deletions maestro/server/Makefile.tmpl.mk

This file was deleted.

10 changes: 10 additions & 0 deletions maestro/server/config.tmpl.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
TENANT_ID=$(shell az account show --query tenantId --output tsv)
MAESTRO_MI_CLIENT_ID=$(shell az identity show -g "{{ .serviceClusterRG }}" -n maestro-server --query clientId -o tsv)
EVENTGRID_HOSTNAME=$(shell az resource show -n {{ .maestroEventgridName }} -g {{ .regionRG }} --resource-type "Microsoft.EventGrid/namespaces" --query properties.topicSpacesConfiguration.hostname -o tsv)
ISTO_VERSION=$(shell az aks show -n {{ .aksName }} -g {{ .serviceClusterRG }} --query serviceMeshProfile.istio.revisions[-1] -o tsv)
IMAGE_BASE ?= {{ .maestroImageBase }}
IMAGE_TAG ?= {{ .maestroImageTag }}
USE_CONTAINERIZED_DB ?= {{ not .maestroPostgresDeploy }}
USE_DATABASE_SSL ?= {{ ternary "enable" "disable" .maestroPostgresDeploy }}
ISTIO_RESTRICT_INGRESS ?= {{ .maestroRestrictIstioIngress }}
KEYVAULT_NAME ?= {{ .maestroKeyVaultName }}
Loading

0 comments on commit aeff941

Please sign in to comment.