exportCLUSTER_NAME=demo-lz
exportCLUSTER_BASEDOMAIN="devcluster.openshift.com"exportPULL_SECRET_PATH="$HOME/.openshift/pull-secret-latest.json"exportSSH_KEYS="$(cat~/.ssh/id_rsa.pub)"exportAWS_REGION=us-east-1
# VPCexportSTACK_VPC=${CLUSTER_NAME}-vpc
awscloudformationcreate-stack--stack-name${STACK_VPC}\--template-bodyfile://template-vpc.yaml\--parameters\ParameterKey=ClusterName,ParameterValue=${CLUSTER_NAME}\ParameterKey=VpcCidr,ParameterValue="10.0.0.0/16"\ParameterKey=AvailabilityZoneCount,ParameterValue=3\ParameterKey=SubnetBits,ParameterValue=12awscloudformationwaitstack-create-complete--stack-name${STACK_VPC}awscloudformationdescribe-stacks--stack-name${STACK_VPC}# Local Zone subnetexportSTACK_LZ=${CLUSTER_NAME}-lz-nyc-1a
exportZONE_GROUP_NAME=${AWS_REGION}-nyc-1
exportVPC_ID=$(awscloudformationdescribe-stacks\--stack-name${STACK_VPC}\|jq-r'.Stacks[0].Outputs[] | select(.OutputKey=="VpcId").OutputValue')exportVPC_RTB_PUB=$(awscloudformationdescribe-stacks\--stack-name${STACK_VPC}\|jq-r'.Stacks[0].Outputs[] | select(.OutputKey=="PublicRouteTableId").OutputValue')awsec2modify-availability-zone-group\--group-name"${ZONE_GROUP_NAME}"\--opt-in-statusopted-in
awscloudformationcreate-stack--stack-name${STACK_LZ}\--template-bodyfile://template-lz.yaml\--parameters\ParameterKey=ClusterName,ParameterValue="${CLUSTER_NAME}"\ParameterKey=VpcId,ParameterValue="${VPC_ID}"\ParameterKey=PublicRouteTableId,ParameterValue="${VPC_RTB_PUB}"\ParameterKey=LocalZoneName,ParameterValue="${ZONE_GROUP_NAME}a"\ParameterKey=LocalZoneNameShort,ParameterValue="nyc-1a"\ParameterKey=PublicSubnetCidr,ParameterValue="10.0.128.0/20"awscloudformationwaitstack-create-complete--stack-name${STACK_LZ}awscloudformationdescribe-stacks--stack-name${STACK_LZ}mapfile-tSUBNETS<<(awscloudformationdescribe-stacks\--stack-name"${STACK_VPC}"\|jq-r'.Stacks[0].Outputs[0].OutputValue'|tr',''\n')mapfile-t-O"${#SUBNETS[@]}"SUBNETS<<(awscloudformationdescribe-stacks\--stack-name"${STACK_VPC}"\|jq-r'.Stacks[0].Outputs[1].OutputValue'|tr',''\n')# Set the SUBNET_ID to be used laterexportSUBNET_ID=$(awscloudformationdescribe-stacks--stack-name"${STACK_LZ}"\|jq-r.Stacks[0].Outputs[0].OutputValue)# Append the Local Zone subnet to the subnet ID listSUBNETS+=(${SUBNET_ID})cat<<EOF > ${PWD}/install-config.yamlapiVersion: v1publish: ExternalbaseDomain: "${CLUSTER_BASEDOMAIN}"metadata: name: "${CLUSTER_NAME}"platform: aws: region: ${AWS_REGION} subnets:$(for SB in ${SUBNETS[*]}; do echo " - $SB"; done)pullSecret: '$(cat ${PULL_SECRET_PATH} | awk -v ORS= -v OFS= '{$1=$1}1')'sshKey: | ${SSH_KEYS}EOFgrep-A7subnets${PWD}/install-config.yaml
cp${PWD}/install-config.yaml${PWD}/install-config.yaml-bkp
./openshift-installcreatemanifests
lsmanifests/cluster-network-*
lsopenshift/99_openshift-cluster-api_worker-machineset-*
./openshift-installcreatecluster
# Wait for the cluster creationexportKUBECONFIG=$PWD/auth/kubeconfig
ocgetnodes-lnode-role.kubernetes.io/edge
ocgetmachineset-nopenshift-machine-api
ocgetmachine-nopenshift-machine-api
Create new node in Day 2
create zone in bue
# Local Zone subnetexportSTACK_LZ=${CLUSTER_NAME}-lz-bue-1a
exportZONE_GROUP_NAME=${AWS_REGION}-bue-1
exportCIDR_BLOCK=10.0.144.0/20
exportVPC_ID=$(awscloudformationdescribe-stacks\--stack-name${STACK_VPC}\|jq-r'.Stacks[0].Outputs[] | select(.OutputKey=="VpcId").OutputValue')exportVPC_RTB_PUB=$(awscloudformationdescribe-stacks\--stack-name${STACK_VPC}\|jq-r'.Stacks[0].Outputs[] | select(.OutputKey=="PublicRouteTableId").OutputValue')awsec2modify-availability-zone-group\--group-name"${ZONE_GROUP_NAME}"\--opt-in-statusopted-in
awscloudformationcreate-stack--stack-name${STACK_LZ}\--template-bodyfile://template-lz.yaml\--parameters\ParameterKey=ClusterName,ParameterValue="${CLUSTER_NAME}"\ParameterKey=VpcId,ParameterValue="${VPC_ID}"\ParameterKey=PublicRouteTableId,ParameterValue="${VPC_RTB_PUB}"\ParameterKey=LocalZoneName,ParameterValue="${ZONE_GROUP_NAME}a"\ParameterKey=LocalZoneNameShort,ParameterValue="bue-1a"\ParameterKey=PublicSubnetCidr,ParameterValue="${CIDR_BLOCK}"awscloudformationwaitstack-create-complete--stack-name${STACK_LZ}awscloudformationdescribe-stacks--stack-name${STACK_LZ}exportSUBNET_ID_BUE=$(awscloudformationdescribe-stacks--stack-name"${STACK_LZ}"\|jq-r.Stacks[0].Outputs[0].OutputValue)
Create machineset
awsec2describe-instance-type-offerings\--location-typeavailability-zone\--filtersName=location,Values=${AWS_REGION}-bue-1a\--region${AWS_REGION}exportINSTANCE_BUE=m5.2xlarge
BASE_MANIFEST=$(ocgetmachineset-nopenshift-machine-api-ojsonpath='{range .items[*].metadata}{.name}{"\n"}{end}'|grepnyc-1)ocgetmachineset-nopenshift-machine-api$BASE_MANIFEST-oyaml>machineset-lz-bue-1a.yaml
# replace the subnet ID from NYC to BUEsed-si"s/${SUBNET_ID}/${SUBNET_ID_BUE}/g"machineset-lz-bue-1a.yaml
# replace the zone reference from NYC to BUEsed-si"s/nyc-1/bue-1/g"machineset-lz-bue-1a.yaml
# replace the instance type to a new onecurrent_instance=$(ocgetmachineset-nopenshift-machine-api$BASE_MANIFEST-ojsonpath='{.spec.template.spec.providerSpec.value.instanceType}')sed-si"s/${current_instance}/${INSTANCE_BUE}/g"machineset-lz-bue-1a.yaml
occreate-fmachineset-lz-bue-1a.yaml
ocgetmachines-w-nopenshift-machine-api-lmachine.openshift.io/cluster-api-machine-role=edge
Installing ALB Operator (not covered by the blog / out of scope)