-
Notifications
You must be signed in to change notification settings - Fork 174
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
Make runlocal-rp with Container Image #3593
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
bf0337d
Add Makefile targets for building, running, and testing RP container …
shubhadapaithankar 90b0ea3
fix: Validate RP before cluster creation, add env variables for OCP p…
shubhadapaithankar 1b12497
Set INSTALLER_PULLSPEC dynamically using the extracted OpenShift vers…
shubhadapaithankar 1046a8d
Fixed INSTALLER_PULLSPEC to use correct release version format by tri…
shubhadapaithankar d948f49
fixed the env
shubhadapaithankar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
@@ -1,8 +1,12 @@ | ||
# use unique prefix for Azure resources when it is set, otherwise use your user's name | ||
export AZURE_PREFIX="${AZURE_PREFIX:-$USER}" | ||
export LOCATION=eastus | ||
export ARO_IMAGE=arointsvc.azurecr.io/aro:latest | ||
export LOCATION=westeurope | ||
export NO_CACHE=false | ||
export AZURE_EXTENSION_DEV_SOURCES="$(pwd)/python" | ||
|
||
. secrets/env | ||
export CLUSTER_RESOURCEGROUP="${USER}-v4-$LOCATION" | ||
export CLUSTER_NAME="${USER}-aro-cluster" | ||
export CLUSTER_VNET="${USER}-aro-vnet" | ||
export ARO_IMAGE=arointsvc.azurecr.io/aro:latest | ||
|
||
. secrets/env |
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,184 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
# Determine the base directory of the script | ||
BASE_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd) | ||
|
||
# Construct the path to const.go using the base directory | ||
CONST_GO_PATH="$BASE_DIR/pkg/util/version/const.go" | ||
|
||
# Debugging: Print paths for verification | ||
echo "Base directory: $BASE_DIR" | ||
echo "Path to const.go: $CONST_GO_PATH" | ||
|
||
# Check if const.go exists | ||
if [ ! -f "$CONST_GO_PATH" ]; then | ||
echo "Error: File $CONST_GO_PATH not found." | ||
exit 1 | ||
fi | ||
|
||
# Extract version and pullspec from const.go | ||
OPENSHIFT_VERSION=$(awk -F'[(,)]' '/NewVersion/ {gsub(/ /, ""); print $2"."$3"."$4; exit}' "$CONST_GO_PATH") | ||
OCP_PULLSPEC=$(awk -F'"' '/PullSpec:/ {print $2; exit}' "$CONST_GO_PATH") | ||
|
||
# Set the INSTALLER_PULLSPEC | ||
INSTALLER_PULLSPEC="arointsvc.azurecr.io/aro-installer:release-$(echo $OPENSHIFT_VERSION | sed 's/\.[^.]*$//')" | ||
echo "Using OpenShift version: $OPENSHIFT_VERSION" | ||
echo "Using OCP_PULLSPEC: $OCP_PULLSPEC" | ||
echo "Using INSTALLER_PULLSPEC: $INSTALLER_PULLSPEC" | ||
|
||
# Function to validate RP running | ||
validate_rp_running() { | ||
echo "########## Checking ARO RP Status ##########" | ||
ELAPSED=0 | ||
while true; do | ||
sleep 5 | ||
http_code=$(curl -k -s -o /dev/null -w '%{http_code}' https://localhost:8443/healthz/ready || true) | ||
case $http_code in | ||
"200") | ||
echo "########## ✅ ARO RP Running ##########" | ||
break | ||
;; | ||
*) | ||
echo "Attempt $ELAPSED - local RP is NOT up. Code : $http_code, waiting" | ||
sleep 2 | ||
# after 40 secs return exit 1 to not block ci | ||
ELAPSED=$((ELAPSED + 1)) | ||
if [ $ELAPSED -eq 20 ]; then | ||
exit 1 | ||
fi | ||
;; | ||
esac | ||
done | ||
} | ||
|
||
# Ensure all env vars are set (LOCATION, CLUSTER_RESOURCEGROUP, CLUSTER_NAME) | ||
ALL_SET="true" | ||
if [ -z "${AZURE_SUBSCRIPTION_ID}" ]; then ALL_SET="false" && echo "AZURE_SUBSCRIPTION_ID is unset"; else echo "AZURE_SUBSCRIPTION_ID is set to '$AZURE_SUBSCRIPTION_ID'"; fi | ||
if [ -z "${LOCATION}" ]; then ALL_SET="false" && echo "LOCATION is unset"; else echo "LOCATION is set to '$LOCATION'"; fi | ||
if [ -z "${CLUSTER_RESOURCEGROUP}" ]; then ALL_SET="false" && echo "CLUSTER_RESOURCEGROUP is unset"; else echo "CLUSTER_RESOURCEGROUP is set to '$CLUSTER_RESOURCEGROUP'"; fi | ||
if [ -z "${CLUSTER_NAME}" ]; then ALL_SET="false" && echo "CLUSTER_NAME is unset"; else echo "CLUSTER_NAME is set to '$CLUSTER_NAME'"; fi | ||
if [ -z "${CLUSTER_VNET}" ]; then CLUSTER_VNET="aro-vnet2"; fi; echo "CLUSTER_VNET is ${CLUSTER_VNET}" | ||
if [ -z "${CLUSTER_MASTER_SUBNET}" ]; then CLUSTER_MASTER_SUBNET="master-subnet"; fi; echo "CLUSTER_MASTER_SUBNET is ${CLUSTER_MASTER_SUBNET}" | ||
if [ -z "${CLUSTER_WORKER_SUBNET}" ]; then CLUSTER_WORKER_SUBNET="worker-subnet"; fi; echo "CLUSTER_WORKER_SUBNET is ${CLUSTER_WORKER_SUBNET}" | ||
|
||
if [[ "${ALL_SET}" != "true" ]]; then exit 1; fi | ||
|
||
# Check Azure CLI version | ||
echo "Checking Azure CLI version..." | ||
az_version=$(az --version | grep 'azure-cli' | awk '{print $2}') | ||
required_version="2.30.0" | ||
if [ "$(printf '%s\n' "$required_version" "$az_version" | sort -V | head -n1)" = "$required_version" ]; then | ||
echo "Azure CLI version is compatible" | ||
else | ||
echo "Azure CLI version must be $required_version or later. Please upgrade." | ||
exit 1 | ||
fi | ||
|
||
# Set the subscription | ||
echo "Setting the subscription..." | ||
az account set --subscription $AZURE_SUBSCRIPTION_ID | ||
|
||
# Register the subscription directly | ||
echo "Registering the subscription directly..." | ||
curl -k -X PUT \ | ||
-H 'Content-Type: application/json' \ | ||
-d '{ | ||
"state": "Registered", | ||
"properties": { | ||
"tenantId": "'"$AZURE_TENANT_ID"'", | ||
"registeredFeatures": [ | ||
{ | ||
"name": "Microsoft.RedHatOpenShift/RedHatEngineering", | ||
"state": "Registered" | ||
} | ||
] | ||
} | ||
}' "https://localhost:8443/subscriptions/$AZURE_SUBSCRIPTION_ID?api-version=2.0" | ||
|
||
# Validate RP running | ||
validate_rp_running | ||
|
||
# Function to add supported OpenShift version | ||
add_openshift_version() { | ||
local version=$1 | ||
local openshift_pullspec=$2 | ||
local installer_pullspec=$3 | ||
|
||
echo "Adding OpenShift version $version..." | ||
curl -k -X PUT "https://localhost:8443/admin/versions" --header "Content-Type: application/json" -d '{ | ||
"properties": { | ||
"version": "'"$version"'", | ||
"enabled": true, | ||
"openShiftPullspec": "'"$openshift_pullspec"'", | ||
"installerPullspec": "'"$installer_pullspec"'" | ||
} | ||
}' | ||
} | ||
|
||
# Add the required OpenShift version | ||
add_openshift_version "$OPENSHIFT_VERSION" "$OCP_PULLSPEC" "$INSTALLER_PULLSPEC" | ||
|
||
# Delete the existing cluster if it exists | ||
echo "Deleting the existing cluster if it exists..." | ||
az aro delete --resource-group $CLUSTER_RESOURCEGROUP --name $CLUSTER_NAME --yes --no-wait || true | ||
|
||
# Wait for the cluster deletion to complete | ||
echo "Waiting for the cluster to be deleted..." | ||
while az aro show --name $CLUSTER_NAME --resource-group $CLUSTER_RESOURCEGROUP &> /dev/null; do | ||
echo "Cluster is still being deleted...waiting 30 seconds." | ||
sleep 30 | ||
done | ||
|
||
# Create resource group | ||
echo "Creating resource group $CLUSTER_RESOURCEGROUP in $LOCATION..." | ||
az group create --name $CLUSTER_RESOURCEGROUP --location $LOCATION | ||
|
||
# Create virtual network | ||
echo "Creating virtual network $CLUSTER_VNET in $CLUSTER_RESOURCEGROUP..." | ||
az network vnet create --resource-group $CLUSTER_RESOURCEGROUP --name $CLUSTER_VNET --address-prefixes 10.0.0.0/22 | ||
|
||
# Delete any existing subnets and associated resources | ||
echo "Deleting any existing master subnet resources..." | ||
az network vnet subnet delete --resource-group $CLUSTER_RESOURCEGROUP --vnet-name $CLUSTER_VNET --name $CLUSTER_MASTER_SUBNET || true | ||
|
||
echo "Deleting any existing worker subnet resources..." | ||
az network vnet subnet delete --resource-group $CLUSTER_RESOURCEGROUP --vnet-name $CLUSTER_VNET --name $CLUSTER_WORKER_SUBNET || true | ||
|
||
# Create master subnet | ||
echo "Creating master subnet $CLUSTER_MASTER_SUBNET in $CLUSTER_VNET..." | ||
az network vnet subnet create --resource-group $CLUSTER_RESOURCEGROUP --vnet-name $CLUSTER_VNET --name $CLUSTER_MASTER_SUBNET --address-prefixes 10.0.0.0/23 --service-endpoints Microsoft.ContainerRegistry | ||
|
||
# Create worker subnet | ||
echo "Creating worker subnet $CLUSTER_WORKER_SUBNET in $CLUSTER_VNET..." | ||
az network vnet subnet create --resource-group $CLUSTER_RESOURCEGROUP --vnet-name $CLUSTER_VNET --name $CLUSTER_WORKER_SUBNET --address-prefixes 10.0.2.0/23 --service-endpoints Microsoft.ContainerRegistry | ||
|
||
# Create cluster | ||
echo "Creating cluster $CLUSTER_NAME in $CLUSTER_RESOURCEGROUP..." | ||
az aro create --resource-group $CLUSTER_RESOURCEGROUP --name $CLUSTER_NAME --vnet $CLUSTER_VNET --master-subnet $CLUSTER_MASTER_SUBNET --worker-subnet $CLUSTER_WORKER_SUBNET --pull-secret "$PULL_SECRET" --location $LOCATION --version $OPENSHIFT_VERSION || { | ||
echo "Cluster creation failed. Fetching deployment logs..." | ||
|
||
# Fetch the deployment logs for further analysis | ||
deployment_name=$(az deployment group list --resource-group $CLUSTER_RESOURCEGROUP --query '[0].name' -o tsv) | ||
if [ -n "$deployment_name" ]; then | ||
az deployment group show --name $deployment_name --resource-group $CLUSTER_RESOURCEGROUP | ||
else | ||
echo "No deployment found for resource group $CLUSTER_RESOURCEGROUP." | ||
fi | ||
|
||
exit 1 | ||
} | ||
|
||
# Check for the existence of the cluster | ||
if az aro show --name $CLUSTER_NAME --resource-group $CLUSTER_RESOURCEGROUP &> /dev/null; then | ||
echo "Cluster creation successful." | ||
else | ||
echo "Cluster creation failed. Please check the logs for more details." | ||
exit 1 | ||
fi | ||
|
||
echo "To list cluster credentials, run:" | ||
echo " az aro list-credentials --name $CLUSTER_NAME --resource-group $CLUSTER_RESOURCEGROUP" | ||
|
||
echo "Note: Do not manually delete any resources. Let the script handle the deletions to avoid issues." |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we change this back to
eastus
? I believewesteurope
was used because of some issues with the region during the work.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's leave it as it is. It's up to the folks which location they want, so they can modify it accordingly on their end.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are still issues in
eastus
atm fyi