Files
container/Sources/Plugins/Cluster/ClusterCommand.swift
T
2026-10-23 13:41:00 -07:00

60 lines
2.6 KiB
Swift

//===----------------------------------------------------------------------===//
// Copyright © 2026 Apple Inc. and the container project authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//===----------------------------------------------------------------------===//
import ArgumentParser
import ContainerCluster
import ContainerVersion
public struct ClusterCommand: AsyncParsableCommand {
public static let configuration = CommandConfiguration(
commandName: "cluster",
abstract: "Manage local Kubernetes development clusters (EXPERIMENTAL)",
discussion: """
EXAMPLES:
Create a cluster by name and list clusters:
$ container cluster create --name my-cluster
$ container cluster list
Switch between clusters:
$ container cluster create --name second-cluster
$ kubectl config use-context my-cluster
Write the cluster context to an alternate configuration file:
$ container cluster write-config --name my-cluster --kubeconfig ~/.kube/my-cluster.kubeconfig
$ KUBECONFIG=~/.kube/my-cluster.kubeconfig kubectl cluster-info
Load a local image into the cluster and run it:
$ container image pull docker.io/library/hello-world:latest
$ container image tag docker.io/library/hello-world:latest registry.example.com/my-hello-world:latest
$ container cluster load-image --name my-cluster registry.example.com/my-hello-world:latest
$ kubectl run hello-job --image=registry.example.com/my-hello-world:latest --image-pull-policy=Never --restart=Never --attach --rm -i
Stop and delete the cluster:
$ container cluster delete --name my-cluster
""",
version: ReleaseVersion.singleLine(appName: "cluster"),
subcommands: [
ClusterCreate.self,
ClusterDelete.self,
ClusterList.self,
ClusterLoadImage.self,
ClusterWriteConfig.self,
]
)
public init() {}
}