Create new AKS cluster using OCLI

The following document shows how to create a new Azure EKS cluster using OCLI

Prerequisites

  1. Install git if not already present.
  2. Install azure cli >= 2.50.
  3. Log in and set a subscription. Please ensure that the user has Contributor and RBAC admin roles in the Subscription
# login
az login

# setting the subscription
az account set --subscription $SUBSCRIPTION_ID

📘

Suggestion

We highly recommend you to please go through the Azure Infrastructure requirementscarefully.

Installing OCLI

  1. Download the binary using the below command.
    curl -H 'Cache-Control: max-age=0' -s "https://releases.ocli.truefoundry.tech/binaries/ocli_$(curl -H 'Cache-Control: max-age=0' -s https://releases.ocli.truefoundry.tech/stable.txt)_darwin_arm64" -o ocli
    
    curl -H 'Cache-Control: max-age=0' -s "https://releases.ocli.truefoundry.tech/binaries/ocli_$(curl -H 'Cache-Control: max-age=0' -s https://releases.ocli.truefoundry.tech/stable.txt)_darwin_amd64" -o ocli
    
    curl -H 'Cache-Control: max-age=0' -s "https://releases.ocli.truefoundry.tech/binaries/ocli_$(curl -H 'Cache-Control: max-age=0' -s https://releases.ocli.truefoundry.tech/stable.txt)_linux_arm64" -o ocli
    
    curl -H 'Cache-Control: max-age=0' -s "https://releases.ocli.truefoundry.tech/binaries/ocli_$(curl -H 'Cache-Control: max-age=0' -s https://releases.ocli.truefoundry.tech/stable.txt)_linux_amd64" -o ocli
    
  2. Make the binary executable and move it to $PATH
    sudo chmod +x ./ocli
    sudo mv ocli /usr/local/bin
    
  3. Confirm by running the command
    ocli --version
    

Configuring input config file

  1. To create a new cluster, you would require your Azure Subscription, Location, Resource Group.
  2. Run the following command to fill in the inputs interactively
    ocli init-compute-plane
    
  3. For networking, there are the following possible configurations:
    1. New resource group & network (Recommended) - This will create a new resource group and a new Virtual network.
    2. Existing resource group with existing network - You can use an existing resource group and an existing Virtual network.
    3. Existing resource group with new network - You can use an existing resource group while creating a new Virtual network
  4. Once all the inputs are filled, an input config file with the nametfy-config.yaml would be generated in your current directory. We highly recommend you to once go through the generated config file and tally your inputs. You can also customize the inputs directly by editing the file. Below is the sample for the same:
aws: null
azure:
    cluster:
        name: coolml
    location: East US
    network:
        existing: true
        subnet_cidr: ""
        subnet_id: /subscriptions/xxxxx-xxxxx-xxxxx-xxxxxxxxx/resourceGroups/existingrg1/providers/Microsoft.Network/virtualNetworks/existingvnet1/subnets/existingvnet1-default-subnet
        vnet_cidr: ""
        vnet_id: /subscriptions/xxxxx-xxxxx-xxxxx-xxxxxxxxx/resourceGroups/existingrg1/providers/Microsoft.Network/virtualNetworks/existingvnet1
        vnet_name: existingvnet1
    resource_group:
        existing: true
        name: resourceGroup1
    state:
        container_name: ""
        resource_group: ""
        storage_account_name: ""
    subscription:
        id: xxxxx-xxxxx-xxxxx-xxxxxxxxx
        name: subscription-name
binaries:
    terraform:
        binary_path: null
    terragrunt:
        binary_path: null
gcp: null
provider: azure
aws: null
azure:
    cluster:
        name: coolml
    location: West US
    network:
        existing: false
        subnet_cidr: 10.10.0.0/16
        subnet_id: ""
        vnet_cidr: 10.0.0.0/8
        vnet_id: ""
        vnet_name: ""
    resource_group:
        existing: true
        name: existingrg1
    state:
        container_name: ""
        resource_group: ""
        storage_account_name: ""
    subscription:
        id: xxxxx-xxxxx-xxxxx-xxxxxxxxx
        name: subscription-name
binaries:
    terraform:
        binary_path: null
    terragrunt:
        binary_path: null
gcp: null
provider: azure
aws: null
azure:
    cluster:
        name: coolml
    location: West US
    network:
        existing: false
        subnet_cidr: 10.10.0.0/16
        subnet_id: ""
        vnet_cidr: 10.0.0.0/8
        vnet_id: ""
        vnet_name: ""
    resource_group:
        existing: false
        name: coolmlrg
    state:
        container_name: ""
        resource_group: ""
        storage_account_name: ""
    subscription:
        id: xxxxx-xxxxx-xxxxx-xxxxxxxxx
        name: subscription-name
binaries:
    terraform:
        binary_path: null
    terragrunt:
        binary_path: null
gcp: null
provider: azure

Create the cluster

Run the following command to create the AKS cluster.

ocli run --file tfy-config.yaml

This command may take around 30-45 minutes to complete.

Connecting the cluster

  1. Head over to the TrueFoundry platform and log in. If you haven't logged in, then you can sign up here.
  2. Once you have logged in, navigate to Integrations tab from the left panel and click on Setup Cluster.
  3. Give the name of the EKS cluster and select the cluster type as Azure AKS.
  4. Copy the resulting ocli command. This command installs the agent in your AKS cluster which will connect your cluster to the TrueFoundry control plane. The command looks similar to the following:
ocli connect-compute-plane --cloud azure-aks --control-plane-url https://coolml.truefoundry.tech \
--token xxxxxxx  --tenant coolml
  1. Run the command from the current directory where your tfy-config.yaml is present.

Saving the output file

Once the above command finishes, save the output using the command below:

ocli output --file tfy-config.yaml > output.txt

Connect your cluster