Skip to content

Commit cda52a1

Browse files
Copilotvipul-21
andcommitted
Add resource group configuration option to BYO CNI cluster script
Co-authored-by: vipul-21 <[email protected]>
1 parent 5e5e43f commit cda52a1

File tree

2 files changed

+32
-6
lines changed

2 files changed

+32
-6
lines changed

hack/aks/README-byocni.md

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ cd /path/to/azure-container-networking
5858
|-----------|-------------|---------|
5959
| `--cluster` | Name of the AKS cluster | `byocni-cluster` |
6060
| `--subscription` | Azure subscription ID | *Required* |
61+
| `--resource-group` | Resource group name | Same as cluster name |
6162
| `--azcli` | Azure CLI command | `az` |
6263
| `--kubernetes-version` | Kubernetes version for the cluster | `1.33` |
6364
| `--networking-mode` | Networking mode (overlay, swift, nodesubnet, dualstack-overlay, vnetscale-swift) | `overlay` |
@@ -126,7 +127,16 @@ cd /path/to/azure-container-networking
126127
--cilium-dir 1.16
127128
```
128129

129-
### Example 4: Cluster with kube-proxy enabled
130+
### Example 4: Custom cluster and resource group
131+
```bash
132+
cd /path/to/azure-container-networking
133+
./hack/aks/create-byocni-cluster.sh \
134+
--cluster my-aks-cluster \
135+
--resource-group my-resource-group \
136+
--subscription 9b8218f9-902a-4d20-a65c-e98acec5362f
137+
```
138+
139+
### Example 5: Cluster with kube-proxy enabled
130140
```bash
131141
cd /path/to/azure-container-networking
132142
./hack/aks/create-byocni-cluster.sh \
@@ -135,7 +145,7 @@ cd /path/to/azure-container-networking
135145
--with-kube-proxy
136146
```
137147

138-
### Example 5: Dualstack cluster with Cilium
148+
### Example 6: Dualstack cluster with Cilium
139149
```bash
140150
cd /path/to/azure-container-networking
141151
./hack/aks/create-byocni-cluster.sh \
@@ -145,7 +155,7 @@ cd /path/to/azure-container-networking
145155
--cilium-version-tag v1.17.0
146156
```
147157

148-
### Example 6: Cluster with specific Kubernetes version
158+
### Example 7: Cluster with specific Kubernetes version
149159
```bash
150160
cd /path/to/azure-container-networking
151161
./hack/aks/create-byocni-cluster.sh \
@@ -155,15 +165,15 @@ cd /path/to/azure-container-networking
155165
--cni-plugin cilium
156166
```
157167

158-
### Example 7: Only cluster and CNS, no CNI plugin
168+
### Example 8: Only cluster and CNS, no CNI plugin
159169
```bash
160170
cd /path/to/azure-container-networking
161171
./hack/aks/create-byocni-cluster.sh \
162172
--subscription 9b8218f9-902a-4d20-a65c-e98acec5362f \
163173
--cni-plugin none
164174
```
165175

166-
### Example 8: Using different image registry
176+
### Example 9: Using different image registry
167177
```bash
168178
cd /path/to/azure-container-networking
169179
./hack/aks/create-byocni-cluster.sh \

