-
Notifications
You must be signed in to change notification settings - Fork 169
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Makefile targets for building, running, and testing RP container …
…image locally with Podman fix the code setup_resources.sh has been fixed makefile has been fixed fix the code removed unwanted files vnet create and delete code has been added Makefile has been fixed makefile modified added code to add dedicated vnet unwanted file deleted added some imp files
- Loading branch information
1 parent
bf7ddde
commit 4c3b5bb
Showing
4 changed files
with
223 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
SHELL = /bin/bash | ||
TAG ?= $(shell git describe --exact-match 2>/dev/null) | ||
COMMIT = $(shell git rev-parse --short=7 HEAD)$(shell [[ $$(git status --porcelain) = "" ]] || echo -dirty) | ||
ARO_IMAGE_BASE = ${RP_IMAGE_ACR}.azurecr.io/aro | ||
ARO_IMAGE_BASE = aro-local | ||
E2E_FLAGS ?= -test.v --ginkgo.v --ginkgo.timeout 180m --ginkgo.flake-attempts=2 --ginkgo.junit-report=e2e-report.xml | ||
GO_FLAGS ?= -tags=containers_image_openpgp,exclude_graphdriver_btrfs,exclude_graphdriver_devicemapper | ||
NO_CACHE ?= true | ||
|
@@ -19,7 +19,7 @@ GATEKEEPER_IMAGE ?= ${RP_IMAGE_ACR}.azurecr.io/gatekeeper:$(GATEKEEPER_VERSION) | |
GOTESTSUM = gotest.tools/[email protected] | ||
|
||
ifneq ($(shell uname -s),Darwin) | ||
export CGO_CFLAGS=-Dgpgme_off_t=off_t | ||
export CGO_CFLAGS=-Dgpgme_off_t=off_t | ||
endif | ||
|
||
ifeq ($(TAG),) | ||
|
@@ -57,8 +57,60 @@ build-all: | |
aro: check-release generate | ||
go build -ldflags "-X github.com/Azure/ARO-RP/pkg/util/version.GitCommit=$(VERSION)" ./cmd/aro | ||
|
||
build-local-rp-image: | ||
@echo "Increasing Podman machine resources..." | ||
@podman machine stop | ||
@podman machine set --cpus 4 --memory 8192 | ||
@podman machine start | ||
@echo "Building local RP image..." | ||
podman build . -f Dockerfile.ci-rp --ulimit=nofile=4096:4096 --build-arg REGISTRY=$(REGISTRY) --build-arg ARO_VERSION=$(VERSION) --no-cache=$(NO_CACHE) -t $(ARO_IMAGE) || true | ||
|
||
runlocal-rp: | ||
go run -ldflags "-X github.com/Azure/ARO-RP/pkg/util/version.GitCommit=$(VERSION)" ./cmd/aro rp | ||
set -a; source .env; set +a; \ | ||
$(MAKE) build-local-rp-image; \ | ||
echo "Starting Podman service if not running..."; \ | ||
podman machine init || true; \ | ||
podman machine start || true; \ | ||
echo "Podman service status:"; \ | ||
podman machine list; \ | ||
podman system connection list; \ | ||
echo "Using ARO_IMAGE: $(ARO_IMAGE)"; \ | ||
if [ -z "$(ARO_IMAGE)" ]; then echo "Error: ARO_IMAGE is not set"; exit 1; fi; \ | ||
podman run --rm -d -p 8443:8443 --name aro-rp -e DOMAIN_NAME=$(DOMAIN_NAME) -e AZURE_FP_CLIENT_ID=$(AZURE_FP_CLIENT_ID) $(ARO_IMAGE) rp; | ||
|
||
ensure-aro-image: | ||
@if ! podman image exists $(ARO_IMAGE); then \ | ||
$(MAKE) build-local-rp-image; \ | ||
fi | ||
|
||
setup: | ||
@bash ./setup_resources.sh $(KEY_NAME) $(KEY_VERSION) | ||
|
||
cluster: | ||
@set -a; source .env; set +a; \ | ||
if [ -z "$$CLUSTER" ]; then \ | ||
read -p "Enter the cluster name: " CLUSTER; \ | ||
fi; \ | ||
echo "Using CLUSTER: $$CLUSTER"; \ | ||
export CLUSTER=$$CLUSTER; \ | ||
CGO_ENABLED=0 go run ./hack/cluster/cluster.go create | ||
|
||
delete-cluster: | ||
@set -a; source .env; set +a; \ | ||
if [ -z "$$CLUSTER" ]; then \ | ||
read -p "Enter the cluster name to delete: " CLUSTER; \ | ||
fi; \ | ||
echo "Deleting CLUSTER: $$CLUSTER"; \ | ||
export CLUSTER=$$CLUSTER; \ | ||
CGO_ENABLED=0 go run ./hack/cluster/cluster.go delete | ||
|
||
e2e: ensure-aro-image | ||
@podman run --rm --name aro-e2e --network host \ | ||
-e AZURE_TENANT_ID=$(AZURE_TENANT_ID) \ | ||
-e AZURE_SUBSCRIPTION_ID=$(AZURE_SUBSCRIPTION_ID) \ | ||
-e AZURE_CLIENT_ID=$(AZURE_CLIENT_ID) \ | ||
-e AZURE_CLIENT_SECRET=$(AZURE_CLIENT_SECRET) \ | ||
aro:e2e | ||
|
||
az: pyenv | ||
. pyenv/bin/activate && \ | ||
|
@@ -77,7 +129,8 @@ client: generate | |
hack/build-client.sh "${AUTOREST_IMAGE}" 2020-04-30 2021-09-01-preview 2022-04-01 2022-09-04 2023-04-01 2023-07-01-preview 2023-09-04 2023-11-22 2024-08-12-preview | ||
|
||
ci-rp: fix-macos-vendor | ||
docker build . -f Dockerfile.ci-rp --ulimit=nofile=4096:4096 --build-arg REGISTRY=$(REGISTRY) --build-arg ARO_VERSION=$(VERSION) --no-cache=$(NO_CACHE) | ||
@echo "Building with VERSION=$(VERSION)" | ||
docker build . -f Dockerfile.ci-rp --ulimit=nofile=4096:4096 --build-arg REGISTRY=$(REGISTRY) --build-arg ARO_VERSION=$(VERSION) --no-cache=$(NO_CACHE) -t $(ARO_IMAGE) | ||
|
||
# TODO: hard coding dev-config.yaml is clunky; it is also probably convenient to | ||
# override COMMIT. | ||
|
@@ -102,6 +155,7 @@ generate: | |
|
||
# TODO: This does not work outside of GOROOT. We should replace all usage of the | ||
# clientset with controller-runtime so we don't need to generate it. | ||
|
||
generate-operator-apiclient: | ||
go run ./vendor/k8s.io/code-generator/cmd/client-gen --clientset-name versioned --input-base ./pkg/operator/apis --input aro.openshift.io/v1alpha1,preview.aro.openshift.io/v1alpha1 --output-package ./pkg/operator/clientset --go-header-file ./hack/licenses/boilerplate.go.txt | ||
gofmt -s -w ./pkg/operator/clientset | ||
|
@@ -140,8 +194,8 @@ image-gatekeeper: | |
publish-image-aro-multistage: image-aro-multistage | ||
docker push $(ARO_IMAGE) | ||
ifeq ("${RP_IMAGE_ACR}-$(BRANCH)","arointsvc-master") | ||
docker tag $(ARO_IMAGE) arointsvc.azurecr.io/aro:latest | ||
docker push arointsvc.azurecr.io/aro:latest | ||
docker tag $(ARO_IMAGE) arointsvc.azurecr.io/aro:latest | ||
docker push arointsvc.azurecr.io/aro:latest | ||
endif | ||
|
||
publish-image-autorest: image-autorest | ||
|
@@ -177,10 +231,10 @@ build-portal: | |
pyenv: | ||
python3 -m venv pyenv | ||
. pyenv/bin/activate && \ | ||
pip install -U pip && \ | ||
pip install -r requirements.txt && \ | ||
azdev setup -r . && \ | ||
sed -i -e "s|^dev_sources = $(PWD)$$|dev_sources = $(PWD)/python|" ~/.azure/config | ||
pip install -U pip && \ | ||
pip install -r requirements.txt && \ | ||
azdev setup -r . && \ | ||
sed -i -e "s|^dev_sources = $(PWD)$$|dev_sources = $(PWD)/python|" ~/.azure/config | ||
|
||
secrets: | ||
@[ "${SECRET_SA_ACCOUNT_NAME}" ] || ( echo ">> SECRET_SA_ACCOUNT_NAME is not set"; exit 1 ) | ||
|
@@ -190,7 +244,7 @@ secrets: | |
rm secrets.tar.gz | ||
|
||
secrets-update: | ||
@[ "${SECRET_SA_ACCOUNT_NAME}" ] || ( echo ">> SECRET_SA_ACCOUNT_NAME is not set"; exit 1 ) | ||
@[ "${SECRET_SA_ACCOUNT_NAME}" ] || ( echo ">> SECRET_SA_ACCOUNT_NAME}" is not set"; exit 1 ) | ||
tar -czf secrets.tar.gz secrets | ||
az storage blob upload -n secrets.tar.gz -c secrets -f secrets.tar.gz --overwrite --account-name ${SECRET_SA_ACCOUNT_NAME} >/dev/null | ||
rm secrets.tar.gz | ||
|
@@ -247,9 +301,9 @@ lint-admin-portal: | |
|
||
test-python: pyenv az | ||
. pyenv/bin/activate && \ | ||
azdev linter && \ | ||
azdev style && \ | ||
hack/unit-test-python.sh | ||
azdev linter && \ | ||
azdev style && \ | ||
hack/unit-test-python.sh | ||
|
||
shared-cluster-login: | ||
@oc login $(shell az aro show -g sre-shared-cluster -n sre-shared-cluster -ojson --query apiserverProfile.url) \ | ||
|
@@ -272,7 +326,7 @@ aks.kubeconfig: | |
hack/get-admin-aks-kubeconfig.sh | ||
|
||
vendor: | ||
# See comments in the script for background on why we need it | ||
# See comments in the script for background on why we need it | ||
hack/update-go-module-dependencies.sh | ||
|
||
install-go-tools: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/bin/bash | ||
|
||
# Load environment variables from .env file | ||
set -a | ||
source .env | ||
set +a | ||
|
||
# Set cluster-specific environment variables | ||
RESOURCEGROUP="v4-westeurope" | ||
DATABASE_ACCOUNT_NAME="${USER}-aro-${LOCATION}" | ||
KEYVAULT_PREFIX="${USER}-aro-${LOCATION}" | ||
|
||
# Create resource group | ||
echo "Ensuring resource group $RESOURCEGROUP in $LOCATION..." | ||
az group show --name "$RESOURCEGROUP" &>/dev/null | ||
if [ $? -ne 0 ]; then | ||
az group create --name "$RESOURCEGROUP" --location "$LOCATION" | ||
else | ||
echo "Resource group $RESOURCEGROUP already exists." | ||
fi | ||
|
||
# Create virtual network | ||
echo "Ensuring virtual network dev-vnet in resource group $RESOURCEGROUP..." | ||
az network vnet show --resource-group "$RESOURCEGROUP" --name dev-vnet &>/dev/null | ||
if [ $? -ne 0 ]; then | ||
az network vnet create --resource-group "$RESOURCEGROUP" --name dev-vnet --address-prefix 10.0.0.0/16 --subnet-name dev-subnet --subnet-prefix 10.0.0.0/24 | ||
else | ||
echo "Virtual network dev-vnet already exists." | ||
fi | ||
|
||
# Create key vault | ||
echo "Ensuring key vault ${KEYVAULT_PREFIX}-kv in resource group $RESOURCEGROUP..." | ||
az keyvault show --name "${KEYVAULT_PREFIX}-kv" --resource-group "$RESOURCEGROUP" &>/dev/null | ||
if [ $? -ne 0 ]; then | ||
az keyvault create --name "${KEYVAULT_PREFIX}-kv" --resource-group "$RESOURCEGROUP" --location "$LOCATION" | ||
else | ||
echo "Key vault ${KEYVAULT_PREFIX}-kv already exists." | ||
fi | ||
|
||
# Create disk encryption set | ||
KEY_URL="https://${KEYVAULT_PREFIX}-kv.vault.azure.net/keys/<key-name>/<key-version>" # Replace with the actual key URL | ||
echo "Ensuring disk encryption set ${RESOURCEGROUP}-disk-encryption-set in resource group $RESOURCEGROUP..." | ||
az disk-encryption-set show --name "${RESOURCEGROUP}-disk-encryption-set" --resource-group "$RESOURCEGROUP" &>/dev/null | ||
if [ $? -ne 0 ]; then | ||
az disk-encryption-set create --name "${RESOURCEGROUP}-disk-encryption-set" --resource-group "$RESOURCEGROUP" --location "$LOCATION" --source-vault "/subscriptions/$AZURE_SUBSCRIPTION_ID/resourceGroups/$RESOURCEGROUP/providers/Microsoft.KeyVault/vaults/${KEYVAULT_PREFIX}-kv" --key-url "$KEY_URL" | ||
else | ||
echo "Disk encryption set ${RESOURCEGROUP}-disk-encryption-set already exists." | ||
fi | ||
|
||
echo "Resource setup completed." |