Skip to content

Instantly share code, notes, and snippets.

@yuhkih
Last active January 16, 2023 15:26
Show Gist options
  • Select an option

  • Save yuhkih/79c2ed1eaa2e999c4fa6b8aa34b1312c to your computer and use it in GitHub Desktop.

Select an option

Save yuhkih/79c2ed1eaa2e999c4fa6b8aa34b1312c to your computer and use it in GitHub Desktop.

Revisions

  1. yuhkih revised this gist Jan 16, 2023. 1 changed file with 21 additions and 8 deletions.
    29 changes: 21 additions & 8 deletions create-rosa-privatelink-cluster.sh
    Original file line number Diff line number Diff line change
    @@ -1,10 +1,21 @@
    #!/bin/bash

    # rosa CLI parameters
    # ------------------------------------------------------
    # Make sure aws cli is configured properly before run this shell
    # ------------------------------------------------------
    # History
    # 2023/01/16 yuhkih initial creation

    # ------------------------------------------------------
    # Basic Information
    # ------------------------------------------------------
    ClusterName=mycluster
    RosaCIDR="10.0.0.0/16"
    NumberOfWorkers="6"

    # ------------------------------------------------------
    # Get ROSA VPC subnetIds
    # ------------------------------------------------------
    export PrivateSubnetID1=`aws ec2 describe-subnets | jq -r '.Subnets[] | [ .CidrBlock, .SubnetId, .AvailabilityZone, .Tags[].Value ] | @csv' | grep PrivateSubnet1 | awk -F'[,]' '{print $2}' | sed 's/"//g'`
    export PrivateSubnetID2=`aws ec2 describe-subnets | jq -r '.Subnets[] | [ .CidrBlock, .SubnetId, .AvailabilityZone, .Tags[].Value ] | @csv' | grep PrivateSubnet2 | awk -F'[,]' '{print $2}' | sed 's/"//g'`
    export PrivateSubnetID3=`aws ec2 describe-subnets | jq -r '.Subnets[] | [ .CidrBlock, .SubnetId, .AvailabilityZone, .Tags[].Value ] | @csv' | grep PrivateSubnet3 | awk -F'[,]' '{print $2}' | sed 's/"//g'`
    @@ -27,7 +38,7 @@ WORKER_ROLE=`aws iam list-roles | jq -r '.Roles[] | [.RoleName, .Arn] | @csv' |
    # Check parameters are set before creating cluster
    # ---------------------------
    echo "=============================================================="
    echo "[install parameters]"
    echo "[log] install parameters"
    echo "RosaCIDR = " $RosaCIDR
    echo "ClusterName = " $ClusterName
    echo "PrivateSubnetID1 = " $PrivateSubnetID1
    @@ -41,22 +52,25 @@ echo "SUPPORT_ROLE = "$SUPPORT_ROLE
    echo "CONTROL_PLANE_ROLE = " $CONTROL_PLANE_ROLE
    echo "WORKER_ROLE = " $WORKER_ROLE
    echo "RosaCIDR = " $RosaCIDR
    echo "NumberOfWorkers = "$NumberOfWorkers
    echo "=============================================================="

    echo "Wait for 10 seconds"
    echo "[NOTICE!] If there is any unset parameter, that means something is wrong. Quit within 10 seconds by Ctrl +C"
    echo "[NOTICE!] If there is any unset parameter, that means something is wrong. Quit within 10 seconds by pressing Ctrl +C"
    echo "[NOTICE!] If every parameter has a value. Wait for a moment. The cluster installation will start soon "
    sleep 20

    # ---------------------------------------
    # Create ROSA cluster (Multi AZ)
    # ---------------------------------------
    echo "=============================================================="
    echo "[log] run rosa create cluster"
    rosa create cluster --cluster-name $ClusterName --sts \
    --role-arn $INSTALL_ROLE \
    --support-role-arn $SUPPORT_ROLE \
    --controlplane-iam-role $CONTROL_PLANE_ROLE \
    --worker-iam-role $WORKER_ROLE \
    --multi-az --region ap-northeast-1 --version 4.11.21 --compute-nodes 6 --compute-machine-type m5.xlarge \
    --multi-az --region ap-northeast-1 --version 4.11.21 --compute-nodes $NumberOfWorkers --compute-machine-type m5.xlarge \
    --machine-cidr $RosaCIDR --service-cidr 172.30.0.0/16 --pod-cidr 10.128.0.0/14 --host-prefix 23 \
    --private-link \
    --subnet-ids $PrivateSubnetID1,$PrivateSubnetID2,$PrivateSubnetID3 \
    @@ -66,23 +80,22 @@ rosa create cluster --cluster-name $ClusterName --sts \
    # After "rosa create cluster"
    # create operator roles and OIDC Provider
    # ------------------------------------------------
    echo "==================================================================="
    echo "=============================================================="
    echo "[log] create operator roles and oidc provider"
    rosa create operator-roles -y -m auto --cluster $ClusterName
    rosa create oidc-provider -y -m auto --cluster $ClusterName

    # ------------------------------------------------
    # Wait until the cuslter becomes ready
    # ------------------------------------------------
    echo "==================================================================="
    echo "=============================================================="
    echo "[log] monitor installation completion"
    rosa logs install -c $ClusterName --watch


    # ---------------------------
    # Create ROSA admin user
    # ---------------------------
    # create cluster admin after cluster installation completes
    echo "==================================================================="
    echo "=============================================================="
    echo "[log] create admin user"
    rosa create admin -c $ClusterName
  2. yuhkih revised this gist Jan 16, 2023. 1 changed file with 12 additions and 1 deletion.
    13 changes: 12 additions & 1 deletion create-rosa-privatelink-cluster.sh
    Original file line number Diff line number Diff line change
    @@ -71,7 +71,18 @@ echo "[log] create operator roles and oidc provider"
    rosa create operator-roles -y -m auto --cluster $ClusterName
    rosa create oidc-provider -y -m auto --cluster $ClusterName

    # ------------------------------------------------
    # Wait until the cuslter becomes ready
    # ------------------------------------------------
    echo "==================================================================="
    echo "[log] monitor installation completion"
    rosa logs install -c $ClusterName --watch
    rosa logs install -c $ClusterName --watch


    # ---------------------------
    # Create ROSA admin user
    # ---------------------------
    # create cluster admin after cluster installation completes
    echo "==================================================================="
    echo "[log] create admin user"
    rosa create admin -c $ClusterName
  3. yuhkih renamed this gist Jan 16, 2023. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  4. yuhkih revised this gist Jan 16, 2023. 1 changed file with 30 additions and 15 deletions.
    45 changes: 30 additions & 15 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -1,11 +1,4 @@
    How to create ROSA cluster

    1. Deploy multi AZ network for ROSA Cluster with PrivateLink

    2. set up aws cli
    aws configure

    3. Set up necessary parameters
    #!/bin/bash

    # rosa CLI parameters
    ClusterName=mycluster
    @@ -33,23 +26,31 @@ WORKER_ROLE=`aws iam list-roles | jq -r '.Roles[] | [.RoleName, .Arn] | @csv' |
    # ---------------------------
    # Check parameters are set before creating cluster
    # ---------------------------
    echo "=============================================================="
    echo "[install parameters]"
    echo "RosaCIDR = " $RosaCIDR
    echo "ClusterName = " $ClusterName
    echo "PrivateSubnetID1 = " $PrivateSubnetID1
    echo "PrivateSubnetID2 = " $PrivateSubnetID2
    echo "PrivateSubnetID3 = " $PrivateSubnetID3
    echo "FwSubnetID1 = " $FwSubnetID1
    echo "FwSubnetID2 = " $FwSubnetID2
    echo "FwSubnetID3 = " $FwSubnetID3
    # echo "FwSubnetID1 = " $FwSubnetID1
    # echo "FwSubnetID2 = " $FwSubnetID2
    # echo "FwSubnetID3 = " $FwSubnetID3
    echo "INSTALL_ROLE = " $INSTALL_ROLE
    echo "SUPPORT_ROLE = "$SUPPORT_ROLE
    echo "CONTROL_PLANE_ROLE = " $CONTROL_PLANE_ROLE
    echo "WORKER_ROLE = " $WORKER_ROLE
    echo "RosaCIDR = " $RosaCIDR
    echo "=============================================================="

    echo "Wait for 10 seconds"
    echo "[NOTICE!] If there is any unset parameter, that means something is wrong. Quit within 10 seconds by Ctrl +C"
    echo "[NOTICE!] If every parameter has a value. Wait for a moment. The cluster installation will start soon "
    sleep 20

    4 . Create ROSA cluster (Multi AZ)

    # ---------------------------------------
    # Create ROSA cluster (Multi AZ)
    # ---------------------------------------
    rosa create cluster --cluster-name $ClusterName --sts \
    --role-arn $INSTALL_ROLE \
    --support-role-arn $SUPPORT_ROLE \
    @@ -58,5 +59,19 @@ rosa create cluster --cluster-name $ClusterName --sts \
    --multi-az --region ap-northeast-1 --version 4.11.21 --compute-nodes 6 --compute-machine-type m5.xlarge \
    --machine-cidr $RosaCIDR --service-cidr 172.30.0.0/16 --pod-cidr 10.128.0.0/14 --host-prefix 23 \
    --private-link \
    --subnet-ids $PrivateSubnetID1,$PrivateSubnetID2,$PrivateSubnetID3
    -y
    --subnet-ids $PrivateSubnetID1,$PrivateSubnetID2,$PrivateSubnetID3 \
    -y

    # ------------------------------------------------
    # After "rosa create cluster"
    # create operator roles and OIDC Provider
    # ------------------------------------------------
    echo "==================================================================="
    echo "[log] create operator roles and oidc provider"
    rosa create operator-roles -y -m auto --cluster $ClusterName
    rosa create oidc-provider -y -m auto --cluster $ClusterName

    # Wait until the cuslter becomes ready
    echo "==================================================================="
    echo "[log] monitor installation completion"
    rosa logs install -c $ClusterName --watch
  5. yuhkih created this gist Jan 16, 2023.
    62 changes: 62 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,62 @@
    How to create ROSA cluster

    1. Deploy multi AZ network for ROSA Cluster with PrivateLink

    2. set up aws cli
    aws configure

    3. Set up necessary parameters

    # rosa CLI parameters
    ClusterName=mycluster
    RosaCIDR="10.0.0.0/16"

    # Get ROSA VPC subnetIds
    export PrivateSubnetID1=`aws ec2 describe-subnets | jq -r '.Subnets[] | [ .CidrBlock, .SubnetId, .AvailabilityZone, .Tags[].Value ] | @csv' | grep PrivateSubnet1 | awk -F'[,]' '{print $2}' | sed 's/"//g'`
    export PrivateSubnetID2=`aws ec2 describe-subnets | jq -r '.Subnets[] | [ .CidrBlock, .SubnetId, .AvailabilityZone, .Tags[].Value ] | @csv' | grep PrivateSubnet2 | awk -F'[,]' '{print $2}' | sed 's/"//g'`
    export PrivateSubnetID3=`aws ec2 describe-subnets | jq -r '.Subnets[] | [ .CidrBlock, .SubnetId, .AvailabilityZone, .Tags[].Value ] | @csv' | grep PrivateSubnet3 | awk -F'[,]' '{print $2}' | sed 's/"//g'`

    # ------------------------------------------------------
    # Create IAMRole and set them to variables
    # ------------------------------------------------------
    rosa create account-roles -m auto -y

    # ------------------------------------------------------
    # Get Necessary parameter for CLI installation
    # ------------------------------------------------------
    INSTALL_ROLE=`aws iam list-roles | jq -r '.Roles[] | [.RoleName, .Arn] | @csv' | grep ManagedOpenShift-Installer-Role | awk -F'[,]' '{print $2}' | sed 's/"//g'`
    SUPPORT_ROLE=`aws iam list-roles | jq -r '.Roles[] | [.RoleName, .Arn] | @csv' | grep ManagedOpenShift-Support-Role | awk -F'[,]' '{print $2}' | sed 's/"//g'`
    CONTROL_PLANE_ROLE=`aws iam list-roles | jq -r '.Roles[] | [.RoleName, .Arn] | @csv' | grep ManagedOpenShift-ControlPlane-Role | awk -F'[,]' '{print $2}' | sed 's/"//g'`
    WORKER_ROLE=`aws iam list-roles | jq -r '.Roles[] | [.RoleName, .Arn] | @csv' | grep ManagedOpenShift-Worker-Role | awk -F'[,]' '{print $2}' | sed 's/"//g'`


    # ---------------------------
    # Check parameters are set before creating cluster
    # ---------------------------
    echo "RosaCIDR = " $RosaCIDR
    echo "ClusterName = " $ClusterName
    echo "PrivateSubnetID1 = " $PrivateSubnetID1
    echo "PrivateSubnetID2 = " $PrivateSubnetID2
    echo "PrivateSubnetID3 = " $PrivateSubnetID3
    echo "FwSubnetID1 = " $FwSubnetID1
    echo "FwSubnetID2 = " $FwSubnetID2
    echo "FwSubnetID3 = " $FwSubnetID3
    echo "INSTALL_ROLE = " $INSTALL_ROLE
    echo "SUPPORT_ROLE = "$SUPPORT_ROLE
    echo "CONTROL_PLANE_ROLE = " $CONTROL_PLANE_ROLE
    echo "WORKER_ROLE = " $WORKER_ROLE
    echo "RosaCIDR = " $RosaCIDR


    4 . Create ROSA cluster (Multi AZ)

    rosa create cluster --cluster-name $ClusterName --sts \
    --role-arn $INSTALL_ROLE \
    --support-role-arn $SUPPORT_ROLE \
    --controlplane-iam-role $CONTROL_PLANE_ROLE \
    --worker-iam-role $WORKER_ROLE \
    --multi-az --region ap-northeast-1 --version 4.11.21 --compute-nodes 6 --compute-machine-type m5.xlarge \
    --machine-cidr $RosaCIDR --service-cidr 172.30.0.0/16 --pod-cidr 10.128.0.0/14 --host-prefix 23 \
    --private-link \
    --subnet-ids $PrivateSubnetID1,$PrivateSubnetID2,$PrivateSubnetID3
    -y