-
Notifications
You must be signed in to change notification settings - Fork 12
Add flex node added into / remove from Private AKS cluster #55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
e1ff0af
f583f12
2997606
7b43aeb
66e48e0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -55,8 +55,12 @@ type BootstrapTokenConfig struct { | |
|
|
||
| // TargetClusterConfig holds configuration for the target AKS cluster the ARC machine will connect to. | ||
| type TargetClusterConfig struct { | ||
| ResourceID string `json:"resourceId"` // Full resource ID of the target AKS cluster | ||
| Location string `json:"location"` // Azure region of the cluster (e.g., "eastus", "westus2") | ||
| ResourceID string `json:"resourceId"` // Full resource ID of the target AKS cluster | ||
| Location string `json:"location"` // Azure region of the cluster (e.g., "eastus", "westus2") | ||
| IsPrivateCluster bool `json:"private" mapstructure:"private"` // Whether this is a private AKS cluster (requires Gateway/VPN setup) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. reconsider the naming private cluster, since this applies to other use cases: VM/BM within VPC from 3rd party cloud, physical machine behind office firewall
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point. Agreed. VPN connections are not limited to private clusters. Currently, "private: true" is used as the trigger condition; this can be changed to "gateway: true" or other conditions in the future to support more network scenarios.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we update it in the following PR as the current PR is already big? |
||
| GatewayVMSize string `json:"gatewayVMSize,omitempty" mapstructure:"gatewayVMSize"` // VPN Gateway VM size (defaults to "Standard_D2s_v3") | ||
| GatewayPort int `json:"gatewayPort,omitempty" mapstructure:"gatewayPort"` // VPN Gateway port (defaults to 51820) | ||
| CleanupMode string `json:"-"` // Runtime-only, set by CLI flag for unbootstrap | ||
| Name string // will be populated from ResourceID | ||
| ResourceGroup string // will be populated from ResourceID | ||
| SubscriptionID string // will be populated from ResourceID | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| # Private AKS Cluster - Edge Node Join/Leave | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. consolidate with create_private_cluster.md into one usage doc?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, will do it. |
||
|
|
||
| ## Prerequisites | ||
|
|
||
| ### 1. Login to Azure CLI | ||
|
|
||
| ```bash | ||
| az login | ||
| ``` | ||
|
|
||
| > **Note:** When running the agent with `sudo`, use `sudo -E` to preserve your Azure CLI token. | ||
|
|
||
| ### 2. Create a Private AKS Cluster | ||
|
|
||
| Create a Private AKS cluster with AAD and Azure RBAC enabled, and assign the required roles to your user. | ||
|
|
||
| See: [create_private_cluster.md](create_private_cluster.md) | ||
|
|
||
| ### 3. Prepare Configuration File | ||
|
|
||
| Create a `config.json` with `"private": true` in the `targetCluster` section: | ||
|
|
||
| ```json | ||
| { | ||
| "azure": { | ||
| "subscriptionId": "<SUBSCRIPTION_ID>", | ||
| "tenantId": "<TENANT_ID>", | ||
| "targetCluster": { | ||
| "resourceId": "/subscriptions/<SUB_ID>/resourceGroups/<RG>/providers/Microsoft.ContainerService/managedClusters/<CLUSTER_NAME>", | ||
| "location": "eastus2", | ||
| "private": true | ||
| }, | ||
| "arc": { | ||
| "enabled": true, | ||
| "resourceGroup": "<RG>", | ||
| "location": "eastus2" | ||
| } | ||
| }, | ||
| "kubernetes": { | ||
| "version": "1.33.0" | ||
| }, | ||
| "containerd": { | ||
| "version": "1.7.11", | ||
| "pauseImage": "mcr.microsoft.com/oss/kubernetes/pause:3.6" | ||
| }, | ||
| "agent": { | ||
| "logLevel": "info", | ||
| "logDir": "/var/log/aks-flex-node" | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ## Join Private AKS Cluster | ||
|
|
||
| ### 1. Build the project | ||
|
|
||
| ```bash | ||
| go build -o aks-flex-node . | ||
| ``` | ||
|
|
||
| ### 2. Join the cluster | ||
|
|
||
| When the config has `"private": true`, the `agent` command automatically sets up the Gateway/VPN before bootstrapping: | ||
|
|
||
| ```bash | ||
| sudo -E ./aks-flex-node agent --config config.json | ||
| ``` | ||
|
|
||
| This will: | ||
| 1. Detect private cluster from config | ||
| 2. Set up Gateway VM and VPN tunnel (WireGuard) | ||
| 3. Run normal bootstrap (Arc, containerd, kubelet, etc.) | ||
| 4. Enter daemon mode for status monitoring | ||
|
|
||
| ### 3. Verify | ||
|
|
||
| ```bash | ||
| kubectl get nodes | ||
| ``` | ||
|
|
||
| ## Leave Private AKS Cluster | ||
|
|
||
| When the config has `"private": true`, the `unbootstrap` command automatically handles VPN/Gateway cleanup: | ||
|
|
||
| ```bash | ||
| sudo -E ./aks-flex-node unbootstrap --config config.json [--cleanup-mode <local|full>] | ||
| ``` | ||
|
|
||
| ### Mode Comparison | ||
|
|
||
| | Mode | Command | Description | | ||
| |------|---------|-------------| | ||
| | `local` (default) | `sudo -E ./aks-flex-node unbootstrap --config config.json` | Remove node and local VPN config, **keep Gateway** for other nodes | | ||
| | `full` | `sudo -E ./aks-flex-node unbootstrap --config config.json --cleanup-mode full` | Remove all components **including Gateway VM and Azure resources** | | ||
|
|
||
| ### When to use each mode | ||
|
|
||
| - **`--cleanup-mode=local`** (default): Other nodes are still using the Gateway, or you plan to rejoin later | ||
| - **`--cleanup-mode=full`**: Last node leaving, clean up all Azure resources (Gateway VM, subnet, NSG, public IP) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rm?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes