Repository navigation
[SDK/CLI] Add self-serve cluster management - #165
Conversation
Expose POST /clusters as CentMLClient.register_cluster and a `register` CLI command so users can register their own cluster. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Expose PUT /clusters/{id} as CentMLClient.update_cluster and an
`update` CLI command that reads the components from a YAML or JSON file.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Could we validate this change by exercising the lifecycle of a real cluster? |
|
Two non-blocking structural nits:
The thin SDK wrappers and separate register/update examples fit the existing structure. I don't think this PR needs a broader module split. |
Add CentMLClient.delete_cluster, list_clusters and delete_cluster CLI commands, and a delete_cluster example. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Ran it locally with 1. An empty entry in the components file uninstalls that component. Say someone writes final_stack: {}
istio:
2. The SDK path doesn't get the CLI's checks. 3. These commands 404 on prod today. register/update/delete sit behind 4. +1 to HanFa on a real-cluster run. Every new test mocks the client, so #1 and the server-side 5. +1 to Michael on naming. The scariest part is that Smaller things (non-blocking)
|
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The file now has the API's {"components": {...}} shape, in YAML or JSON,
so the same file works with the API and the CLI.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… command names - CentMLClient.update_cluster takes the request body as a dict and rejects empty components (which would be uninstalled), unknown or non-string component names, and a missing or misspelled components key, before building the request with from_dict. The CLI and the example use it. - Rename the cluster commands to register-cluster, update-cluster, list-clusters and delete-cluster. - Accept --cloud-provider in any case; reword the delete prompt for clusters not managed by ccluster; use a PEM-shaped ca_cert in tests; note in the update example that it resets every component to its defaults. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Tested end to end on dev (
|
…s it can't do from_dict already rejects a missing or misspelled components key, a non-mapping body and a missing final_stack. Keep only the two mistakes it accepts and the server would read as an uninstall: an unknown component name and a component with no values. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@michaelshin Thanks! Renamed to |
|
@V2arK Thanks for the thorough run.
Smaller: non-string keys, |
|
@anandj91 I tried to rerun with my agent, and it looks good now. LGTM :) |
Expose the platform's self-serve cluster endpoints so users can register, configure, list and delete their own clusters from the SDK or CLI instead of calling the API directly.
Register (
POST /clusters)CentMLClient.register_cluster(request: ClusterRegistrationRequest)returns aClusterRegistrationResponsecarrying the new cluster'sid.ccluster register-clustertakes--name,--storage-class,--server,--ca-cert(base64 PEM, as in a kubeconfig'scertificate-authority-data), and optional--regionand--cloud-provider(any case). If--bearer-tokenis omitted, it prompts for the token with hidden input so it stays out of shell history.Update components (
PUT /clusters/{id})CentMLClient.update_cluster(cluster_id, request: dict)takes the request body,{"components": {name: chart values}}. It builds the request withUpdateClusterRequest.from_dict, because the generated constructors drop chart keys the typed models don't list (CentML/platform#4946), and reports its validation errors asValueError. On top of that it rejects, without calling the API, the two mistakesfrom_dictaccepts and the server would read as "not requested", uninstalling the component:ingress-nginx), whichfrom_dictdrops;istio:), which is sent asnull.ccluster update-cluster CLUSTER_ID REQUEST_FILE, where the file is the same request body in YAML or JSON, so one file works with the API, the SDK and the CLI. It goes through the SDK's validation and reports problems as CLI errors.PyYAMLas a dependency (types-PyYAMLfor dev).List (
GET /clusters)CentMLClient.get_clusters().ccluster list-clustersprints the ID, name and region of each cluster the caller has access to.Delete (
DELETE /clusters/{id})CentMLClient.delete_cluster(cluster_id).ccluster delete-cluster CLUSTER_IDasks for confirmation first;--yesskips the prompt. For a cluster managed by ccluster, the server also uninstalls the components installed through it.Examples:
examples/sdk/register_cluster.pyregisters a cluster from environment variables.examples/sdk/update_cluster.pysets every component to its chart defaults on the cluster named byCLUSTER_ID.examples/sdk/delete_cluster.pydeletes it. Listing is already covered byexamples/sdk/get_clusters.py.The README has a new "Managing your own clusters" section with the CLI commands, including installing the
ccluster-ipoperator first.These endpoints are all already in the pinned
platform-api-python-client==4.41.0. On the platform side, register, update and delete require dev features to be enabled andPERM_ADMIN_MANAGE_HARDWARE.Validation:
python -m pytest tests -q: 151 passed. The CLI update tests run the SDK's real validation, with only the generated API mocked../scripts/format.sh,./scripts/lint.sh(10.00/10),./scripts/typecheck.sh: passed.api.centml.org) with a real GKE cluster:register-clusterregistered it,list-clusterslists it, andupdate-clusterinstalled the cluster-base components, after which the cluster's infra-plane operator reportedVerified=True("All 14 cluster_base components are installed and configured").delete-clusterhas not been run against a real cluster.🤖 Generated with Claude Code