Skip to content

Commit 97ced0c

Browse files
committed
docs: add k8s plugin command reference
1 parent ea34c22 commit 97ced0c

2 files changed

Lines changed: 173 additions & 1 deletion

File tree

.github/workflows/common.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
buildAndTest:
2424
name: Build and test the project
2525
if: github.repository == 'apple/container'
26-
timeout-minutes: 75
26+
timeout-minutes: 90
2727
runs-on: [self-hosted, macos, tahoe, ARM64]
2828
permissions:
2929
contents: read

docs/command-reference.md

Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1579,3 +1579,175 @@ container system property list
15791579
# output as JSON for scripting
15801580
container system property list --format json
15811581
```
1582+
1583+
## Kubernetes Cluster Management
1584+
1585+
`container k8s` manages local single-node Kubernetes clusters backed by container VMs. Each cluster runs a Kubernetes control-plane node inside a container using `kindest/node` and `kubeadm`.
1586+
1587+
> [!IMPORTANT]
1588+
> The `k8s` command is an experimental feature and its subcommands and options are subject to change.
1589+
1590+
### `container k8s create`
1591+
1592+
Creates and starts a local Kubernetes cluster. Pulls the node image if needed, runs `kubeadm init`, installs the kindnet CNI, and merges the cluster credentials into `~/.kube/config`.
1593+
1594+
**Usage**
1595+
1596+
```bash
1597+
container k8s create [--name <name>] [--node-image <image>] [--rm] [<resource options>] [--debug]
1598+
```
1599+
1600+
**Options**
1601+
1602+
* `--name <name>`: Cluster name (default: `k8s-dev`)
1603+
* `--node-image <image>`: Node image reference (default: `docker.io/kindest/node:v1.35.5`)
1604+
* `--rm`: Remove the cluster container after it stops
1605+
1606+
**Resource Options**
1607+
1608+
* `--cpus <cpus>`: Number of virtual CPUs (default: 1/4 of host CPUs, minimum 2)
1609+
* `--memory <memory>`: Memory allocation (default: 1/4 of host memory, minimum 2g)
1610+
1611+
**Registry Options**
1612+
1613+
* `--scheme <scheme>`: Scheme for the container registry (values: http, https, auto; default: auto)
1614+
1615+
**Image Fetch Options**
1616+
1617+
* `--max-concurrent-downloads <n>`: Maximum number of concurrent downloads (default: 3)
1618+
1619+
**Examples**
1620+
1621+
```bash
1622+
# create a cluster with the default name (k8s-dev)
1623+
container k8s create
1624+
1625+
# create a cluster with a custom name and resource allocation
1626+
container k8s create --name my-cluster --cpus 4 --memory 8g
1627+
1628+
# create a cluster that removes itself when stopped
1629+
container k8s create --name temp-cluster --rm
1630+
```
1631+
1632+
### `container k8s start`
1633+
1634+
Starts a stopped Kubernetes cluster and refreshes its entry in `~/.kube/config` (the container IP can change between starts).
1635+
1636+
**Usage**
1637+
1638+
```bash
1639+
container k8s start [--name <name>] [--debug]
1640+
```
1641+
1642+
**Options**
1643+
1644+
* `--name <name>`: Cluster name (default: `k8s-dev`)
1645+
1646+
**Examples**
1647+
1648+
```bash
1649+
# start the default cluster
1650+
container k8s start
1651+
1652+
# start a named cluster
1653+
container k8s start --name my-cluster
1654+
```
1655+
1656+
### `container k8s delete (rm)`
1657+
1658+
Stops and deletes a Kubernetes cluster container and removes its entry from `~/.kube/config`.
1659+
1660+
**Usage**
1661+
1662+
```bash
1663+
container k8s delete [--name <name>] [--debug]
1664+
```
1665+
1666+
**Options**
1667+
1668+
* `--name <name>`: Cluster name (default: `k8s-dev`)
1669+
1670+
**Examples**
1671+
1672+
```bash
1673+
# delete the default cluster
1674+
container k8s delete
1675+
1676+
# delete a named cluster
1677+
container k8s delete --name my-cluster
1678+
container k8s rm --name my-cluster
1679+
```
1680+
1681+
### `container k8s list (ls)`
1682+
1683+
Lists all Kubernetes clusters with their status and node image.
1684+
1685+
**Usage**
1686+
1687+
```bash
1688+
container k8s list [--debug]
1689+
```
1690+
1691+
**Examples**
1692+
1693+
```bash
1694+
container k8s list
1695+
container k8s ls
1696+
```
1697+
1698+
### `container k8s load-image`
1699+
1700+
Exports an image from the local `container` image store and imports it into the cluster's containerd (in the `k8s.io` namespace) so that Kubernetes can schedule pods that reference it.
1701+
1702+
**Usage**
1703+
1704+
```bash
1705+
container k8s load-image [--name <name>] [--platform <platform>] <image> [--debug]
1706+
```
1707+
1708+
**Arguments**
1709+
1710+
* `<image>`: Image reference to load (e.g. `my-app:latest`)
1711+
1712+
**Options**
1713+
1714+
* `--name <name>`: Cluster name (default: `k8s-dev`)
1715+
* `--platform <platform>`: Platform of the image variant to load from a multi-arch image (format: os/arch[/variant], default: `linux/<host-arch>`). Use this when the local store contains a multi-arch manifest list and you want to select a specific variant.
1716+
1717+
**Examples**
1718+
1719+
```bash
1720+
# load an image into the default cluster
1721+
container k8s load-image my-app:latest
1722+
1723+
# load an image into a named cluster
1724+
container k8s load-image --name my-cluster my-app:latest
1725+
1726+
# load the amd64 variant of a multi-arch image
1727+
container k8s load-image --platform linux/amd64 my-app:latest
1728+
```
1729+
1730+
### `container k8s write-config`
1731+
1732+
Fetches the current kubeconfig from a running cluster and merges its context into a kubeconfig file. Use this to refresh credentials after a cluster restart or to write to an alternate config file.
1733+
1734+
**Usage**
1735+
1736+
```bash
1737+
container k8s write-config [--name <name>] [--kubeconfig <path>] [--debug]
1738+
```
1739+
1740+
**Options**
1741+
1742+
* `--name <name>`: Cluster name (default: `k8s-dev`)
1743+
* `--kubeconfig <path>`: Path to the kubeconfig file to write or append to (default: `~/.kube/config`)
1744+
1745+
**Examples**
1746+
1747+
```bash
1748+
# refresh credentials for the default cluster into ~/.kube/config
1749+
container k8s write-config
1750+
1751+
# write the context for a named cluster to an alternate kubeconfig file
1752+
container k8s write-config --name my-cluster --kubeconfig ~/.kube/my-cluster.kubeconfig
1753+
```

0 commit comments

Comments
 (0)