-
Notifications
You must be signed in to change notification settings - Fork 177
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
- Loading branch information
1 parent
bf7ddde
commit 91c82f1
Showing
3 changed files
with
136 additions
and
15 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,44 @@ 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 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 | ||
|
||
cluster: | ||
set -a; source .env; set +a; \ | ||
if [ -z "${CLUSTER}" ]; then \ | ||
read -p "Enter the cluster name: " CLUSTER; \ | ||
fi; \ | ||
echo "Using CLUSTER: ${CLUSTER}"; \ | ||
CGO_ENABLED=0 go run ./hack/cluster/cluster.go create | ||
|
||
|
||
e2e: ensure-aro-image | ||
@podman run --rm -d --name aro-e2e $(ARO_IMAGE) e2e | ||
@podman logs aro-e2e | ||
|
||
az: pyenv | ||
. pyenv/bin/activate && \ | ||
|
@@ -77,7 +113,7 @@ 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) | ||
docker build . -f Dockerfile.ci-rp --ulimit=nofile=4096:4096 --build-arg REGISTRY=$(REGISTRY) --build-arg VERSION=$(VERSION) --no-cache=$(NO_CACHE) | ||
|
||
# TODO: hard coding dev-config.yaml is clunky; it is also probably convenient to | ||
# override COMMIT. | ||
|
@@ -102,6 +138,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 +177,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 +214,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 ) | ||
|
@@ -247,9 +284,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 +309,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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
#!/bin/bash | ||
|
||
# Ensure Azure CLI is installed and the user is logged in | ||
if ! command -v az &> /dev/null; then | ||
echo "Azure CLI (az) could not be found. Please install it and log in using 'az login'." | ||
exit 1 | ||
fi | ||
|
||
if ! az account show &> /dev/null; then | ||
echo "Azure CLI is not logged in. Please log in using 'az login'." | ||
exit 1 | ||
fi | ||
|
||
# Set the Azure subscription | ||
az account set --subscription "ARO SRE Team - InProgress (EA Subscription 2)" | ||
|
||
# Load environment variables from .env file | ||
set -a | ||
source .env | ||
set +a | ||
|
||
# Set cluster-specific environment variables with fallback defaults | ||
RESOURCEGROUP="${1:-v4-westeurope}" | ||
DATABASE_ACCOUNT_NAME="${USER}-aro-${LOCATION}" | ||
KEYVAULT_PREFIX="${USER:0:20}-kv-${LOCATION:0:4}" # Ensure valid key vault name length | ||
|
||
# Use arguments or fallback to environment variables | ||
KEY_NAME="${2:-$KEY_NAME}" | ||
KEY_VERSION="${3:-$KEY_VERSION}" | ||
|
||
# Prompt for key name and key version if not set | ||
if [ -z "$KEY_NAME" ]; then | ||
read -p "Enter the key name for the disk encryption set: " KEY_NAME | ||
fi | ||
|
||
if [ -z "$KEY_VERSION" ]; then | ||
read -p "Enter the key version for the disk encryption set: " KEY_VERSION | ||
fi | ||
|
||
# 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" --tags createdAt=$(date -u +%Y-%m-%dT%H:%M:%SZ) | ||
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} in resource group $RESOURCEGROUP..." | ||
az keyvault show --name "${KEYVAULT_PREFIX}" --resource-group "$RESOURCEGROUP" &>/dev/null | ||
if [ $? -ne 0 ]; then | ||
az keyvault create --name "${KEYVAULT_PREFIX}" --resource-group "$RESOURCEGROUP" --location "$LOCATION" | ||
else | ||
echo "Key vault ${KEYVAULT_PREFIX} already exists." | ||
fi | ||
|
||
# Validate key URL format and existence in Key Vault | ||
KEY_URL="https://${KEYVAULT_PREFIX}.vault.azure.net/keys/${KEY_NAME}/${KEY_VERSION}" | ||
echo "Ensuring disk encryption set ${RESOURCEGROUP}-disk-encryption-set in resource group $RESOURCEGROUP..." | ||
az keyvault key show --vault-name "${KEYVAULT_PREFIX}" --name "${KEY_NAME}" --version "${KEY_VERSION}" &>/dev/null | ||
if [ $? -ne 0 ]; then | ||
echo "The specified key name and version do not exist in the Key Vault. Please check the values and try again." | ||
exit 1 | ||
fi | ||
|
||
# Create disk encryption set | ||
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}" --key-url "$KEY_URL" | ||
else | ||
echo "Disk encryption set ${RESOURCEGROUP}-disk-encryption-set already exists." | ||
fi | ||
|
||
echo "Resource setup completed." |