Skip to content

Commit bd0c427

Browse files
Merge pull request #3256 from MicrosoftDocs/main638581282932124643sync_temp
For protected branch, push strategy should use PR and merge to target branch method to work around git push error
2 parents 076b8dd + 4ec6f31 commit bd0c427

File tree

6 files changed

+233
-27
lines changed

6 files changed

+233
-27
lines changed

AKS-Hybrid/TOC.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@
4747
- name: Azure CLI
4848
href: aks-create-clusters-cli.md
4949
- name: Azure portal
50-
href: aks-create-clusters-portal.md
50+
href: aks-create-clusters-portal.md
51+
- name: Bicep
52+
href: create-clusters-bicep.md
5153
- name: Deploy to Azure using a quickstart template
5254
href: /samples/azure/azure-quickstart-templates/aks-on-ashci
5355
- name: Azure Resource Manager template

AKS-Hybrid/azure-rbac-23h2.md

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,7 @@ After a few minutes, the command completes and returns JSON-formatted informatio
6969

7070
## Step 2: Create role assignments for users to access the cluster
7171

72-
AKS enabled by Azure Arc provides the following built-in roles:
73-
74-
| Role | Description |
75-
| ------------------------------------------------------------ | ------------------------------------------------------------ |
76-
| [Azure Arc Kubernetes Viewer](/azure/role-based-access-control/built-in-roles#azure-arc-kubernetes-viewer) | Allows read-only access to see most objects in a namespace. <br />Doesn't allow viewing roles or role bindings. <br />Doesn't allow viewing `secrets`, because `read` permission on secrets enables access to `ServiceAccount` credentials in the namespace, which allows API access as any `ServiceAccount` in the namespace (a form of privilege escalation). |
77-
| [Azure Arc Kubernetes Writer](/azure/role-based-access-control/built-in-roles#azure-arc-kubernetes-writer) | Allows read/write access to most objects in a namespace. <br />Doesn't allow viewing or modifying roles or role bindings. <br />Allows accessing `secrets` and running pods as any `ServiceAccount` in the namespace, so it can be used to gain the API access levels of any `ServiceAccount` in the namespace. |
78-
| [Azure Arc Kubernetes Admin](/azure/role-based-access-control/built-in-roles#azure-arc-kubernetes-admin) | Allows admin access, intended to be granted within a namespace. <br />Allows read/write access to most resources in a namespace (or cluster scope), including the ability to create roles and role bindings within the namespace. <br />Doesn't allow write access to resource quota or to the namespace itself. |
79-
| [Azure Arc Kubernetes Cluster Admin](/azure/role-based-access-control/built-in-roles#azure-arc-kubernetes-cluster-admin) | Allows "super-user" access to perform any action on any resource.<br/>Gives full control over every resource in the cluster and in all namespaces. |
72+
[!INCLUDE [built-in-roles](includes/built-in-roles.md)]
8073

8174
You can use the [`az role assignment create`](/cli/azure/role/assignment#az-role-assignment-create) command to create role assignments.
8275

AKS-Hybrid/concepts-security-access-identity.md

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -117,15 +117,7 @@ With this feature, you not only give users permissions to the AKS resource acros
117117
118118
### Built-in roles
119119

120-
AKS enabled by Azure Arc provides the following four built-in roles. They are similar to the [Kubernetes built-in roles](https://kubernetes.io/docs/reference/access-authn-authz/rbac/#user-facing-roles) with a few differences, such as supporting CRDs. See the full list of actions allowed by each [Azure built-in role](/azure/role-based-access-control/built-in-roles).
121-
122-
| Role | Description |
123-
| ------------------------------------------------------------ | ------------------------------------------------------------ |
124-
| [Azure Arc-enabled Kubernetes Cluster User Role](/azure/role-based-access-control/built-in-roles/containers#azure-arc-enabled-kubernetes-cluster-user-role) | Allows you to retrieve the Cluster Connect-based kubeconfig file to manage clusters from anywhere. |
125-
| [Azure Arc Kubernetes Viewer](/azure/role-based-access-control/built-in-roles/containers#azure-arc-kubernetes-viewer) | Allows read-only access to see most objects in a namespace. <br /> Doesn't allow viewing secrets, because **read** permission on secrets enables access to **ServiceAccount** credentials in the namespace. These credentials in turn allow API access through that **ServiceAccount** value (a form of privilege escalation). |
126-
| [Azure Arc Kubernetes Writer](/azure/role-based-access-control/built-in-roles/containers#azure-arc-kubernetes-writer) | Allows read/write access to most objects in a namespace. <br />Doesn't allow viewing or modifying roles or role bindings. However, this role allows accessing secrets and running pods as any **ServiceAccount** value in the namespace, so it can be used to gain the API access levels of any such **ServiceAccount** value in the namespace. |
127-
| [Azure Arc Kubernetes Admin](/azure/role-based-access-control/built-in-roles/containers#azure-arc-kubernetes-admin) | Allows admin access. It's intended to be granted within a namespace through **RoleBinding**. If you use it in **RoleBinding**, it allows read/write access to most resources in a namespace, including the ability to create roles and role bindings within the namespace. This role doesn't allow write access to resource quota or to the namespace itself. |
128-
| [Azure Arc Kubernetes Cluster Admin](/azure/role-based-access-control/built-in-roles/containers#azure-arc-kubernetes-cluster-admin) | Allows "superuser" access to execute any action on any resource. When you use it in **ClusterRoleBinding**, it gives full control over every resource in the cluster and in all namespaces. When you use it in **RoleBinding**, it gives full control over every resource in the role binding namespace, including the namespace itself.|
120+
[!INCLUDE [built-in-roles](includes/built-in-roles.md)]
129121

130122
## Microsoft Entra integration
131123

AKS-Hybrid/create-clusters-bicep.md

Lines changed: 199 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
1+
---
2+
title: Create Kubernetes clusters using Bicep
3+
description: Learn how to create Kubernetes clusters in Azure Stack HCI using Bicep.
4+
ms.topic: how-to
5+
ms.custom: devx-track-azurecli
6+
ms.date: 07/26/2024
7+
author: sethmanheim
8+
ms.author: sethm
9+
ms.reviewer: haojiehang
10+
ms.lastreviewed: 07/24/2024
11+
12+
---
13+
14+
# Create Kubernetes clusters using Bicep
15+
16+
This article describes how to create Kubernetes clusters in Azure Stack HCI using Bicep. The workflow is as follows:
17+
18+
1. Create an SSH key pair
19+
1. Create a Kubernetes cluster in Azure Stack HCI 23H2 using Bicep. By default, the cluster is Azure Arc-connected.
20+
1. Validate the deployment and connect to the cluster.
21+
22+
## Before you begin
23+
24+
Before you begin, make sure you have the following prerequisites:
25+
26+
1. Get the following details from your on-premises infrastructure administrator:
27+
28+
- Azure subscription ID: the Azure subscription ID that uses Azure Stack HCI for deployment and registration.
29+
- Custom location name or ID: the Azure Resource Manager ID of the custom location. The custom location is configured during the Azure Stack HCI cluster deployment. Your infrastructure admin should give you the Resource Manager ID of the custom location. This parameter is required in order to create Kubernetes clusters. You can also get the Resource Manager ID using `az customlocation show --name "<custom location name>" --resource-group <azure resource group> --query "id" -o tsv`, if the infrastructure admin provides a custom location name and resource group name.
30+
- Logical network name or ID: the Azure Resource Manager ID of the Azure Stack HCI logical network that was created following these steps. Your admin should give you the ID of the logical network. This parameter is required in order to create Kubernetes clusters. You can also get the Azure Resource Manager ID using `az stack-hci-vm network lnet show --name "<lnet name>" --resource-group <azure resource group> --query "id" -o tsv` if you know the resource group in which the logical network was created.
31+
32+
1. Make sure you have the [latest version of Azure CLI](/cli/azure/install-azure-cli) on your development machine. You can also upgrade your Azure CLI version using `az upgrade`.
33+
1. Download and install **kubectl** on your development machine. The Kubernetes command-line tool, **kubectl**, enables you to run commands against Kubernetes clusters. You can use **kubectl** to deploy applications, inspect and manage cluster resources, and view logs.
34+
35+
## Create an SSH key pair
36+
37+
To create an SSH key pair (same as Azure AKS), use the following procedure:
38+
39+
1. [Open a Cloud Shell session](https://shell.azure.com) in your browser.
40+
1. Create an SSH key pair using the `az sshkey create` Azure CLI command or the `ssh-keygen` command:
41+
42+
```azurecli
43+
# Create an SSH key pair using Azure CLI
44+
az sshkey create --name "mySSHKey" --resource-group "myResourceGroup"
45+
```
46+
47+
Or, create an SSH key pair using `ssh-keygen`:
48+
49+
```bash
50+
ssh-keygen -t rsa -b 4096
51+
```
52+
53+
For more information about creating SSH keys, see [Create and manage SSH keys for authentication in Azure](/azure/virtual-machines/linux/create-ssh-keys-detailed).
54+
55+
## Update and review the Bicep scripts
56+
57+
This section shows the Bicep parameter and template files. These files are also available in an [Azure Quickstart template](https://github.com/Azure/azure-quickstart-templates).
58+
59+
### Bicep parameter file: aksarc.bicepparam
60+
61+
```bicep
62+
using 'main.bicep'
63+
param aksClusterName = 'aksarc-bicep-new'
64+
param aksControlPlaneIP = 'x.x.x.x'
65+
param sshPublicKey = 'ssh_public_key'
66+
param hciLogicalNetworkName = 'lnet_name'
67+
param hciCustomLocationName = 'cl_name'
68+
param aksNodePoolOSType = 'Linux'
69+
param aksNodePoolNodeCount = 1
70+
```
71+
72+
### Bicep template file: main.bicep
73+
74+
```bicep
75+
@description('The name of AKS Arc cluster resource')
76+
param aksClusterName string
77+
param location string = 'eastus'
78+
79+
// Default to 1 node CP
80+
@description('The name of AKS Arc cluster control plane IP, provide this parameter during deployment')
81+
param aksControlPlaneIP string
82+
param aksControlPlaneNodeSize string = 'Standard_A4_v2'
83+
param aksControlPlaneNodeCount int = 1
84+
85+
// Default to 1 node NP
86+
param aksNodePoolName string = 'nodepool1'
87+
param aksNodePoolNodeSize string = 'Standard_A4_v2'
88+
param aksNodePoolNodeCount int = 1
89+
@allowed(['Linux', 'Windows'])
90+
param aksNodePoolOSType string = 'Linux'
91+
92+
@description('SSH public key used for cluster creation, provide this parameter during deployment')
93+
param sshPublicKey string
94+
95+
// Build LNet ID from LNet name
96+
@description('The name of LNet resource, provide this parameter during deployment')
97+
param hciLogicalNetworkName string
98+
resource logicalNetwork 'Microsoft.AzureStackHCI/logicalNetworks@2023-09-01-preview' existing = {
99+
name: hciLogicalNetworkName
100+
}
101+
102+
// Build custom location ID from custom location name
103+
@description('The name of custom location resource, provide this parameter during deployment')
104+
param hciCustomLocationName string
105+
var customLocationId = resourceId('Microsoft.ExtendedLocation/customLocations', hciCustomLocationName)
106+
107+
// Create the connected cluster. This is the Arc representation of the AKS cluster, used to create a Managed Identity for the provisioned cluster.
108+
resource connectedCluster 'Microsoft.Kubernetes/ConnectedClusters@2024-01-01' = {
109+
location: location
110+
name: aksClusterName
111+
identity: {
112+
type: 'SystemAssigned'
113+
}
114+
kind: 'ProvisionedCluster'
115+
properties: {
116+
agentPublicKeyCertificate: ''
117+
aadProfile: {
118+
enableAzureRBAC: false
119+
}
120+
}
121+
}
122+
123+
// Create the provisioned cluster instance. This is the actual AKS cluster and provisioned on your HCI cluster via the Arc Resource Bridge.
124+
resource provisionedClusterInstance 'Microsoft.HybridContainerService/provisionedClusterInstances@2024-01-01' = {
125+
name: 'default'
126+
scope: connectedCluster
127+
extendedLocation: {
128+
type: 'CustomLocation'
129+
name: customLocationId
130+
}
131+
properties: {
132+
linuxProfile: {
133+
ssh: {
134+
publicKeys: [
135+
{
136+
keyData: sshPublicKey
137+
}
138+
]
139+
}
140+
}
141+
controlPlane: {
142+
count: aksControlPlaneNodeCount
143+
controlPlaneEndpoint: {
144+
hostIP: aksControlPlaneIP
145+
}
146+
vmSize: aksControlPlaneNodeSize
147+
}
148+
networkProfile: {
149+
loadBalancerProfile: {
150+
count: 0
151+
}
152+
networkPolicy: 'calico'
153+
}
154+
agentPoolProfiles: [
155+
{
156+
name: aksNodePoolName
157+
count: aksNodePoolNodeCount
158+
vmSize: aksNodePoolNodeSize
159+
osType: aksNodePoolOSType
160+
}
161+
]
162+
cloudProviderProfile: {
163+
infraNetworkProfile: {
164+
vnetSubnetIds: [
165+
logicalNetwork.id
166+
]
167+
}
168+
}
169+
storageProfile: {
170+
nfsCsiDriver: {
171+
enabled: true
172+
}
173+
smbCsiDriver: {
174+
enabled: true
175+
}
176+
}
177+
}
178+
}
179+
```
180+
181+
The **Microsoft.HybridContainerService/provisionedClusterInstances** resource is defined in the Bicep file. If you want to explore more properties, [see the API reference](/azure/templates/microsoft.hybridcontainerservice/provisionedclusterinstances?pivots=deployment-language-bicep).
182+
183+
## Deploy the Bicep file
184+
185+
1. Save the Bicep file as **main.bicep** to your local computer.
186+
1. Update the parameters defined in **aksarc.bicepparam** and save it to your local computer.
187+
1. Deploy the Bicep file using Azure CLI:
188+
189+
```azurecli
190+
az deployment group create --name BicepDeployment --resource-group myResourceGroupName --template-file main.bicep –-parameters aksarc.bicepparam
191+
```
192+
193+
## Validate the Bicep deployment and connect to the cluster
194+
195+
You can now connect to your Kubernetes cluster by running the `az connectedk8s proxy` command from your development machine. You can also use **kubectl** to see the node and pod status. Follow the same steps as described in [Connect to the Kubernetes cluster](aks-create-clusters-cli.md#connect-to-the-kubernetes-cluster).
196+
197+
## Next steps
198+
199+
[Create Kubernetes clusters using Azure CLI](aks-create-clusters-cli.md)

AKS-Hybrid/includes/built-in-roles.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
author: sethmanheim
3+
ms.author: sethm
4+
ms.service: azure-stack
5+
ms.topic: include
6+
ms.date: 07/31/2024
7+
ms.reviewer: leslielin
8+
ms.lastreviewed: 07/31/2024
9+
10+
---
11+
12+
AKS enabled by Arc provides the following five built-in roles. They are similar to the [Kubernetes built-in roles](https://kubernetes.io/docs/reference/access-authn-authz/rbac/#user-facing-roles) with a few differences, such as supporting CRDs. See the full list of actions allowed by each [Azure built-in role](/azure/role-based-access-control/built-in-roles).
13+
14+
| Role | Description |
15+
| ------------------------------------------------------------ | ------------------------------------------------------------ |
16+
| [Azure Arc-enabled Kubernetes Cluster User](/azure/role-based-access-control/built-in-roles/containers#azure-arc-enabled-kubernetes-cluster-user-role) | Allows you to retrieve the Cluster Connect-based kubeconfig file to manage clusters from anywhere. |
17+
| [Azure Arc Kubernetes Viewer](/azure/role-based-access-control/built-in-roles/containers#azure-arc-kubernetes-viewer) | Allows read-only access to see most objects in a namespace. <br /> Doesn't allow viewing secrets, because **read** permission on secrets enables access to **ServiceAccount** credentials in the namespace. These credentials in turn allow API access through that **ServiceAccount** value (a form of privilege escalation). |
18+
| [Azure Arc Kubernetes Writer](/azure/role-based-access-control/built-in-roles/containers#azure-arc-kubernetes-writer) | Allows read/write access to most objects in a namespace. <br />Doesn't allow viewing or modifying roles or role bindings. However, this role allows accessing secrets and running pods as any **ServiceAccount** value in the namespace, so it can be used to gain the API access levels of any such **ServiceAccount** value in the namespace. |
19+
| [Azure Arc Kubernetes Admin](/azure/role-based-access-control/built-in-roles/containers#azure-arc-kubernetes-admin) | Allows admin access. It's intended to be granted within a namespace through **RoleBinding**. If you use it in **RoleBinding**, it allows read/write access to most resources in a namespace, including the ability to create roles and role bindings within the namespace. This role doesn't allow write access to resource quota or to the namespace itself. |
20+
| [Azure Arc Kubernetes Cluster Admin](/azure/role-based-access-control/built-in-roles/containers#azure-arc-kubernetes-cluster-admin) | Allows "superuser" access to execute any action on any resource. When you use it in **ClusterRoleBinding**, it gives full control over every resource in the cluster and in all namespaces. When you use it in **RoleBinding**, it gives full control over every resource in the role binding namespace, including the namespace itself.|

0 commit comments

Comments
 (0)