Skip to content

Commit b25bb98

Browse files
authored
Merge pull request #252937 from rashirg/naks-cluster
PowerShell example update- Nexus Kubernetes Cluster
2 parents 37e5ecd + 0be8afa commit b25bb98

8 files changed

+344
-0
lines changed

articles/operator-nexus/TOC.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
href: quickstarts-kubernetes-cluster-deployment-arm.md
3535
- name: Use Bicep file
3636
href: quickstarts-kubernetes-cluster-deployment-bicep.md
37+
- name: Use Azure PowerShell
38+
href: quickstarts-kubernetes-cluster-deployment-powershell.md
3739
- name: Deploy Nexus Virtual Machine
3840
expanded: true
3941
items:
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
author: rashirg
3+
ms.author: rajeshwarig
4+
ms.date: 10/03/2023
5+
ms.topic: include
6+
ms.service: azure-operator-nexus
7+
---
8+
9+
> [!NOTE]
10+
> When you create a Nexus Kubernetes cluster, Nexus automatically creates a managed resource group dedicated to storing the cluster resources. Within this group, the Arc connected cluster resource is established.
11+
12+
To access your cluster, you need to set up the cluster connect `kubeconfig`. After logging into Azure PowerShell with the relevant Azure AD entity, you can obtain the `kubeconfig` necessary to communicate with the cluster from anywhere, even outside the firewall that surrounds it.
13+
14+
1. Set CLUSTER_NAME, RESOURCE_GROUP, LOCATION and SUBSCRIPTION_ID variables.
15+
16+
```azurepowershell
17+
$CLUSTER_NAME="myNexusK8sCluster"
18+
$LOCATION="<ClusterAzureRegion>"
19+
$MANAGED_RESOURCE_GROUP=(Get-AzNetworkCloudKubernetesCluster -KubernetesClusterName $CLUSTER_NAME `
20+
-SubscriptionId <mySubscription> `
21+
-ResourceGroupName myResourceGroup `
22+
|Select-Object -Property ManagedResourceGroupConfigurationName)
23+
```
24+
25+
2. Run the following command to connect to the cluster.
26+
```azurepowershell
27+
New-AzConnectedKubernetes -ClusterName $CLUSTER_NAME -ResourceGroupName $MANAGED_RESOURCE_GROUP -Location $LOCATION
28+
```
29+
30+
2. Use `kubectl` to send requests to the cluster:
31+
32+
```console
33+
kubectl get pods -A
34+
```
35+
You should now see a response from the cluster containing the list of all nodes.
36+
37+
> [!NOTE]
38+
> If you see the error message "Failed to post access token to client proxyFailed to connect to MSI", you may need to perform an `az login` to re-authenticate with Azure.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
author: rashirg
3+
ms.author: rajeshwarig
4+
ms.date: 09/26/2023
5+
ms.topic: include
6+
ms.service: azure-operator-nexus
7+
---
8+
9+
When no longer needed, delete the resource group. The resource group and all the resources in the resource group are deleted.
10+
11+
### [Azure PowerShell](#tab/azure-powershell)
12+
13+
Use the [Remove-AzResourceGroup][remove-azresourcegroup] cmdlet to remove the resource group, Kubernetes cluster, and all related resources except the Operator Nexus network resources.
14+
15+
```azurepowershell-interactive
16+
Remove-AzResourceGroup -Name myResourceGroup
17+
```
18+
---
19+
20+
<!-- LINKS - internal -->
21+
[remove-azresourcegroup]: /powershell/module/az.resources/remove-azresourcegroup
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
author: rashrig
3+
ms.author: rajeshwarig
4+
ms.date: 09/28/2023
5+
ms.topic: include
6+
ms.service: azure-operator-nexus
7+
---
8+
9+
Now that the Nexus Kubernetes cluster has been successfully created and connected to Azure Arc, you can easily connect to it using the cluster connect feature. Cluster connect allows you to securely access and manage your cluster from anywhere, making it convenient for interactive development, debugging, and cluster administration tasks.
10+
11+
For more detailed information about available options, see [Connect to an Azure Operator Nexus Kubernetes cluster](../../howto-kubernetes-cluster-connect.md).
12+
13+
[!INCLUDE [cluster-connect](./cluster-connect-powershell.md)]
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
---
2+
author: rashirg
3+
ms.author: rajeshwarig
4+
ms.date: 09/27/2023
5+
ms.topic: include
6+
ms.service: azure-operator-nexus
7+
ms.custom: devx-track-azurecpowershell
8+
---
9+
10+
[!INCLUDE [quickstarts-free-trial-note](../../../../includes/quickstarts-free-trial-note.md)]
11+
12+
* Use the Bash environment in [Azure PowerShell](../../../cloud-shell/overview.md). For more information, see [Quickstart for PowerShell in Azure Cloud Shell.](../../../cloud-shell/quickstart.md)
13+
14+
[:::image type="icon" source="~/articles/reusable-content/azure-cli/media/hdi-launch-cloud-shell.png" alt-text="Launch Azure Cloud Shell" :::](https://shell.azure.com)
15+
16+
* If you are running PowerShell locally, install the Az PowerShell module and connect to your Azure account using the [Connect-AzAccount](/powershell/module/az.accounts/Connect-AzAccount) cmdlet. For more information about installing the Az PowerShell module, see [Install Azure PowerShell][install-azure-powershell].
17+
18+
* If you have multiple Azure subscriptions, select the appropriate subscription ID in which the resources should be billed using the
19+
[Set-AzContext](/powershell/module/az.accounts/set-azcontext) cmdlet. On setting the subscription, one need not pass the 'SubscriptionID' each time executing the PowerShell command.
20+
21+
* Refer the VM SKU table in the [reference section](../../reference-nexus-kubernetes-cluster-sku.md) for the list of supported VM SKUs.
22+
23+
* Create a resource group using the [New-AzResourceGroup][new-azresourcegroup] cmdlet. An [Azure resource group][azure-resource-group] is a logical group in which Azure resources are deployed and managed. When you create a resource group, you're prompted to specify a location. This location is the storage location of your resource group metadata and where your resources run in Azure if you don't specify another region during resource creation. The following example creates a resource group named myResourceGroup in the eastus location.
24+
25+
```azurepowershell-interactive
26+
New-AzResourceGroup -Name myResourceGroup -Location eastus
27+
```
28+
29+
The following output example resembles successful creation of the resource group:
30+
31+
```plaintext
32+
ResourceGroupName : myResourceGroup
33+
Location : eastus
34+
ProvisioningState : Succeeded
35+
Tags :
36+
ResourceId : /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup
37+
```
38+
39+
* You need the `custom location` resource ID of your Azure Operator Nexus cluster.
40+
* You need to create [various networks](../../quickstarts-tenant-workload-prerequisites.md#create-networks-for-tenant-workloads) according to your specific workload requirements, and it's essential to have the appropriate IP addresses available for your workloads. To ensure a smooth implementation, it's advisable to consult the relevant support teams for assistance.
41+
* This quickstart assumes a basic understanding of Kubernetes concepts. For more information, see [Kubernetes core concepts for Azure Kubernetes Service (AKS)][kubernetes-concepts].
42+
43+
<!-- LINKS - internal -->
44+
[install-azure-powershell]: /powershell/azure/install-az-ps
45+
[new-azresourcegroup]: /powershell/module/az.resources/new-azresourcegroup
46+
[kubernetes-concepts]: ../../../aks/concepts-clusters-workloads.md
47+
[azure-resource-group]: ../../../azure-resource-manager/management/overview.md
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
author: rashirg
3+
ms.author: rajeshwarig
4+
ms.date: 09/27/2023
5+
ms.topic: include
6+
ms.service: azure-operator-nexus
7+
---
8+
9+
After the deployment finishes, you can view the resources using the PowerShell or the Azure portal.
10+
11+
To view the details of the ```myNexusK8sCluster``` cluster in the ```myResourceGroup``` resource group, execute the following Azure PowerShell command:
12+
13+
```azurepowershell-interactive
14+
Get-AzNetworkCloudKubernetesCluster -KubernetesClusterName myNexusK8sCluster `
15+
-ResourceGroupName myResourceGroup `
16+
-SubscriptionId <mySubscription>
17+
```
18+
19+
Additionally, to get a list of agent pool names associated with the ```myNexusK8sCluster``` cluster in the ```myResourceGroup``` resource group, you can use the following Azure PowerShell command.
20+
21+
```azurepowershell-interactive
22+
Get-AzNetworkCloudAgentPool -KubernetesClusterName myNexusK8sCluster `
23+
-ResourceGroupName myResourceGroup `
24+
-SubscriptionId <mySubscription>
25+
```
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
author: rashirg
3+
ms.author: rajeshwarig
4+
ms.date: 10/07/2023
5+
ms.topic: include
6+
ms.service: azure-operator-nexus
7+
---
8+
9+
> [!NOTE]
10+
> You can add multiple agent pools during the initial creation of your cluster itself by using the initial agent pool configurations. However, if you want to add agent pools after the initial creation, you can utilize the above command to create additional agent pools for your Nexus Kubernetes cluster.
11+
12+
The following output example resembles successful creation of the agent pools.
13+
14+
```azurepowershell
15+
Get-AzNetworkCloudAgentPool -KubernetesClusterName myNexusK8sCluster `
16+
-ResourceGroupName myResourceGroup `
17+
-SubscriptionId <mySubscription>
18+
19+
Location Name SystemDataCreatedAt SystemDataCreatedBy SystemDataCreatedByType SystemDataLastModifiedAt SystemDataLastModifiedBy
20+
-------- ---- ------------------- ------------------- ----------------------- ------------------------ ------------
21+
eastus myNexusK8sCluster-nodepool-1 09/21/2023 18:14:59 <identity> User 07/18/2023 17:46:45 <identity>
22+
eastus myNexusK8sCluster-nodepool-2 09/25/2023 17:44:02 <identity> User 07/18/2023 17:46:45 <identity>
23+
```
Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
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

Comments
 (0)