Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 30 additions & 4 deletions rhdp/rhdp-cluster-define.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,22 @@
from typing_extensions import Annotated


def get_default_cluster_configs() -> List[Dict]:
"""Get default cluster configurations"""
def get_default_cluster_configs(prefix: str = "") -> List[Dict]:
"""Get default cluster configurations

Args:
prefix: Optional prefix to add to cluster name and directory
"""
if prefix:
return [
{
"name": f"coco-{prefix}",
"directory": f"openshift-install-{prefix}",
"cluster_network_cidr": "10.128.0.0/14",
"machine_network_cidr": "10.0.0.0/16",
"service_network_cidr": "172.30.0.0/16",
}
]
return [
{
"name": "coco",
Expand Down Expand Up @@ -135,23 +149,35 @@ def run(
multicluster: Annotated[
bool, typer.Option("--multicluster", help="Deploy hub and spoke clusters")
] = False,
prefix: Annotated[
str, typer.Option("--prefix", help="Prefix for cluster name and directory")
] = "",
):
"""
Region flag requires an azure region key which can be (authoritatively)
requested with: "az account list-locations -o table".

Use --multicluster flag to deploy both hub (coco-hub) and spoke (coco-spoke)
clusters.

Use --prefix to add a prefix to cluster name and install directory, enabling
multiple cluster deployments (e.g., --prefix cluster1 creates coco-cluster1
in openshift-install-cluster1).
"""
validate_dir()

# Choose cluster configurations based on multicluster flag
if multicluster:
if prefix:
rprint("WARNING: --prefix is ignored when using --multicluster")
cluster_configs = get_multicluster_configs()
rprint("Setting up multicluster deployment (hub and spoke)")
else:
cluster_configs = get_default_cluster_configs()
rprint("Setting up single cluster deployment")
cluster_configs = get_default_cluster_configs(prefix)
if prefix:
rprint(f"Setting up single cluster deployment with prefix: {prefix}")
else:
rprint("Setting up single cluster deployment")

cleanup(pathlib.Path.cwd(), cluster_configs)
setup_install(
Expand Down
61 changes: 54 additions & 7 deletions rhdp/wrapper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,56 @@ get_python_cmd() {
fi
}

if [ "$#" -ne 1 ]; then
echo "Error: Exactly one argument is required."
echo "Usage: $0 {azure-region-code}"
# Parse arguments
AZUREREGION=""
PREFIX=""

while [[ $# -gt 0 ]]; do
case $1 in
--prefix)
PREFIX="$2"
shift 2
;;
--prefix=*)
PREFIX="${1#*=}"
shift
;;
-*)
echo "Error: Unknown option $1"
echo "Usage: $0 [--prefix <prefix>] {azure-region-code}"
echo "Example: $0 eastasia"
echo "Example: $0 --prefix cluster1 eastasia"
exit 1
;;
*)
if [ -z "$AZUREREGION" ]; then
AZUREREGION="$1"
else
echo "Error: Too many positional arguments."
echo "Usage: $0 [--prefix <prefix>] {azure-region-code}"
exit 1
fi
shift
;;
esac
done

if [ -z "$AZUREREGION" ]; then
echo "Error: Azure region is required."
echo "Usage: $0 [--prefix <prefix>] {azure-region-code}"
echo "Example: $0 eastasia"
echo "Example: $0 --prefix cluster1 eastasia"
exit 1
fi
AZUREREGION=$1

# Set install directory based on prefix
if [ -n "$PREFIX" ]; then
INSTALL_DIR="openshift-install-${PREFIX}"
echo "Using prefix: $PREFIX"
echo "Install directory: $INSTALL_DIR"
else
INSTALL_DIR="openshift-install"
fi

echo "---------------------"
echo "Validating configuration"
Expand Down Expand Up @@ -113,15 +156,19 @@ echo "---------------------"
echo "defining cluster"
echo "---------------------"
PYTHON_CMD=$(get_python_cmd)
$PYTHON_CMD rhdp/rhdp-cluster-define.py ${AZUREREGION}
if [ -n "$PREFIX" ]; then
$PYTHON_CMD rhdp/rhdp-cluster-define.py --prefix "${PREFIX}" ${AZUREREGION}
else
$PYTHON_CMD rhdp/rhdp-cluster-define.py ${AZUREREGION}
fi
echo "---------------------"
echo "cluster defined"
echo "---------------------"
sleep 10
echo "---------------------"
echo "openshift-install"
echo "---------------------"
openshift-install create cluster --dir=./openshift-install
openshift-install create cluster --dir=./${INSTALL_DIR}
echo "openshift-install done"
echo "---------------------"
echo "setting up secrets"
Expand All @@ -133,7 +180,7 @@ sleep 60
echo "---------------------"
echo "pattern install"
echo "---------------------"
export KUBECONFIG="$(pwd)/openshift-install/auth/kubeconfig"
export KUBECONFIG="$(pwd)/${INSTALL_DIR}/auth/kubeconfig"


./pattern.sh make install
Expand Down
4 changes: 2 additions & 2 deletions values-simple.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ clusterGroup:
source: redhat-operators
channel: stable
installPlanApproval: Manual
csv: sandboxed-containers-operator.v1.10.1
csv: sandboxed-containers-operator.v1.11.0
trustee:
name: trustee-operator
namespace: trustee-operator-system
source: redhat-operators
channel: stable
installPlanApproval: Manual
csv: trustee-operator.v0.4.1
csv: trustee-operator.v1.0.0
cert-manager:
name: openshift-cert-manager-operator
namespace: cert-manager-operator
Expand Down
Loading