Skip to content

Create container-core-clusters XPC service - #2451

Merged
egernst merged 3 commits into
apple:mainfrom
adityaramani:cluster-helper-ls
Nov 5, 2026
Merged

egernst merged 3 commits into
apple:mainfrom
adityaramani:cluster-helper-ls

Conversation

@adityaramani

@adityaramani adityaramani commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Closes #2452.

Added a new plugin binary container-core-clusters that handles cluster CRUD operations.

container cluster ls now prints one row per cluster (NAME, STATUS, NODES, K8S VERSION) instead of one row per node. Use --nodes for the per-node table, -q for names, and --format json|yaml|toml for the machine-readable configuration and state.

The requested configuration is persisted at create time by the helper plugin, which exposes an XPC service (create, get, list, delete) and owns <App Root>/plugin-state/container-core-clusters. The cluster CLI plugin is now a client of that service and no longer touches the data directory. Clusters without a stored configuration are not listed.

Sample output

➜ bin/container cluster ls
NAME  STATUS   NODES  K8S VERSION
foo   Running  4      v1.35.5


➜ bin/container cluster ls  --nodes
CLUSTER  NODE           ROLE           STATE    CPUS  MEMORY  ADDR          PORTS
foo      foo            control-plane  running  4     16 GB   192.168.64.2
foo      foo-worker-1   worker         running  4     16 GB   192.168.64.3
foo      foo-worker-2   worker         running  4     16 GB   192.168.64.4
foo      foo-worker-3   worker         running  4     16 GB   192.168.64.5


➜ bin/container cluster ls  -q
foo


➜ bin/container cluster ls  -q --nodes
foo
foo-worker-1
foo-worker-2
foo-worker-3

➜ bin/container cluster ls --format json  | jq .
[
  {
    "configuration": {
      "cni": null,
      "creationDate": "2026-11-03T19:40:50Z",
      "fqdn": "bar.vsl",
      "kubernetesVersion": "v1.35.5",
      "labels": {},
      "name": "bar",
      "nodes": [
        {
          "kind": "linux",
          "name": "bar",
          "roles": [
            "control-plane",
            "worker"
          ],
          "settings": {
            "cpus": 4,
            "memory": "16g",
            "nodeImage": "docker.io/kindest/node:v1.35.5@sha256:ce977ae6d65918d0b58a5f8b5e940429c2ce42fa3a5619ec2bbc60b949c0ac95",
            "remove": false
          }
        }
      ]
    },
    "id": "bar",
    "status": {
      "nodes": [
        {
          "addresses": [
            "192.168.64.6"
          ],
          "name": "bar",
          "status": "running"
        }
      ],
      "state": "running"
    }
  }
 ]

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Motivation and Context

Splitting the responsibility of managing state and container operations between the CLI and the XPC helper

Testing

  • Tested locally
  • Added/updated tests
  • Added/updated docs

@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Nov 3, 2026
@github-actions

github-actions Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Code Coverage

Tier Line Coverage
Unit 23.59%
Integration 69.86%
Combined 78.43%

)

try await clusterBootstrapper.create(progress: { progress.set(description: $0) }, log: log)
// Record the cluster before provisioning. Fails `.exists` for a live duplicate and replaces stale records.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For two concurrent cluster create --name foo commands:

  • The second sees no live node yet and treats the first's record as stale (ensureReplaceable), replacing it.
  • If their settings differ, ls then describes the second request's cluster even though the first one's containers won.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes this will happen today, I guess the right way to do it would be to move the cluster creation to the XPC helper and have it manage the creation of the nodes. But thats a bigger change which I think should be done in a follow up

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just create an issue afterward describing the problem. If it's something you'd want the community to take on but think there's nuances, propose in the issue that the potential contributor should first describe their approach in the issue comments and then we'll assign them.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opened #2453

@adityaramani
adityaramani force-pushed the cluster-helper-ls branch 2 times, most recently from 8f923ef to ce45096 Compare November 3, 2026 23:13
Comment thread docs/cluster.md Resolved
Comment thread docs/technical-overview.md Resolved
@egernst
egernst merged commit 07dee3d into apple:main Nov 5, 2026
4 checks passed
henrywang added a commit to henrywang/Berthly that referenced this pull request Nov 12, 2026
Closes #236.

Re-audits PARITY.md against container CLI 1.7.1, following #217 for
1.6.1. 1.7.1 changed no CLI flags outside `cluster` (diffed
`ContainerCommands`, `Flags.swift`, and the cluster plugin between 1.6.1
and 1.7.1).

## Changes

