Skip to content

Commit 139d152

Browse files
AtharvaCopilot
andcommitted
feat: enhanced target create with onboarding simplification flags
Add --init-extended-location, --init-context, --init-hierarchy, --service-group, and --release-train flags to 'az workload-orchestration target create' to reduce onboarding from 15+ manual steps to a single command. New commands: - target prepare: Prepares Arc cluster (cert-mgr, trust-mgr, extension, CL) - hierarchy create: Creates site hierarchy (SG, Site, Config, SiteRef) Pre-operation hooks in target create: 1. --init-extended-location: calls target_prepare to set up cluster + CL 2. --init-context: discovers/creates WO context with capability injection 3. --init-hierarchy: creates site hierarchy linked to context 4. Default target-specification: injects Helm v3 in-cluster if not provided Post-operation hook: 5. --service-group: links target to a service group after creation 8 flag combinations supported (from vanilla to full onboarding). Includes unit tests for hierarchy, SG link, utils, and target prepare. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 0f3c8a9 commit 139d152

15 files changed

Lines changed: 2817 additions & 8 deletions

File tree

src/workload-orchestration/azext_workload_orchestration/_help.py

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,72 @@
4646
- name: Use a specific kubeconfig and context
4747
text: az workload-orchestration support create-bundle --kube-config ~/.kube/prod-config --kube-context my-cluster
4848
"""
49+
50+
helps['workload-orchestration target prepare'] = """
51+
type: command
52+
short-summary: Prepare an Arc-connected Kubernetes cluster for Workload Orchestration.
53+
long-summary: |
54+
Installs all prerequisites needed to run Workload Orchestration on an Arc-connected
55+
Kubernetes cluster. This is a convenience command that wraps multiple setup steps into one.
56+
57+
Steps performed:
58+
1. Install cert-manager (if not already installed)
59+
2. Install trust-manager via helm (if not already installed)
60+
3. Install the WO extension (microsoft.workloadorchestration)
61+
4. Create a custom location linked to the cluster and extension
62+
63+
Prerequisites:
64+
- Cluster must already be Arc-connected (az connectedk8s connect)
65+
- kubectl must be in PATH and configured for the target cluster
66+
- helm must be in PATH (required for trust-manager)
67+
68+
The command is idempotent - it skips components that are already installed.
69+
On completion, it outputs an extended-location.json file in the current directory
70+
for use with target create.
71+
examples:
72+
- name: Prepare a cluster with defaults
73+
text: az workload-orchestration target prepare --cluster-name my-cluster -g my-rg -l eastus
74+
- name: Prepare with a specific extension version
75+
text: az workload-orchestration target prepare --cluster-name my-cluster -g my-rg -l eastus --extension-version 2.1.18
76+
- name: Prepare without waiting for extension (fire and forget)
77+
text: az workload-orchestration target prepare --cluster-name my-cluster -g my-rg -l eastus --no-wait
78+
- name: Skip cert-manager (already installed separately)
79+
text: az workload-orchestration target prepare --cluster-name my-cluster -g my-rg -l eastus --skip-cert-manager
80+
- name: Use a specific kubeconfig
81+
text: az workload-orchestration target prepare --cluster-name my-cluster -g my-rg -l eastus --kube-config ~/.kube/prod
82+
"""
83+
84+
helps['workload-orchestration hierarchy'] = """
85+
type: group
86+
short-summary: Commands for managing WO site hierarchy levels.
87+
"""
88+
89+
helps['workload-orchestration hierarchy create'] = """
90+
type: command
91+
short-summary: Create a hierarchy level (Service Group + Site + Configuration) in one command.
92+
long-summary: |
93+
Creates all resources needed for a single hierarchy level in Workload Orchestration.
94+
This replaces 4 separate az rest calls with a single CLI command.
95+
96+
Resources created:
97+
1. Service Group (Microsoft.Management/serviceGroups)
98+
2. Site (Microsoft.Edge/sites) — in the Service Group
99+
3. Configuration (Microsoft.Edge/configurations) — in the Resource Group
100+
4. Configuration Reference — links the Configuration to the Site
101+
102+
If no WO context exists, one is auto-created and set as the current context.
103+
A site-reference is also auto-created to link the site to the context.
104+
105+
All operations are idempotent (PUT upsert) — safe to re-run.
106+
examples:
107+
- name: Create a top-level Region hierarchy
108+
text: az workload-orchestration hierarchy create --name my-region -g my-rg -l eastus --level-label Region
109+
- name: Create a Factory nested under Region
110+
text: az workload-orchestration hierarchy create --name my-factory -g my-rg -l eastus --level-label Factory --parent my-region
111+
- name: Create with capabilities (auto-added to context)
112+
text: az workload-orchestration hierarchy create --name my-region -g my-rg -l eastus --level-label Region --capabilities soap shampoo
113+
- name: Use an existing context
114+
text: az workload-orchestration hierarchy create --name my-factory -g my-rg -l eastus --level-label Factory --context-name my-context --context-rg context-rg
115+
- name: Skip context auto-creation (manual context management)
116+
text: az workload-orchestration hierarchy create --name my-factory -g my-rg -l eastus --level-label Factory --skip-context
117+
"""

src/workload-orchestration/azext_workload_orchestration/_params.py

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,148 @@ def load_arguments(self, _): # pylint: disable=unused-argument
6565
options_list=['--kube-context'],
6666
help='Kubernetes context to use. Defaults to current context.',
6767
)
68+
69+
# -----------------------------------------------------------------------
70+
# target prepare
71+
# -----------------------------------------------------------------------
72+
with self.argument_context('workload-orchestration target prepare') as c:
73+
c.argument(
74+
'cluster_name',
75+
options_list=['--cluster-name'],
76+
help='Name of the Arc-connected Kubernetes cluster.',
77+
required=True,
78+
)
79+
c.argument(
80+
'resource_group',
81+
options_list=['--resource-group', '-g'],
82+
help='Resource group of the cluster.',
83+
required=True,
84+
)
85+
c.argument(
86+
'location',
87+
options_list=['--location', '-l'],
88+
help='Azure region (e.g., eastus, westeurope).',
89+
required=True,
90+
)
91+
c.argument(
92+
'extension_name',
93+
options_list=['--extension-name'],
94+
help='Name for the WO extension. Defaults to wo-extension.',
95+
)
96+
c.argument(
97+
'custom_location_name',
98+
options_list=['--custom-location-name'],
99+
help='Name for the custom location. Defaults to {cluster-name}-cl.',
100+
)
101+
c.argument(
102+
'extension_version',
103+
options_list=['--extension-version'],
104+
help='WO extension version to install (e.g., 2.1.18).',
105+
)
106+
c.argument(
107+
'release_train',
108+
options_list=['--release-train'],
109+
help='Extension release train. Defaults to preview.',
110+
)
111+
c.argument(
112+
'cert_manager_version',
113+
options_list=['--cert-manager-version'],
114+
help='cert-manager version to install. Defaults to v1.15.3.',
115+
)
116+
c.argument(
117+
'skip_cert_manager',
118+
options_list=['--skip-cert-manager'],
119+
action='store_true',
120+
help='Skip cert-manager installation.',
121+
)
122+
c.argument(
123+
'skip_trust_manager',
124+
options_list=['--skip-trust-manager'],
125+
action='store_true',
126+
help='Skip trust-manager installation.',
127+
)
128+
c.argument(
129+
'kube_config',
130+
options_list=['--kube-config'],
131+
help='Path to kubeconfig file. Defaults to ~/.kube/config.',
132+
)
133+
c.argument(
134+
'kube_context',
135+
options_list=['--kube-context'],
136+
help='Kubernetes context to use. Defaults to current context.',
137+
)
138+
c.argument(
139+
'no_wait',
140+
options_list=['--no-wait'],
141+
action='store_true',
142+
help="Don't wait for the WO extension to finish installing.",
143+
)
144+
145+
# -----------------------------------------------------------------------
146+
# hierarchy create
147+
# -----------------------------------------------------------------------
148+
with self.argument_context('workload-orchestration hierarchy create') as c:
149+
c.argument(
150+
'name',
151+
options_list=['--name', '-n'],
152+
help='Name for this hierarchy level. Used for Service Group, Site, and '
153+
'Configuration resources. Maximum 24 characters.',
154+
required=True,
155+
)
156+
c.argument(
157+
'resource_group',
158+
options_list=['--resource-group', '-g'],
159+
help='Resource group for the Configuration resource.',
160+
required=True,
161+
)
162+
c.argument(
163+
'location',
164+
options_list=['--location', '-l'],
165+
help='Azure region (determines regional API endpoint for Site/Config).',
166+
required=True,
167+
)
168+
c.argument(
169+
'level_label',
170+
options_list=['--level-label'],
171+
help='Label for this hierarchy level (e.g., Region, Factory, Line).',
172+
required=True,
173+
)
174+
c.argument(
175+
'parent',
176+
options_list=['--parent'],
177+
help='Parent service group name for nesting. '
178+
'Omit for top-level (parent defaults to tenant root).',
179+
)
180+
c.argument(
181+
'capabilities',
182+
options_list=['--capabilities'],
183+
nargs='+',
184+
help='Capabilities to add to the WO context (e.g., soap shampoo).',
185+
)
186+
c.argument(
187+
'description',
188+
options_list=['--description'],
189+
help='Description for the Site resource. Defaults to the name.',
190+
)
191+
c.argument(
192+
'context_name',
193+
options_list=['--context-name'],
194+
help='Use an existing context by name (skip auto-create).',
195+
)
196+
c.argument(
197+
'context_rg',
198+
options_list=['--context-rg'],
199+
help='Resource group of the existing context.',
200+
)
201+
c.argument(
202+
'skip_context',
203+
options_list=['--skip-context'],
204+
action='store_true',
205+
help='Skip auto-creation of context and site-reference.',
206+
)
207+
c.argument(
208+
'skip_site_reference',
209+
options_list=['--skip-site-reference'],
210+
action='store_true',
211+
help='Skip auto-creation of site-reference to context.',
212+
)

0 commit comments

Comments
 (0)