|
| 1 | +--- |
| 2 | +title: Create an Azure Nexus Kubernetes cluster by using Azure PowerShell |
| 3 | +description: Learn how to create an Azure Nexus Kubernetes cluster by using Azure PowerShell. |
| 4 | +ms.service: azure-operator-nexus |
| 5 | +author: rashirg |
| 6 | +ms.author: rajeshwarig |
| 7 | +ms.topic: quickstart |
| 8 | +ms.custom: subject-armqs, devx-track-azurepowershell |
| 9 | +ms.date: 09/26/2023 |
| 10 | +--- |
| 11 | + |
| 12 | +# Quickstart: Create an Azure Nexus Kubernetes cluster by using Azure PowerShell |
| 13 | + |
| 14 | + Deploy an Azure Nexus Kubernetes cluster using Azure PowerShell. |
| 15 | + |
| 16 | +This quick-start guide is designed to help you get started with using Nexus kubernetes cluster. By following the steps outlined in this guide, you're able to quickly and easily create a customized Nexus kubernetes cluster that meets your specific needs and requirements. Whether you're a beginner or an expert in Nexus networking, this guide is here to help. You learn everything you need to know to customize and create Nexus kubernetes cluster. |
| 17 | + |
| 18 | +## Before you begin |
| 19 | + |
| 20 | +[!INCLUDE [kubernetes-cluster-prereq](./includes/kubernetes-cluster/quickstart-prerequisite-powershell.md)] |
| 21 | + |
| 22 | +## Create an Azure Nexus Kubernetes cluster |
| 23 | + |
| 24 | +The following example creates a cluster named *myNexusK8sCluster* in resource group *myResourceGroup* in the *eastus* location. |
| 25 | + |
| 26 | +Before you run the commands, you need to set several variables to define the configuration for your cluster. Here are the variables you need to set, along with some default values you can use for certain variables: |
| 27 | + |
| 28 | +| Variable | Description | |
| 29 | +| -------------------------- | ------------------------------------------------------------------------------------------------------------------------ | |
| 30 | +| LOCATION | The Azure region where you want to create your cluster. | |
| 31 | +| RESOURCE_GROUP | The name of the Azure resource group where you want to create the cluster. | |
| 32 | +| SUBSCRIPTION_ID | The ID of your Azure subscription. | |
| 33 | +| CUSTOM_LOCATION | This argument specifies a custom location of the Nexus instance. | |
| 34 | +| CSN_ARM_ID | CSN ID is the unique identifier for the cloud services network you want to use. | |
| 35 | +| CNI_ARM_ID | CNI ID is the unique identifier for the network interface to be used by the container runtime. | |
| 36 | +| AAD_ADMIN_GROUP_OBJECT_ID | The object ID of the Azure Active Directory group that should have admin privileges on the cluster. | |
| 37 | +| CLUSTER_NAME | The name you want to give to your Nexus Kubernetes cluster. | |
| 38 | +| K8S_VERSION | The version of Kubernetes you want to use. | |
| 39 | +| ADMIN_USERNAME | The username for the cluster administrator. | |
| 40 | +| SSH_PUBLIC_KEY | The SSH public key that is used for secure communication with the cluster. | |
| 41 | +| CONTROL_PLANE_COUNT | The number of control plane nodes for the cluster. | |
| 42 | +| CONTROL_PLANE_VM_SIZE | The size of the virtual machine for the control plane nodes. | |
| 43 | +| INITIAL_AGENT_POOL_NAME | The name of the initial agent pool. | |
| 44 | +| INITIAL_AGENT_POOL_COUNT | The number of nodes in the initial agent pool. | |
| 45 | +| INITIAL_AGENT_POOL_VM_SIZE | The size of the virtual machine for the initial agent pool. | |
| 46 | +| MODE | The mode of the agent pool containing the node, values apply System or User or NotApplicable | |
| 47 | +| AGENT_POOL_CONFIGURATION | The parameter specifies the agent pools created for running critical system services and workloads. | |
| 48 | +| POD_CIDR | The network range for the Kubernetes pods in the cluster, in CIDR notation. | |
| 49 | +| SERVICE_CIDR | The network range for the Kubernetes services in the cluster, in CIDR notation. | |
| 50 | +| DNS_SERVICE_IP | The IP address for the Kubernetes DNS service. | |
| 51 | + |
| 52 | +Once you've defined these variables, you can run the Azure PowerShell command to create the cluster. Add the ```-Debug``` flag at the end to provide more detailed output for troubleshooting purposes. |
| 53 | + |
| 54 | +To define these variables, use the following set commands and replace the example values with your preferred values. You can also use the default values for some of the variables, as shown in the following example: |
| 55 | + |
| 56 | +```azurepowershell-interactive |
| 57 | +# Azure parameters |
| 58 | +$RESOURCE_GROUP="myResourceGroup" |
| 59 | +$SUBSCRIPTION="<Azure subscription ID>" |
| 60 | +$CUSTOM_LOCATION="/subscriptions/<subscription_id>/resourceGroups/<managed_resource_group>/providers/microsoft.extendedlocation/customlocations/<custom-location-name>" |
| 61 | +$CUSTOM_LOCATION_TYPE="CustomLocation" |
| 62 | +$LOCATION="<ClusterAzureRegion>" |
| 63 | +
|
| 64 | +# Network parameters |
| 65 | +$CSN_ARM_ID="/subscriptions/<subscription_id>/resourceGroups/<resource_group>/providers/Microsoft.NetworkCloud/cloudServicesNetworks/<csn-name>" |
| 66 | +$CNI_ARM_ID="/subscriptions/<subscription_id>/resourceGroups/<resource_group>/providers/Microsoft.NetworkCloud/l3Networks/<l3Network-name>" |
| 67 | +$POD_CIDR="10.244.0.0/16" |
| 68 | +$SERVICE_CIDR="10.96.0.0/16" |
| 69 | +$DNS_SERVICE_IP="10.96.0.10" |
| 70 | +
|
| 71 | +# AgentPoolConfiguration parameters |
| 72 | +$INITIAL_AGENT_POOL_COUNT="1" |
| 73 | +$MODE="System" |
| 74 | +$INITIAL_AGENT_POOL_NAME="agentpool1" |
| 75 | +$INITIAL_AGENT_POOL_VM_SIZE="NC_P10_56_v1" |
| 76 | +
|
| 77 | +# NAKS Cluster Parameters |
| 78 | +$CLUSTER_NAME="myNexusK8sCluster" |
| 79 | +$SSH_PUBLIC_KEY = @{ |
| 80 | + KeyData = "$(cat ~/.ssh/id_rsa.pub)" |
| 81 | +} |
| 82 | +$K8S_VERSION="1.24.9" |
| 83 | +$AAD_ADMIN_GROUP_OBJECT_ID="3d4c8620-ac8c-4bd6-9a92-f2b75923ef9f" |
| 84 | +$ADMIN_USERNAME="azureuser" |
| 85 | +$CONTROL_PLANE_COUNT="1" |
| 86 | +$CONTROL_PLANE_VM_SIZE="NC_G6_28_v1" |
| 87 | +
|
| 88 | +$AGENT_POOL_CONFIGURATION = New-AzNetworkCloudInitialAgentPoolConfigurationObject ` |
| 89 | +-Count $INITIAL_AGENT_POOL_COUNT ` |
| 90 | +-Mode $MODE ` |
| 91 | +-Name $INITIAL_AGENT_POOL_NAME ` |
| 92 | +-VmSkuName $INITIAL_AGENT_POOL_VM_SIZE |
| 93 | +``` |
| 94 | + |
| 95 | +> [!IMPORTANT] |
| 96 | +> It is essential that you replace the placeholders for CUSTOM_LOCATION, CSN_ARM_ID, CNI_ARM_ID, and AAD_ADMIN_GROUP_OBJECT_ID with your actual values before running these commands. |
| 97 | +
|
| 98 | +After defining these variables, you can create the Kubernetes cluster by executing the following Azure PowerShell command: |
| 99 | + |
| 100 | +```azurepowershell-interactive |
| 101 | +New-AzNetworkCloudKubernetesCluster -KubernetesClusterName $CLUSTER_NAME ` |
| 102 | +-ResourceGroupName $RESOURCE_GROUP ` |
| 103 | +-SubscriptionId $SUBSCRIPTION ` |
| 104 | +-Location $LOCATION ` |
| 105 | +-ExtendedLocationName $CUSTOM_LOCATION ` |
| 106 | +-ExtendedLocationType $CUSTOM_LOCATION_TYPE ` |
| 107 | +-KubernetesVersion $K8S_VERSION ` |
| 108 | +-AadConfigurationAdminGroupObjectId $AAD_ADMIN_GROUP_OBJECT_ID ` |
| 109 | +-AdminUsername $ADMIN_USERNAME ` |
| 110 | +-SshPublicKey $SSH_PUBLIC_KEY ` |
| 111 | +-ControlPlaneNodeConfigurationCount $CONTROL_PLANE_COUNT ` |
| 112 | +-ControlPlaneNodeConfigurationVMSkuName $CONTROL_PLANE_VM_SIZE ` |
| 113 | +-InitialAgentPoolConfiguration $AGENT_POOL_CONFIGURATION ` |
| 114 | +-NetworkConfigurationCloudServicesNetworkId $CSN_ARM_ID ` |
| 115 | +-NetworkConfigurationCniNetworkId $CNI_ARM_ID ` |
| 116 | +-NetworkConfigurationPodCidr $POD_CIDR ` |
| 117 | +-NetworkConfigurationDnsServiceIP $SERVICE_CIDR ` |
| 118 | +-NetworkConfigurationServiceCidr $DNS_SERVICE_IP |
| 119 | +``` |
| 120 | + |
| 121 | +After a few minutes, the command completes and returns information about the cluster. For more advanced options, see [Quickstart: Deploy an Azure Nexus Kubernetes cluster using Bicep](./quickstarts-kubernetes-cluster-deployment-bicep.md). |
| 122 | + |
| 123 | +## Review deployed resources |
| 124 | + |
| 125 | +[!INCLUDE [quickstart-review-deployment-cli](./includes/kubernetes-cluster/quickstart-review-deployment-powershell.md)] |
| 126 | + |
| 127 | +## Connect to the cluster |
| 128 | + |
| 129 | +[!INCLUDE [quickstart-cluster-connect](./includes/kubernetes-cluster/quickstart-cluster-connect-powershell.md)] |
| 130 | + |
| 131 | +## Add an agent pool |
| 132 | + |
| 133 | +The cluster created in the previous step has a single node pool. Let's add a second agent pool using the ```New-AzNetworkCloudAgentPool``` create command. The following example creates an agent pool named ```myNexusK8sCluster-nodepool-2```: |
| 134 | + |
| 135 | +You can also use the default values for some of the variables, as shown in the following example: |
| 136 | + |
| 137 | +```azurepowershell-interactive |
| 138 | +$RESOURCE_GROUP="myResourceGroup" |
| 139 | +$SUBSCRIPTION="<Azure subscription ID>" |
| 140 | +$CUSTOM_LOCATION="/subscriptions/<subscription_id>/resourceGroups/<managed_resource_group>/providers/microsoft.extendedlocation/customlocations/<custom-location-name>" |
| 141 | +$CUSTOM_LOCATION_TYPE="CustomLocation" |
| 142 | +$LOCATION="<ClusterAzureRegion>" |
| 143 | +$CLUSTER_NAME="myNexusK8sCluster" |
| 144 | +$AGENT_POOL_NAME="myNexusK8sCluster-nodepool-2" |
| 145 | +$AGENT_POOL_VM_SIZE="NC_P10_56_v1" |
| 146 | +$AGENT_POOL_COUNT="1" |
| 147 | +$AGENT_POOL_MODE="User" |
| 148 | +``` |
| 149 | + |
| 150 | +After defining these variables, you can add an agent pool by executing the following Azure PowerShell command: |
| 151 | + |
| 152 | +```azurepowershell-interactive |
| 153 | +New-AzNetworkCloudAgentPool -KubernetesClusterName $CLUSTER_NAME ` |
| 154 | +-Name $AGENT_POOL_NAME ` |
| 155 | +-ResourceGroupName $RESOURCE_GROUP ` |
| 156 | +-SubscriptionId $SUBSCRIPTION ` |
| 157 | +-ExtendedLocationName $CUSTOM_LOCATION ` |
| 158 | +-ExtendedLocationType $CUSTOM_LOCATION_TYPE ` |
| 159 | +-Location $LOCATION ` |
| 160 | +-Count $AGENT_POOL_COUNT ` |
| 161 | +-Mode $AGENT_POOL_MODE ` |
| 162 | +-VMSkuName $AGENT_POOL_VM_SIZE |
| 163 | +``` |
| 164 | + |
| 165 | +After a few minutes, the command completes and returns information about the agent pool. For more advanced options, see [Quickstart: Deploy an Azure Nexus Kubernetes cluster using Bicep](./quickstarts-kubernetes-cluster-deployment-bicep.md). |
| 166 | + |
| 167 | +[!INCLUDE [quickstart-review-nodepool](./includes/kubernetes-cluster/quickstart-review-nodepool-powershell.md)] |
| 168 | + |
| 169 | +## Clean up resources |
| 170 | + |
| 171 | +[!INCLUDE [quickstart-cleanup](./includes/kubernetes-cluster/quickstart-cleanup-powershell.md)] |
| 172 | + |
| 173 | +## Next steps |
| 174 | + |
| 175 | +[!INCLUDE [quickstart-nextsteps](./includes/kubernetes-cluster/quickstart-nextsteps.md)] |
0 commit comments