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 5412594
Show file tree
Hide file tree
Showing 14 changed files with 98 additions and 106 deletions.
2 changes: 1 addition & 1 deletion backend/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Makefile
config.mk
19 changes: 12 additions & 7 deletions backend/Makefile.tmpl.mk → backend/Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
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 +29,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
48 changes: 48 additions & 0 deletions cluster-service/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
SHELL = /bin/bash
DEPLOY_ENV ?= personal-dev

$(shell ../templatize.sh $(DEPLOY_ENV) config.tmpl.mk config.mk)

include config.mk

ZONE_RESOURCE_ID ?= $(shell az network dns zone show -n ${DNS_ZONE_NAME} -g ${REGIONAL_RESOURCEGROUP} --query id -o tsv)

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 }}
DNS_ZONE_NAME ?= {{ .regionalDNSSubdomain }}.{{ .baseDnsZoneName }}
FPA_CERT_NAME ?= firstPartyCert
2 changes: 1 addition & 1 deletion frontend/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Makefile
config.mk
19 changes: 12 additions & 7 deletions frontend/Makefile.tmpl.mk → frontend/Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
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 +34,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.

0 comments on commit 5412594

Please sign in to comment.