hack/aks/create-byocni-cluster.sh

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ set -euo pipefail
99
# Default configuration
1010
DEFAULT_CLUSTER_NAME="byocni-cluster"
1111
DEFAULT_SUB=""
12+
DEFAULT_RESOURCE_GROUP=""
1213
DEFAULT_NETWORKING_MODE="overlay"
1314
DEFAULT_NO_KUBE_PROXY="true"
1415
DEFAULT_CNI_PLUGIN="cilium"
@@ -39,6 +40,7 @@ Creates a BYO CNI cluster with the following steps:
3940
OPTIONS:
4041
-c, --cluster CLUSTER_NAME Name of the AKS cluster (default: ${DEFAULT_CLUSTER_NAME})
4142
-s, --subscription SUB_ID Azure subscription ID (required)
43+
-g, --resource-group GROUP Resource group name (default: same as cluster name)
4244
-z, --azcli AZCLI_COMMAND Azure CLI command (default: ${DEFAULT_AZCLI})
4345
-k, --kubernetes-version VER Kubernetes version for the cluster (default: ${DEFAULT_KUBERNETES_VERSION})
4446
-n, --networking-mode MODE Networking mode: overlay, swift, nodesubnet, dualstack-overlay, vnetscale-swift (default: ${DEFAULT_NETWORKING_MODE})
@@ -80,6 +82,9 @@ EXAMPLES:
8082
# Custom cluster name and CNS version
8183
$0 --cluster my-cluster --subscription 9b8218f9-902a-4d20-a65c-e98acec5362f --cns-version v1.6.0
8284
85+
# Custom cluster name and resource group
86+
$0 --cluster my-cluster --resource-group my-rg --subscription 9b8218f9-902a-4d20-a65c-e98acec5362f
87+
8388
# Cluster with kube-proxy enabled
8489
$0 --subscription 9b8218f9-902a-4d20-a65c-e98acec5362f --with-kube-proxy
8590
@@ -319,7 +324,12 @@ create_cluster() {
319324
log "Kubernetes version ${KUBERNETES_VERSION} is >= 1.31, setting LTS=false"
320325
fi
321326

322-
local make_cmd="AZCLI=${AZCLI} CLUSTER=${CLUSTER_NAME} SUB=${SUBSCRIPTION} K8S_VER=${KUBERNETES_VERSION} LTS=${lts_setting} make ${make_target}"
327+
# Build make command with optional GROUP parameter
328+
local make_cmd="AZCLI=${AZCLI} CLUSTER=${CLUSTER_NAME} SUB=${SUBSCRIPTION} K8S_VER=${KUBERNETES_VERSION} LTS=${lts_setting}"
329+
if [[ -n "${RESOURCE_GROUP}" ]]; then
330+
make_cmd="${make_cmd} GROUP=${RESOURCE_GROUP}"
331+
fi
332+
make_cmd="${make_cmd} make ${make_target}"
323333

324334
log "Using make target: ${make_target}"
325335
execute "cd '${SCRIPT_DIR}' && ${make_cmd}"
@@ -480,6 +490,7 @@ show_completion_message() {
480490
# Parse command line arguments
481491
CLUSTER_NAME="${DEFAULT_CLUSTER_NAME}"
482492
SUBSCRIPTION="${DEFAULT_SUB}"
493+
RESOURCE_GROUP="${DEFAULT_RESOURCE_GROUP}"
483494
NETWORKING_MODE="${DEFAULT_NETWORKING_MODE}"
484495
NO_KUBE_PROXY="${DEFAULT_NO_KUBE_PROXY}"
485496
CNI_PLUGIN="${DEFAULT_CNI_PLUGIN}"
@@ -504,6 +515,10 @@ while [[ $# -gt 0 ]]; do
504515
SUBSCRIPTION="$2"
505516
shift 2
506517
;;
518+
-g|--resource-group)
519+
RESOURCE_GROUP="$2"
520+
shift 2
521+
;;
507522
-z|--azcli)
508523
AZCLI="$2"
509524
shift 2
@@ -585,6 +600,7 @@ main() {
585600
log "Configuration:"
586601
log " Cluster Name: ${CLUSTER_NAME}"
587602
log " Subscription: ${SUBSCRIPTION}"
603+
log " Resource Group: ${RESOURCE_GROUP:-${CLUSTER_NAME}}"
588604
log " Azure CLI: ${AZCLI}"
589605
log " Kubernetes Version: ${KUBERNETES_VERSION}"
590606
log " Networking Mode: ${NETWORKING_MODE}"

0 commit comments

Comments
 (0)