- **Header:** "Audited against" moves to 1.7.1 (2026-11-12).
- **`stats`:** CPU is a percentage of one core, the CLI's
`cpuUtilization` × 100 (#235).
- **Run/Create:**
- Empty DNS fields fall back to `[container.dns]`
(apple/container#1614), and a value in the sheet overrides them.
- Out-of-range cpus or memory get the CLI's own error, since 1.7.1
validates both on the client.
- **Builder:** gets the `[container.dns]` defaults, or the gateway's
resolver, and is recreated when its DNS changes (#233).
- **`property`:** the list includes the `container.dns.*` defaults
(#234).
- **`cluster` (deliberate gap):**
- Records the 1.7.1 changes: `load-image` replaced by
`--shared-image-store` (apple/container#2437), `cluster ls` per cluster
with `--nodes` (apple/container#2451), and per-worker cpus/memory
(apple/container#2448).
- Notes that the CLI now skips cluster nodes in
`ls`/`start`/`stop`/`kill`/`delete`/`prune` (apple/container#2462), as
Berthly already did (#204). `prune` isn't in #236's list, but the 1.7.1
source filters it too.
- The revisit condition is half met: the new `container-core-clusters`
XPC service only handles cluster records, and the command is still
EXPERIMENTAL.

Time Machine exclusion (apple/container#2412) and the smaller install
(apple/container#2458) are daemon-side with no CLI command to compare
against, so they get no entry.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
andrewkomkov added a commit to getgantry/gantry that referenced this pull request Nov 12, 2026
Apple container **1.7.1** is out. The previously tracked version is
`1.6.1`.

Upstream notes: https://github.com/apple/container/releases/tag/1.7.1. A
copy is in `docs/upstream/apple-container-1.7.1.md`.

Most of the 1.7.1 support is already on main from PR #57
(`specs/001-apple-container-1-7-1`) and PR #50 (clusters). This PR adds
no code. It adds the 1.7.1 features to the README and records the live
check in spec 001.

## Review checklist

- [x] New or changed CLI flags Gantry should surface: `cluster run
--shared-image-store` and `--workers count=,cpus=,memory=` came in PR
#50. The `run`, `create`, `machine` and `build` commands have no new
flags in 1.7.1.
- [x] Changed `--format json` shapes the DockerKit apple transport
decodes: only `stats` changed (`cpuUtilization`).
`AppleContainerJSON.statsBody` uses it, with the counter math as
fallback
(`Packages/DockerKit/Sources/DockerKit/AppleContainer/AppleContainerJSON.swift:653`).
The live output matches the test fixture. `container ls --format json`
did not change.
- [x] Fixed upstream bugs Gantry currently works around: none. The
BuildKit fixes (#2428, #2414) need no change in Gantry. The "Builder
image is outdated" card covers the new builder shim 0.13.3
(`AppleBuilderStatus.imageUpdate`).
- [x] `ContainerTooling.recommendedVersion` and feature gates:
`recommendedVersion = "1.7.1"`
(`Packages/AppCore/Sources/AppCore/ContainerTooling.swift:18`). The DNS
defaults are gated on 1.7.0 (`containerDNSDefaultsVersion`, line 46).
- [x] MCP tools and App Intents that expose the affected commands:
`container_stats` uses the same DockerKit decoder. `apple_set_property`
accepts lists for the DNS keys (PR #57). No App Intent shows the changed
commands.
- [x] README and CHANGELOG entries for whatever is adopted: the
CHANGELOG has the #57 and #50 lines. This PR adds the 1.7.1 features to
the README.

## Adopted (on main, checked again on CLI 1.7.1)

- Stats `cpuUtilization` (#2146). The old calculation stays as fallback
for 1.6.1.
- `[container.dns]` defaults in `config.toml` (#1614): a list editor in
System Properties, gated on 1.7.0.
- Recommended kernel (#2447): Gantry has no kernel version of its own.
It runs `system kernel set --recommended`.
- Cluster changes (#2437, #2448, #2451, #2462) came in PR #50. The
notice for missing or stopped cluster services came in PR #57.
- Builder shim 0.13.3: the outdated builder card.

## Not adopted, and why

- #2412 Time Machine exclusion, #2443 containerization 0.54.0, #2458
package size, #2470 copy blobs, #2416 bootstrapper, #2477 test library:
internal changes. Gantry has nothing to show for them.
- #2457, #2459, #2433, #2413: upstream docs and examples only.

## Checks

- `swift test` in DockerKit: 324 tests passed. AppCore
`AppleContainer171` tests: 19 passed.
- `scripts/check-localization.py`: 0 problems in 28 languages. This PR
adds no strings.
- Debug build on CLI 1.7.1: a busy test container shows 98 % CPU. The
CLI reports `cpuUtilization` 1.0 for it.
- The Builder card shows 0.13.2 to 0.13.3 in light and dark mode. System
Properties shows `[container.dns]`. The cluster list shows one row for
each cluster.
- Open (T035 in spec 001): two items had no check in the app. These are
the DNS list editor sheet and the cluster services notice. The editor
needs a click. The notice needs a broken cluster setup.

---

<details><summary>Upstream release notes</summary>

## Highlights

⌨️ denotes breaking CLI changes.

👩‍💻 denotes breaking API changes.

- Core
- [`container stats` now reports `cpuUtilization` in JSON, YAML, and
TOML output](apple/container#2146)
- [Image snapshots and container filesystems are now excluded from Time
Machine backups](apple/container#2412)
- [Default Kata kernel is now 4.3.1
(`vmlinux-6.18.56-208-debug`)](apple/container#2447)
- [Updated Containerization to
0.54.0](apple/container#2443)
- Networking
- [Default DNS nameservers, search domains, and options can now be set
in `config.toml`](apple/container#1614)
- Build
- [Fixed `container build` failures with newer
BuildKit](apple/container#2428) and [missing
build context for steps that need the full
context](apple/container#2414)
- Kubernetes
- ⌨️ [New `--shared-image-store` option on `container cluster run` to
use the `container` image store from cluster nodes; removed the
`load-image` subcommand](apple/container#2437)
- ⌨️ [`container cluster ls` now shows one row per cluster; use
`--nodes` for the per-node
view](apple/container#2451)
- ⌨️ [Container lifecycle commands no longer operate on cluster
nodes](apple/container#2462)
- [Worker node CPU and memory can now be set with `--workers
count=<n>,cpus=<n>,memory=<size>`](apple/container#2448)

## What's Changed
* Send an :authority on the builder gRPC connection by @jglogan in
apple/container#2428
* Adds `container cluster` example. by @jglogan in
apple/container#2433
* Update container-builder-shim to 0.13.3. by @jglogan in
apple/container#2434
* use macos 27 runners by @madrob in
apple/container#2436
* Fix empty followpaths handling in BuildFSSync by @onlyarnav in
apple/container#2414
* Document container clean in the reclaim disk space guide by
@lucasbrito-wdt in apple/container#2413
* Bump to use containerization 0.54.0 by @adityaramani in
apple/container#2443
* feat(stats): report cpuUtilization in the machine-readable formats by
@guanchzhou in apple/container#2146
* [k8s plugin] Create a cluster bootstrapper by @katiewasnothere in
apple/container#2416
* Update recommended kernel to kata 4.3.1 release
vmlinux-6.18.56-208-debug by @katiewasnothere in
apple/container#2447
* Add TOML configuration for default DNS nameservers, search, options by
@0xMH in apple/container#1614
* Add the ability to share container's image store with container
cluster by @crosbymichael in
apple/container#2437
* Reduce install package size and install footprint. by @jglogan in
apple/container#2458
* Add reference to apple/container-examples and remove examples/ out of
this repo by @michaelzhang114 in
apple/container#2457
* Create container-core-clusters XPC service by @adityaramani in
apple/container#2451
* Exclude recreatable container data from Time Machine by @abdullahtas0
in apple/container#2412
* Clean the `cluster-shim` build files with `make clean` by @dkovba in
apple/container#2463
* Quiet the `cluster-shim` build output and show the swift progress in
place by @dkovba in apple/container#2461
* Do not allow high level container lifecycle commands to operate on
cluster nodes by @katiewasnothere in
apple/container#2462
* Switch to copy blobs by @crosbymichael in
apple/container#2470
* Add option to set cpus and memory resources for worker nodes of
cluster by @katiewasnothere in
apple/container#2448
* Removed bug-report-how-to.md as this info is now consolidated in
CONTRIBUTING.md by @michaelzhang114 in
apple/container#2459
* Move HostStoreServer into a library so tests don't link the executable
by @katiewasnothere in apple/container#2477

## New Contributors
* @madrob made their first contribution in
apple/container#2436
* @onlyarnav made their first contribution in
apple/container#2414
* @lucasbrito-wdt made their first contribution in
apple/container#2413
* @abdullahtas0 made their first contribution in
apple/container#2412

**Full Changelog**:
apple/container@1.6.1...1.7.1

</details>

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: andrewkomkov <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Request]: Server-side container cluster resource management.

4 participants