Az / Create Aks Cluster
Create Aks Cluster
Creates an Azure Kubernetes Service cluster.
az aks create -g <resource_group> -n <name> -c <count> --node-vm-size <size> az aks create -g <resource_group> -n <name> -c <count> --node-vm-size <size> #!/bin/bash
# Create Aks Cluster
az aks create {{[-g|--resource-group]}} {{resource_group}} {{[-n|--name]}} {{name}} {{[-c|--node-count]}} {{count}} --node-vm-size {{size}} import subprocess
# Create Aks Cluster
# Make sure to replace <placeholders> with actual values
def run_command():
cmd = [
"az",
"aks",
"create",
"-g",
"<resource_group>",
"-n",
"<name>",
"-c",
"<count>",
"--node-vm-size",
"<size>"
]
try:
print(f"Executing: {' '.join(cmd)}")
subprocess.run(cmd, check=True)
except subprocess.CalledProcessError as e:
print(f"Error: {e}")
except FileNotFoundError:
print("Error: az not found. Please install it first.")
if __name__ == "__main__":
run_command() When To Use
When deploying new applications that require orchestration services.
Pro Tip
Specify `--kubernetes-version` to ensure compatibility with existing workloads; check Azure's supported versions.
Terminal Output
Expected runtime feedback
Creating AKS cluster...
Resource Group: myResourceGroup
Cluster Name: myAKSCluster
Node Count: 3
Node VM Size: Standard_DS2_v2
INFO: Successful cluster creation.
INFO: You can connect to the AKS cluster with the following command:
az aks get-credentials --resource-group myResourceGroup --name myAKSCluster Anatomy of Output
Understanding the result
Name: MyAKSCluster Cluster Name Indicates the name of the newly created AKS cluster.
Node Count: 3 Node Count Displays the number of nodes allocated for the cluster.
Provisioning State: Succeeded Provisioning Status Confirms that the AKS cluster is in a ready state.
Power User Variants
Optimized versions
az aks create -g resource_group -n cluster_name -c 3 --node-vm-size Standard_DS2_v2 Create an AKS cluster with specified VM size and count.
az aks create -g resource_group -n cluster_name --enable-addons monitoring Create an AKS cluster with monitoring enabled.
Troubleshooting
Common pitfalls
Error creating the AKS cluster: quota exceeded.
Solution: Review your Azure subscription quotas and possibly increase limits.
InvalidParameter: VM size not supported.
Solution: Check Azure's VM size compatibility for AKS.
Error: resource group not found.
Solution: Ensure the specified resource group exists in Azure.
Command Breakdown
What each part is doing
-
az - Base Command
- The executable that performs this operation. Here it runs Az before the shell applies any redirect operators.
-
-g - g| resource group
- The value supplied for g| resource group.
-
<resource_group> - resource group
- The value supplied for resource group.
-
-n - n| name
- The value supplied for n| name.
-
<name> - name
- The value supplied for name.
-
-c - c| node count
- The value supplied for c| node count.
-
<count> - count
- The value supplied for count.
-
<size> - size
- The value supplied for size.
-
-g - Command Option
- Tool-specific option used by this command invocation.
-
-n - Command Option
- Tool-specific option used by this command invocation.
-
-c - Command Option
- Tool-specific option used by this command invocation.
-
--node-vm-size - Command Option
- Tool-specific option used by this command invocation.
How To Run
Execution path
- Step 1
Run: az aks create -g myResourceGroup -n myAKSCluster -c 3 --node-vm-size Standard_DS2_v2
- Step 2
Verify the creation using: az aks show -g myResourceGroup -n myAKSCluster
Alternative Approaches
Comparable commands in other tools
Alternative cloud infrastructure tools for the same job.
gcloud compute ssh <user>@<instance> Flyctl / View Status Of Specific Application flyctl status --app <app_name> Aws / Delete Eks Cluster 1608 aws eks delete-cluster --name <cluster_name> Gh / Create Codespace Github Interactively gh cs create Cradle / Submit Elasticsearch Schema cradle elastic map