Skip to content

Commit 229cd3a

Browse files
committed
Updated ARM and Bicep to include SSH keys
1 parent 10a4c39 commit 229cd3a

7 files changed

+120
-49
lines changed

articles/operator-nexus/howto-kubernetes-cluster-manage-ssh-key.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ Refer the [Disconnected mode access](./howto-kubernetes-cluster-connect.md#disco
3636

3737
Following are the variables you need to set, along with the [quickstart guide](./quickstarts-kubernetes-cluster-deployment-cli.md#create-an-azure-nexus-kubernetes-cluster) default values you can use for certain variables.
3838

39-
`SSH_PUBLIC_KEY` - For the cluster wide keys.
40-
`CONTROL_PLANE_SSH_PUBLIC_KEY` - For the control plane, you can provide public keys that are inserted into the control plane nodes.
41-
`INITIAL_AGENT_POOL_SSH_PUBLIC_KEY` - For each agent pool, you can provide public keys that are inserted into the nodes in that pool.
39+
* `SSH_PUBLIC_KEY` - For the cluster wide keys. Note that using cluster wide key with agent pool and control plane keys doesn't have any effect as the control plane and agent pool keys are used instead of the cluster wide keys.
40+
* `CONTROL_PLANE_SSH_PUBLIC_KEY` - For the control plane, you can provide public keys that are inserted into the control plane nodes.
41+
* `INITIAL_AGENT_POOL_SSH_PUBLIC_KEY` - For each agent pool, you can provide public keys that are inserted into the nodes in that pool.
4242

4343
```azurecli
4444
az networkcloud kubernetescluster create \
@@ -109,7 +109,7 @@ To update the SSH keys, you can apply the same Bicep/ARM configuration used duri
109109

110110
#### Update cluster wide SSH keys
111111

112-
Use the following command to update the cluster wide SSH keys, which are used for all nodes in the cluster. All the nodes in the cluster will be updated with the new keys.
112+
Use the following command to update the cluster wide SSH keys, which are used for all nodes in the cluster. All the nodes in the cluster will be updated with the new keys if the clster was created with only cluster wide keys.
113113

114114
```azurecli
115115
az networkcloud kubernetescluster update --name "$CLUSTER_NAME" --resource-group "$RESOURCE_GROUP" --subscription "$SUBSCRIPTION_ID" --ssh-key-values "$CLUSER_WIDE_KEY"

articles/operator-nexus/includes/kubernetes-cluster/quickstart-arm-add-node-pool.json

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,26 +21,27 @@
2121
"description": "The custom location of the Nexus instance"
2222
}
2323
},
24-
"tags": {
25-
"type": "object",
26-
"defaultValue": {},
27-
"metadata": {
28-
"description": "Tags to be associated with the resource"
29-
}
30-
},
3124
"adminUsername": {
3225
"type": "string",
3326
"defaultValue": "azureuser",
3427
"metadata": {
3528
"description": "The username for the administrative account on the cluster"
3629
}
3730
},
38-
"sshPublicKey": {
39-
"type": "string",
40-
"defaultValue": "",
31+
"agentPoolSshKeys": {
32+
"type": "array",
4133
"metadata": {
42-
"description": "The SSH public key that will be associated with the 'azureuser' user for secure remote login"
43-
}
34+
"description": "The agent pool SSH public key that will be associated with the given user for secure remote login"
35+
},
36+
"defaultValue": []
37+
/*
38+
{
39+
"keyData": "ssh-rsa AAAAA...."
40+
},
41+
{
42+
"keyData": "ssh-rsa BBBBB...."
43+
}
44+
*/
4445
},
4546
"agentPoolNodeCount": {
4647
"type": "int",
@@ -167,7 +168,10 @@
167168
"type": "CustomLocation"
168169
},
169170
"properties": {
170-
"administratorConfiguration": {},
171+
"administratorConfiguration": {
172+
"adminUsername": "[parameters('adminUsername')]",
173+
"sshPublicKeys": "[if(empty(parameters('agentPoolSshKeys')), json('null'), parameters('agentPoolSshKeys'))]"
174+
},
171175
"count": "[parameters('agentPoolNodeCount')]",
172176
"mode": "[parameters('agentPoolMode')]",
173177
"vmSkuName": "[parameters('agentVmSku')]",

articles/operator-nexus/includes/kubernetes-cluster/quickstart-arm-deploy.json

Lines changed: 52 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -235,11 +235,50 @@
235235
"hugepagesSize": "2M/1G"
236236
*/
237237
},
238-
"sshPublicKey": {
239-
"type": "string",
238+
"sshPublicKeys": {
239+
"type": "array",
240240
"metadata": {
241-
"description": "The SSH public key that will be associated with the 'azureuser' user for secure remote login"
242-
}
241+
"description": "The cluster wide SSH public key that will be associated with the given user for secure remote login"
242+
},
243+
"defaultValue": []
244+
/*
245+
{
246+
"keyData": "ssh-rsa AAAAA...."
247+
},
248+
{
249+
"keyData": "ssh-rsa BBBBB...."
250+
}
251+
*/
252+
},
253+
"controlPlaneSshKeys": {
254+
"type": "array",
255+
"metadata": {
256+
"description": "The control plane SSH public key that will be associated with the given user for secure remote login"
257+
},
258+
"defaultValue": []
259+
/*
260+
{
261+
"keyData": "ssh-rsa AAAAA...."
262+
},
263+
{
264+
"keyData": "ssh-rsa BBBBB...."
265+
}
266+
*/
267+
},
268+
"agentPoolSshKeys": {
269+
"type": "array",
270+
"metadata": {
271+
"description": "The agent pool SSH public key that will be associated with the given user for secure remote login"
272+
},
273+
"defaultValue": []
274+
/*
275+
{
276+
"keyData": "ssh-rsa AAAAA...."
277+
},
278+
{
279+
"keyData": "ssh-rsa BBBBB...."
280+
}
281+
*/
243282
},
244283
"labels": {
245284
"type": "array",
@@ -290,16 +329,15 @@
290329
},
291330
"administratorConfiguration": {
292331
"adminUsername": "[parameters('adminUsername')]",
293-
"sshPublicKeys": [
294-
{
295-
"keyData": "[parameters('sshPublicKey')]"
296-
}
297-
]
332+
"sshPublicKeys": "[if(empty(parameters('sshPublicKeys')), createArray(), parameters('sshPublicKeys'))]"
298333
},
299334
"initialAgentPoolConfigurations": [
300335
{
301336
"name": "[concat(parameters('kubernetesClusterName'), '-nodepool-1')]",
302-
"administratorConfiguration": {},
337+
"administratorConfiguration": {
338+
"adminUsername": "[parameters('adminUsername')]",
339+
"sshPublicKeys": "[if(empty(parameters('agentPoolSshKeys')), createArray(), parameters('agentPoolSshKeys'))]"
340+
},
303341
"count": "[parameters('systemPoolNodeCount')]",
304342
"vmSkuName": "[parameters('workerVmSkuName')]",
305343
"mode": "System",
@@ -318,7 +356,10 @@
318356
}
319357
],
320358
"controlPlaneNodeConfiguration": {
321-
"administratorConfiguration": {},
359+
"administratorConfiguration": {
360+
"adminUsername": "[parameters('adminUsername')]",
361+
"sshPublicKeys": "[if(empty(parameters('controlPlaneSshKeys')), createArray(), parameters('controlPlaneSshKeys'))]"
362+
},
322363
"count": "[parameters('controlPlaneCount')]",
323364
"vmSkuName": "[parameters('controlPlaneVmSkuName')]",
324365
"availabilityZones": "[if(empty(parameters('controlPlaneZones')), json('null'), parameters('controlPlaneZones'))]"

articles/operator-nexus/includes/kubernetes-cluster/quickstart-bicep-add-node-pool.bicep

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,14 @@ param tags object = {}
1414
@description('The username for the administrative account on the cluster')
1515
param adminUsername string = 'azureuser'
1616

17-
@description('The SSH public key that will be associated with the "azureuser" user for secure remote login')
18-
param sshPublicKey string = ''
17+
@description('The agent pool SSH public key that will be associated with the given user for secure remote login')
18+
param agentPoolSshKeys array = []
19+
// {
20+
// keyData: "ssh-rsa AAAAA...."
21+
// },
22+
// {
23+
// keyData: "ssh-rsa AAAAA...."
24+
// }
1925

2026
// Cluster Configuration Parameters
2127
@description('Number of nodes in the agent pool')
@@ -86,14 +92,10 @@ resource agentPools 'Microsoft.NetworkCloud/kubernetesClusters/agentPools@2023-0
8692
type: 'CustomLocation'
8793
}
8894
properties: {
89-
administratorConfiguration: sshPublicKey != '' ? {
95+
administratorConfiguration: {
9096
adminUsername: adminUsername
91-
sshPublicKeys: [
92-
{
93-
keyData: sshPublicKey
94-
}
95-
]
96-
}: {}
97+
sshPublicKeys: empty(agentPoolSshKeys) ? null : agentPoolSshKeys
98+
}
9799
attachedNetworkConfiguration: {
98100
l2Networks: empty(l2Networks) ? null : l2Networks
99101
l3Networks: empty(l3Networks) ? null : l3Networks

articles/operator-nexus/includes/kubernetes-cluster/quickstart-bicep-deploy.bicep

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,20 @@ param initialPoolAgentOptions object = {}
122122
// "hugepagesSize": "2M/1G"
123123
// }
124124

125-
@description('The SSH public key that will be associated with the "azureuser" user for secure remote login')
126-
param sshPublicKey string = ''
125+
@description('The cluster wide SSH public key that will be associated with the given user for secure remote login')
126+
param sshPublicKeys array = []
127+
128+
@description('The control plane SSH public key that will be associated with the given user for secure remote login')
129+
param controlPlaneSshKeys array = []
130+
131+
@description('The agent pool SSH public key that will be associated with the given user for secure remote login')
132+
param agentPoolSshKeys array = []
133+
// {
134+
// keyData: "ssh-rsa AAAAA...."
135+
// },
136+
// {
137+
// keyData: "ssh-rsa AAAAA...."
138+
// }
127139

128140
@description('The labels to assign to the nodes in the cluster for identification and organization')
129141
param labels array = []
@@ -157,16 +169,15 @@ resource kubernetescluster 'Microsoft.NetworkCloud/kubernetesClusters@2023-07-01
157169
}
158170
administratorConfiguration: {
159171
adminUsername: adminUsername
160-
sshPublicKeys: [
161-
{
162-
keyData: sshPublicKey
163-
}
164-
]
172+
sshPublicKeys: empty(sshPublicKeys) ? [] : sshPublicKeys
165173
}
166174
initialAgentPoolConfigurations: [
167175
{
168176
name: '${kubernetesClusterName}-nodepool-1'
169-
administratorConfiguration: {}
177+
administratorConfiguration: {
178+
adminUsername: adminUsername
179+
sshPublicKeys: empty(agentPoolSshKeys) ? [] : agentPoolSshKeys
180+
}
170181
count: systemPoolNodeCount
171182
vmSkuName: workerVmSkuName
172183
mode: 'System'
@@ -185,7 +196,10 @@ resource kubernetescluster 'Microsoft.NetworkCloud/kubernetesClusters@2023-07-01
185196
}
186197
]
187198
controlPlaneNodeConfiguration: {
188-
administratorConfiguration: {}
199+
administratorConfiguration: {
200+
adminUsername: adminUsername
201+
sshPublicKeys: empty(controlPlaneSshKeys) ? [] : controlPlaneSshKeys
202+
}
189203
count: controlPlaneCount
190204
vmSkuName: controlPlaneVmSkuName
191205
availabilityZones: empty(controlPlaneZones) ? null : controlPlaneZones

articles/operator-nexus/includes/kubernetes-cluster/quickstart-deploy-params.json

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,15 @@
2222
"location": {
2323
"value": "eastus"
2424
},
25-
"sshPublicKey": {
26-
"value": "ssh-rsa AAAAB...."
25+
"sshPublicKeys": {
26+
"value": [
27+
{
28+
"keyData": "ssh-rsa AAAAA...."
29+
},
30+
{
31+
"keyData": "ssh-rsa BBBBB...."
32+
}
33+
]
2734
}
2835
}
2936
}

articles/operator-nexus/quickstarts-kubernetes-cluster-deployment-cli.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ CLUSTER_NAME="myNexusK8sCluster"
6161
K8S_VERSION="v1.24.9"
6262
ADMIN_USERNAME="azureuser"
6363
SSH_PUBLIC_KEY="$(cat ~/.ssh/id_rsa.pub)"
64+
CONTROL_PLANE_SSH_PUBLIC_KEY="$(cat ~/.ssh/id_rsa.pub)"
65+
AGENT_POOL_SSH_PUBLIC_KEY="$(cat ~/.ssh/id_rsa.pub)"
6466
CONTROL_PLANE_COUNT="1"
6567
CONTROL_PLANE_VM_SIZE="NC_G6_28_v1"
6668
INITIAL_AGENT_POOL_NAME="${CLUSTER_NAME}-nodepool-1"
@@ -90,7 +92,8 @@ az networkcloud kubernetescluster create \
9092
--control-plane-node-configuration \
9193
count="${CONTROL_PLANE_COUNT}" \
9294
vm-sku-name="${CONTROL_PLANE_VM_SIZE}" \
93-
--initial-agent-pool-configurations "[{count:${INITIAL_AGENT_POOL_COUNT},mode:System,name:${INITIAL_AGENT_POOL_NAME},vm-sku-name:${INITIAL_AGENT_POOL_VM_SIZE}}]" \
95+
ssh-key-values='["${CONTROL_PLANE_SSH_PUBLIC_KEY}"]' \
96+
--initial-agent-pool-configurations "[{count:${INITIAL_AGENT_POOL_COUNT},mode:System,name:${INITIAL_AGENT_POOL_NAME},vm-sku-name:${INITIAL_AGENT_POOL_VM_SIZE},,ssh-key-values:['${AGENT_POOL_SSH_PUBLIC_KEY}']}]" \
9497
--network-configuration \
9598
cloud-services-network-id="${CSN_ARM_ID}" \
9699
cni-network-id="${CNI_ARM_ID}" \

0 commit comments

Comments
 (0)