Documentation
¶
Overview ¶
Package runtime defines the interface of a cluster operation and providers a register method.
Index ¶
- Variables
- func ApplyComponentPatches(component *internalversion.Component, ...)
- func ExpandVolumesHostPaths(volumes []internalversion.Volume) ([]internalversion.Volume, error)
- func FormatExec(ctx context.Context, name string, args ...string) string
- func GetComponentPatches(conf *internalversion.KwokctlConfiguration, componentName string) internalversion.ComponentPatches
- func GetLogVolumes(ctx context.Context) []internalversion.Volume
- func GetUsedPorts(ctx context.Context) (rets sets.Sets[uint32])
- func ListClusters(ctx context.Context) ([]string, error)
- type BuildRuntime
- type Cluster
- func (c *Cluster) AppendToFile(name string, content []byte) error
- func (c *Cluster) AuditLogs(ctx context.Context, out io.Writer) error
- func (c *Cluster) AuditLogsFollow(ctx context.Context, out io.Writer) error
- func (c *Cluster) Config(ctx context.Context) (*internalversion.KwokctlConfiguration, error)
- func (c *Cluster) CopyFile(oldpath, newpath string) error
- func (c *Cluster) CopySchedulerConfig(oldpath, newpath, kubeconfig string) error
- func (c *Cluster) CreateFile(name string) error
- func (c *Cluster) DownloadWithCache(ctx context.Context, cacheDir, src, dest string, mode fs.FileMode, quiet bool) error
- func (c *Cluster) EnsureBinary(ctx context.Context, name, binary string) (string, error)
- func (c *Cluster) EnsureImage(ctx context.Context, command string, image string) error
- func (c *Cluster) Etcdctl(ctx context.Context, args ...string) error
- func (c *Cluster) Exec(ctx context.Context, name string, args ...string) error
- func (c *Cluster) ForeachComponents(ctx context.Context, reverse, order bool, ...) error
- func (c *Cluster) ForkExec(ctx context.Context, dir string, name string, args ...string) error
- func (c *Cluster) ForkExecIsRunning(ctx context.Context, dir string, name string) bool
- func (c *Cluster) ForkExecKill(ctx context.Context, dir string, name string) error
- func (c *Cluster) GeneratePki(pkiPath string, sans ...string) error
- func (c *Cluster) GetBinPath(name string) string
- func (c *Cluster) GetClientset(ctx context.Context) (client.Clientset, error)
- func (c *Cluster) GetComponent(ctx context.Context, name string) (internalversion.Component, error)
- func (c *Cluster) GetEtcdClient(ctx context.Context) (etcd.Client, error)
- func (c *Cluster) GetLogPath(name string) string
- func (c *Cluster) GetWorkdirPath(name string) string
- func (c *Cluster) InitCRDs(ctx context.Context) error
- func (c *Cluster) Install(ctx context.Context) error
- func (c *Cluster) IsDryRun() bool
- func (c *Cluster) Kubectl(ctx context.Context, args ...string) error
- func (c *Cluster) KubectlInCluster(ctx context.Context, args ...string) error
- func (c *Cluster) KubectlPath(ctx context.Context) (string, error)
- func (c *Cluster) ListComponents(ctx context.Context) ([]internalversion.Component, error)
- func (c *Cluster) Load(ctx context.Context) (*internalversion.KwokctlConfiguration, error)
- func (c *Cluster) MkdirAll(name string) error
- func (c *Cluster) Name() string
- func (c *Cluster) OpenFile(name string) (io.WriteCloser, error)
- func (c *Cluster) ParseVersionFromBinary(ctx context.Context, path string) (version.Version, error)
- func (c *Cluster) ParseVersionFromImage(ctx context.Context, runtime string, image string, command string) (version.Version, error)
- func (c *Cluster) Ready(ctx context.Context) (bool, error)
- func (c *Cluster) Remove(name string) error
- func (c *Cluster) RemoveAll(name string) error
- func (c *Cluster) RenameFile(oldpath, newpath string) error
- func (c *Cluster) Save(ctx context.Context) error
- func (c *Cluster) SetConfig(ctx context.Context, conf *internalversion.KwokctlConfiguration) error
- func (c *Cluster) SnapshotRestoreWithYAML(ctx context.Context, path string, conf SnapshotRestoreWithYAMLConfig) error
- func (c *Cluster) SnapshotSaveWithYAML(ctx context.Context, path string, conf SnapshotSaveWithYAMLConfig) error
- func (c *Cluster) Uninstall(ctx context.Context) error
- func (c *Cluster) WaitReady(ctx context.Context, timeout time.Duration) error
- func (c *Cluster) Workdir() string
- func (c *Cluster) WriteFile(name string, content []byte) error
- func (c *Cluster) WriteFileWithMode(name string, content []byte, mode os.FileMode) error
- func (c *Cluster) WriteToPath(ctx context.Context, path string, commands []string) error
- type ComponentStatus
- type Registry
- type Runtime
- type SnapshotRestoreWithYAMLConfig
- type SnapshotSaveWithYAMLConfig
Constants ¶
This section is empty.
Variables ¶
var ( ConfigName = consts.ConfigName InHostKubeconfigName = "kubeconfig.yaml" InClusterKubeconfigName = "kubeconfig" EtcdDataDirName = "etcd" PkiName = "pki" ManifestsName = "manifests" Prometheus = "prometheus.yaml" KindName = "kind.yaml" AuditPolicyName = "audit.yaml" AuditLogName = "audit.log" SchedulerConfigName = "scheduler.yaml" ApiserverTracingConfig = "apiserver-tracing-config.yaml" )
The following functions are used to get the path of the cluster
var DefaultRegistry = NewRegistry()
DefaultRegistry is the default registry
var ( // ErrComponentNotFound is returned when a component is not found ErrComponentNotFound = fmt.Errorf("component not found") )
Functions ¶
func ApplyComponentPatches ¶ added in v0.5.0
func ApplyComponentPatches(component *internalversion.Component, patches []internalversion.ComponentPatches)
ApplyComponentPatches applies patches to a component.
func ExpandVolumesHostPaths ¶ added in v0.2.0
func ExpandVolumesHostPaths(volumes []internalversion.Volume) ([]internalversion.Volume, error)
ExpandVolumesHostPaths expands relative paths specified in volumes to absolute paths
func FormatExec ¶ added in v0.4.0
FormatExec prints the command to be executed to the output stream.
func GetComponentPatches ¶ added in v0.2.0
func GetComponentPatches(conf *internalversion.KwokctlConfiguration, componentName string) internalversion.ComponentPatches
GetComponentPatches returns the patches for a component.
func GetLogVolumes ¶ added in v0.2.0
func GetLogVolumes(ctx context.Context) []internalversion.Volume
GetLogVolumes returns volumes for Logs and ClusterLogs resource.
func GetUsedPorts ¶ added in v0.5.0
GetUsedPorts returns the list of ports used by the clusters in the directory
Types ¶
type BuildRuntime ¶
BuildRuntime is a function to build a runtime
type Cluster ¶
type Cluster struct {
// contains filtered or unexported fields
}
Cluster is the cluster
func (*Cluster) AppendToFile ¶ added in v0.4.0
AppendToFile appends content to a file.
func (*Cluster) AuditLogsFollow ¶
AuditLogsFollow follows the audit logs of the cluster.
func (*Cluster) Config ¶
func (c *Cluster) Config(ctx context.Context) (*internalversion.KwokctlConfiguration, error)
Config returns the cluster config
func (*Cluster) CopySchedulerConfig ¶ added in v0.4.0
CopySchedulerConfig copies the scheduler configuration file to the given path.
func (*Cluster) CreateFile ¶ added in v0.4.0
CreateFile creates a file.
func (*Cluster) DownloadWithCache ¶ added in v0.4.0
func (c *Cluster) DownloadWithCache(ctx context.Context, cacheDir, src, dest string, mode fs.FileMode, quiet bool) error
DownloadWithCache downloads the src file to the dest file.
func (*Cluster) EnsureBinary ¶ added in v0.5.0
EnsureBinary ensures the binary exists.
func (*Cluster) EnsureImage ¶ added in v0.5.0
EnsureImage ensures the image exists.
func (*Cluster) ForeachComponents ¶ added in v0.4.0
func (c *Cluster) ForeachComponents(ctx context.Context, reverse, order bool, fun func(ctx context.Context, component internalversion.Component) error) error
ForeachComponents starts components.
func (*Cluster) ForkExec ¶ added in v0.4.0
ForkExec forks a new process and execs the given command. The process will be terminated when the context is canceled.
func (*Cluster) ForkExecIsRunning ¶ added in v0.4.0
ForkExecIsRunning checks if the process is running.
func (*Cluster) ForkExecKill ¶ added in v0.4.0
ForkExecKill kills the process if it is running.
func (*Cluster) GeneratePki ¶ added in v0.4.0
GeneratePki generates the pki for kwokctl
func (*Cluster) GetBinPath ¶ added in v0.1.0
GetBinPath returns the path to the given binary name.
func (*Cluster) GetClientset ¶ added in v0.4.0
GetClientset returns the clientset of the cluster.
func (*Cluster) GetComponent ¶ added in v0.1.0
GetComponent returns the component by name
func (*Cluster) GetEtcdClient ¶ added in v0.5.0
GetEtcdClient returns the etcd client of cluster
func (*Cluster) GetLogPath ¶ added in v0.1.0
GetLogPath returns the path of the given log name.
func (*Cluster) GetWorkdirPath ¶ added in v0.1.0
GetWorkdirPath returns the path to the file in the workdir.
func (*Cluster) KubectlInCluster ¶
KubectlInCluster runs kubectl in the cluster.
func (*Cluster) KubectlPath ¶ added in v0.6.0
func (*Cluster) ListComponents ¶ added in v0.5.0
ListComponents returns the list of components
func (*Cluster) Load ¶
func (c *Cluster) Load(ctx context.Context) (*internalversion.KwokctlConfiguration, error)
Load loads the cluster config
func (*Cluster) OpenFile ¶ added in v0.4.0
func (c *Cluster) OpenFile(name string) (io.WriteCloser, error)
OpenFile opens/creates a file for writing.
func (*Cluster) ParseVersionFromBinary ¶ added in v0.4.0
ParseVersionFromBinary parses the version from the given binary.
func (*Cluster) ParseVersionFromImage ¶ added in v0.4.0
func (c *Cluster) ParseVersionFromImage(ctx context.Context, runtime string, image string, command string) (version.Version, error)
ParseVersionFromImage parses the version from the image.
func (*Cluster) RenameFile ¶ added in v0.4.0
RenameFile renames a file.
func (*Cluster) SetConfig ¶ added in v0.1.0
func (c *Cluster) SetConfig(ctx context.Context, conf *internalversion.KwokctlConfiguration) error
SetConfig sets the cluster config
func (*Cluster) SnapshotRestoreWithYAML ¶ added in v0.2.0
func (c *Cluster) SnapshotRestoreWithYAML(ctx context.Context, path string, conf SnapshotRestoreWithYAMLConfig) error
SnapshotRestoreWithYAML restore the snapshot of cluster
func (*Cluster) SnapshotSaveWithYAML ¶ added in v0.2.0
func (c *Cluster) SnapshotSaveWithYAML(ctx context.Context, path string, conf SnapshotSaveWithYAMLConfig) error
SnapshotSaveWithYAML save the snapshot of cluster
func (*Cluster) WriteFileWithMode ¶ added in v0.4.0
WriteFileWithMode writes content to a file with the given mode.
type ComponentStatus ¶ added in v0.6.0
type ComponentStatus uint64
const ( ComponentStatusUnknown ComponentStatus = iota ComponentStatusStopped ComponentStatusRunning ComponentStatusReady )
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry is a registry of runtime
func (*Registry) Register ¶
func (r *Registry) Register(name string, buildRuntime BuildRuntime)
Register a runtime
type Runtime ¶
type Runtime interface { // Available checks whether the runtime is available. Available(ctx context.Context) error // SetConfig sets the config of cluster SetConfig(ctx context.Context, conf *internalversion.KwokctlConfiguration) error // Save the config of cluster Save(ctx context.Context) error // Config return the config of cluster Config(ctx context.Context) (*internalversion.KwokctlConfiguration, error) // Install the cluster Install(ctx context.Context) error // Uninstall the cluster Uninstall(ctx context.Context) error // Up start the cluster Up(ctx context.Context) error // Down stop the cluster Down(ctx context.Context) error // Start a cluster Start(ctx context.Context) error // Stop a cluster Stop(ctx context.Context) error // StartComponent start cluster component StartComponent(ctx context.Context, name string) error // StopComponent stop cluster component StopComponent(ctx context.Context, name string) error // GetComponent return the component if it exists GetComponent(ctx context.Context, name string) (internalversion.Component, error) // ListComponents list the components of cluster ListComponents(ctx context.Context) ([]internalversion.Component, error) // InspectComponent inspect the component InspectComponent(ctx context.Context, name string) (ComponentStatus, error) // Ready check the cluster is ready Ready(ctx context.Context) (bool, error) // WaitReady wait the cluster is ready WaitReady(ctx context.Context, timeout time.Duration) error // AddContext add the context of cluster to kubeconfig AddContext(ctx context.Context, kubeconfigPath string) error // RemoveContext remove the context of cluster from kubeconfig RemoveContext(ctx context.Context, kubeconfigPath string) error // Kubectl command Kubectl(ctx context.Context, args ...string) error // KubectlInCluster command in cluster KubectlInCluster(ctx context.Context, args ...string) error // EtcdctlInCluster command in cluster EtcdctlInCluster(ctx context.Context, args ...string) error // Logs logs of a component Logs(ctx context.Context, name string, out io.Writer) error // LogsFollow follow logs of a component with follow LogsFollow(ctx context.Context, name string, out io.Writer) error // CollectLogs will populate dir with cluster logs and other debug files CollectLogs(ctx context.Context, dir string) error // AuditLogs audit logs of apiserver AuditLogs(ctx context.Context, out io.Writer) error // AuditLogsFollow follow audit logs of apiserver AuditLogsFollow(ctx context.Context, out io.Writer) error // ListBinaries list binaries in the cluster ListBinaries(ctx context.Context) ([]string, error) // ListImages list images in the cluster ListImages(ctx context.Context) ([]string, error) // SnapshotSave save the snapshot of cluster SnapshotSave(ctx context.Context, path string) error // SnapshotRestore restore the snapshot of cluster SnapshotRestore(ctx context.Context, path string) error // SnapshotSaveWithYAML save the snapshot of cluster SnapshotSaveWithYAML(ctx context.Context, path string, conf SnapshotSaveWithYAMLConfig) error // SnapshotRestoreWithYAML restore the snapshot of cluster SnapshotRestoreWithYAML(ctx context.Context, path string, conf SnapshotRestoreWithYAMLConfig) error // GetWorkdirPath get the workdir path of cluster GetWorkdirPath(name string) string // InitCRDs init the crds of cluster InitCRDs(ctx context.Context) error // InitCRs init the crs of cluster InitCRs(ctx context.Context) error // IsDryRun returns true if the runtime is in dry-run mode IsDryRun() bool // GetClientset returns the clientset of cluster GetClientset(ctx context.Context) (client.Clientset, error) // GetEtcdClient returns the etcd client of cluster GetEtcdClient(ctx context.Context) (etcd.Client, error) }
Runtime is the interface for a runtime.
type SnapshotRestoreWithYAMLConfig ¶ added in v0.5.0
type SnapshotRestoreWithYAMLConfig struct {
Filters []string
}
type SnapshotSaveWithYAMLConfig ¶ added in v0.5.0
type SnapshotSaveWithYAMLConfig struct {
Filters []string
}
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
Package binary implements the runtime.Runtime interface using the binaries.
|
Package binary implements the runtime.Runtime interface using the binaries. |
Package compose implements the runtime.Runtime interface using the image.
|
Package compose implements the runtime.Runtime interface using the image. |
Package kind implements the runtime.Runtime interface using the kind.
|
Package kind implements the runtime.Runtime interface using the kind. |
config/kind/v1alpha4
Package v1alpha4 copy from https://github.com/kubernetes-sigs/kind/blob/master/pkg/apis/config/v1alpha4/types.go
|
Package v1alpha4 copy from https://github.com/kubernetes-sigs/kind/blob/master/pkg/apis/config/v1alpha4/types.go |
config/kubeadm/v1beta3
Package v1beta3 copy from https://github.com/kubernetes/kubernetes/blob/master/cmd/kubeadm/app/apis/kubeadm/v1beta3/types.go
|
Package v1beta3 copy from https://github.com/kubernetes/kubernetes/blob/master/cmd/kubeadm/app/apis/kubeadm/v1beta3/types.go |