Last active
February 12, 2021 10:02
-
-
Save nataz77/b9ed0bf6f13d59be9b05c4443a8e5d73 to your computer and use it in GitHub Desktop.
Azure Redhat Openshift creation script
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
#!/bin/bash | |
# shellcheck shell=bash | |
# AUTHOR: github.com/nataz77 | |
# USAGE: ./aro.sh | |
function providers { | |
az provider register -n Microsoft.RedHatOpenShift --wait | |
az provider register -n Microsoft.Compute --wait | |
az provider register -n Microsoft.Storage --wait | |
} | |
function rg { | |
az group create --name "$RESOURCEGROUP" --location "$LOCATION" | |
} | |
function vnet { | |
az network vnet create --resource-group "$RESOURCEGROUP" --name aro-vnet --address-prefixes 10.0.0.0/22 | |
} | |
function subnet { | |
az network vnet subnet create --resource-group "$RESOURCEGROUP" \ | |
--vnet-name aro-vnet \ | |
--name master-subnet \ | |
--address-prefixes 10.0.0.0/23 \ | |
--service-endpoints Microsoft.ContainerRegistry | |
az network vnet subnet create \ | |
--resource-group "$RESOURCEGROUP" \ | |
--vnet-name aro-vnet \ | |
--name worker-subnet \ | |
--address-prefixes 10.0.2.0/23 \ | |
--service-endpoints Microsoft.ContainerRegistry | |
az network vnet subnet update \ | |
--name master-subnet \ | |
--resource-group "$RESOURCEGROUP" \ | |
--vnet-name aro-vnet \ | |
--disable-private-link-service-network-policies true | |
} | |
function aro { | |
echo 'Deploying OpenShift. This is gonna take a while...' | |
az aro create --resource-group "$RESOURCEGROUP" \ | |
--name "$CLUSTER" \ | |
--vnet aro-vnet \ | |
--master-subnet master-subnet \ | |
--worker-subnet worker-subnet | |
echo 'Deployment complete' | |
} | |
function credentials { | |
echo 'Getting cluster credentials' | |
az aro list-credentials \ | |
--name "$CLUSTER" \ | |
--resource-group "$RESOURCEGROUP" | |
echo 'Done!' | |
} | |
function main { | |
providers | |
rg | |
vnet | |
subnet | |
aro | |
credentials | |
} | |
function login { | |
if ! az login; | |
then | |
echo 'Unable to login. Please see the az command output above for more details.' | |
else | |
main | |
fi | |
} | |
LOCATION=westeurope | |
RESOURCEGROUP=aro | |
CLUSTER=inpsaro | |
read -p "Did you login into the az cli? (y/n)" -n 1 -r | |
echo | |
if [[ $REPLY =~ ^[Yy]$ ]] | |
then | |
main | |
else | |
login | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment