Documentation
¶
Index ¶
- type Cluster
- func (c *Cluster) ApplyFile(ctx context.Context, path string) ([]byte, error)
- func (c *Cluster) ApplyFiles(ctx context.Context, paths ...string) ([]byte, error)
- func (c *Cluster) ApplyYAML(ctx context.Context, yaml []byte) ([]byte, error)
- func (c *Cluster) BuildAndPushImage(ctx context.Context, dockerfile string, clusterImage string) (PushedImage, string, error)
- func (c *Cluster) Cleanup(ctx context.Context) error
- func (c *Cluster) Create(ctx context.Context) error
- func (c *Cluster) DeleteYAML(ctx context.Context, yaml []byte) ([]byte, error)
- func (c *Cluster) Endpoints() map[string]string
- func (c *Cluster) Env() map[string]string
- func (c *Cluster) Kubeconfig(ctx context.Context) ([]byte, error)
- func (c *Cluster) KubeconfigPath() string
- func (c *Cluster) Kubectl(ctx context.Context, args ...string) ([]byte, error)
- func (c *Cluster) Logs(ctx context.Context) (logs.LogStreams, error)
- func (c *Cluster) Name() string
- func (c *Cluster) PushImage(ctx context.Context, localImage string, clusterImage string) (PushedImage, error)
- func (c *Cluster) RegistryAddress() string
- func (c *Cluster) RegistryDockerConfigJSON() ([]byte, error)
- func (c *Cluster) RegistryEnv() map[string]string
- func (c *Cluster) RegistryImage(image string) string
- func (c *Cluster) RegistryInternalAddress() string
- func (c *Cluster) SSHAddress() string
- func (c *Cluster) SetLabels(labels map[string]string)
- func (c *Cluster) SetNamePrefix(prefix string)
- func (c *Cluster) SetNetwork(name string)
- func (c *Cluster) Status(ctx context.Context) ([]byte, error)
- func (c *Cluster) WaitForRollouts(ctx context.Context) error
- func (c *Cluster) WriteKubeconfig(ctx context.Context, path string) (string, error)
- type Image
- type Option
- func WithDockerfileImage(dockerfile string, clusterImage string) Option
- func WithK3sArgs(args ...string) Option
- func WithKubeconfigPath(path string) Option
- func WithLocalImage(localImage string, clusterImage string) Option
- func WithManifest(path string) Option
- func WithNamespace(name string) Option
- func WithReadyTimeout(timeout time.Duration) Option
- func WithRegistry(hostPort string) Option
- func WithRegistryImage(image string, tag string) Option
- func WithRolloutTimeout(timeout time.Duration) Option
- func WithSSH(hostPort string, publicKeys ...string) Option
- func WithSSHImage(image string, tag string) Option
- func WithTag(tag string) Option
- type PushedImage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cluster ¶
type Cluster struct {
// contains filtered or unexported fields
}
Cluster is a Docker-backed Kubernetes quickstart. It runs k3s in a privileged container and applies user-provided YAML through kubectl inside the container.
func NewCluster ¶
NewCluster creates a k3s-backed Kubernetes cluster service.
func (*Cluster) ApplyFile ¶
ApplyFile reads a manifest file from the host and sends it to kubectl inside the k3s container.
func (*Cluster) ApplyFiles ¶
ApplyFiles reads host manifest files and applies them in order.
func (*Cluster) BuildAndPushImage ¶
func (c *Cluster) BuildAndPushImage(ctx context.Context, dockerfile string, clusterImage string) (PushedImage, string, error)
BuildAndPushImage builds a Dockerfile, pushes the result to the registry, and returns the cluster image reference manifests should use.
func (*Cluster) Cleanup ¶
Cleanup deletes registered manifests in reverse order and removes the k3s container.
func (*Cluster) Create ¶
Create starts the k3s container, waits for the Kubernetes API, applies registered manifests, and waits for rollouts.
func (*Cluster) DeleteYAML ¶
DeleteYAML sends YAML directly to kubectl delete inside the k3s container. Missing resources are ignored.
func (*Cluster) Kubeconfig ¶
Kubeconfig returns a host-usable kubeconfig for this cluster without writing it to disk.
func (*Cluster) KubeconfigPath ¶
KubeconfigPath returns the last path written by WriteKubeconfig, or the configured default path if WriteKubeconfig has not been called yet.
func (*Cluster) Kubectl ¶
Kubectl executes kubectl inside the k3s container and returns combined stdout and stderr.
func (*Cluster) PushImage ¶
func (c *Cluster) PushImage(ctx context.Context, localImage string, clusterImage string) (PushedImage, error)
PushImage tags a local image, pushes it to the host registry endpoint, and returns the cluster image reference manifests should use.
func (*Cluster) RegistryAddress ¶
RegistryAddress returns the host-reachable registry address.
func (*Cluster) RegistryDockerConfigJSON ¶
RegistryDockerConfigJSON returns a Docker config.json payload for the host-reachable registry. The default registry has no authentication, so the auth entry is intentionally empty.
func (*Cluster) RegistryEnv ¶
RegistryEnv returns environment variables useful for CLI commands that build, tag, push, or patch manifests with registry images.
func (*Cluster) RegistryImage ¶
RegistryImage returns the image reference Kubernetes should use for an image stored in the cluster registry.
func (*Cluster) RegistryInternalAddress ¶
RegistryInternalAddress returns the registry address reachable from the cluster's Docker network.
func (*Cluster) SSHAddress ¶
SSHAddress returns the local SSH address when WithSSH is enabled and the container has started.
func (*Cluster) SetNamePrefix ¶
func (*Cluster) SetNetwork ¶
func (*Cluster) WaitForRollouts ¶
WaitForRollouts waits for deployment, statefulset, and daemonset rollouts in the configured namespace.
type Image ¶
Image describes a container image that should be made available through the cluster registry.
type Option ¶
type Option func(*Cluster)
Option configures the Kubernetes cluster before the container is built.
func WithDockerfileImage ¶
WithDockerfileImage builds the Dockerfile and pushes the result into the cluster registry before manifests are applied.
func WithK3sArgs ¶
WithK3sArgs appends arguments to the k3s server command.
func WithKubeconfigPath ¶
WithKubeconfigPath sets the default path used by WriteKubeconfig. Nothing is written unless WriteKubeconfig is called.
func WithLocalImage ¶
WithLocalImage tags and pushes an existing local Docker image into the cluster registry before manifests are applied.
func WithManifest ¶
WithManifest registers a YAML file, directory, or URL to apply after the cluster is ready. Local paths are bind-mounted into the k3s container; URLs are passed directly to kubectl.
func WithNamespace ¶
WithNamespace creates and uses a namespace for manifest apply, delete, status, and rollout helpers.
func WithReadyTimeout ¶
WithReadyTimeout changes how long Create waits for the Kubernetes API.
func WithRegistry ¶
WithRegistry starts a local Docker registry beside the cluster. hostPort may be blank to let Docker assign a free host port.
func WithRegistryImage ¶
WithRegistryImage changes the local registry container image.
func WithRolloutTimeout ¶
WithRolloutTimeout changes how long Create waits for deployments, statefulsets, and daemonsets to finish rolling out after manifests are applied.
func WithSSH ¶
WithSSH starts a companion SSH/kubectl container configured against the k3s API. Public keys are written to root's authorized_keys inside that companion container. hostPort may be blank to let Docker assign a free port.
func WithSSHImage ¶
WithSSHImage changes the companion SSH/kubectl image. The image must have kubectl, sh, apk, and OpenSSH packages available or installable.
type PushedImage ¶
PushedImage describes an image pushed to the local registry. HostImage is the image reference used by the host Docker daemon. ClusterImage is the image reference Kubernetes manifests should use.