k8s

package
v0.3.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 2, 2026 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StreamLogs

func StreamLogs(ctx context.Context, client *Client, appName, namespace string, opts deploy.LogOpts) (io.ReadCloser, error)

StreamLogs returns a ReadCloser streaming logs from the app's pods.

func WaitForRollout

func WaitForRollout(ctx context.Context, client *Client, name, namespace string, timeout time.Duration) error

WaitForRollout polls a Deployment until all replicas are ready or the context is cancelled.

Types

type Client

type Client struct {
	Typed     kubernetes.Interface
	Dynamic   dynamic.Interface
	Config    *rest.Config
	Namespace string
}

Client wraps Kubernetes clientsets for typed and dynamic operations.

func NewClient

func NewClient(cfg ClientConfig) (*Client, error)

NewClient creates a Kubernetes client using the following resolution order: 1. Explicit kubeconfig path 2. KUBECONFIG environment variable 3. ~/.kube/config 4. In-cluster config

type ClientConfig

type ClientConfig struct {
	Kubeconfig string
	Context    string
	Namespace  string
}

ClientConfig holds options for creating a Kubernetes client.

type ContainerStatus

type ContainerStatus struct {
	Name         string `json:"name"`
	Ready        bool   `json:"ready"`
	RestartCount int32  `json:"restartCount"`
	State        string `json:"state"`
	Reason       string `json:"reason,omitempty"`
	Message      string `json:"message,omitempty"`
}

ContainerStatus describes the status of a container within a pod.

type Deployer

type Deployer struct {
	// contains filtered or unexported fields
}

Deployer handles applying and deleting Kubernetes resources.

func NewDeployer

func NewDeployer(client *Client) *Deployer

NewDeployer creates a new Deployer.

func (*Deployer) Apply

func (d *Deployer) Apply(ctx context.Context, artifacts *deploy.DeployArtifacts, opts deploy.ApplyOpts) (*deploy.DeployResult, error)

Apply performs server-side apply for all objects in the artifacts.

func (*Deployer) Delete

func (d *Deployer) Delete(ctx context.Context, appName, namespace string) error

Delete removes all resources matching the app label.

func (*Deployer) Diff

func (d *Deployer) Diff(ctx context.Context, artifacts *deploy.DeployArtifacts) (string, error)

Diff compares artifacts against live state and returns a human-readable diff.

type K8sDeployTarget

type K8sDeployTarget struct {
	// contains filtered or unexported fields
}

K8sDeployTarget implements deploy.DeployTarget for Kubernetes.

func NewDeployTarget

func NewDeployTarget() *K8sDeployTarget

NewDeployTarget creates a K8sDeployTarget. If client is nil, one will be created lazily from default kubeconfig on first operation.

func NewDeployTargetWithClient

func NewDeployTargetWithClient(client *Client) *K8sDeployTarget

NewDeployTargetWithClient creates a K8sDeployTarget with a pre-configured client.

func (*K8sDeployTarget) Apply

func (*K8sDeployTarget) Destroy

func (t *K8sDeployTarget) Destroy(ctx context.Context, appName, namespace string) error

func (*K8sDeployTarget) Diff

func (t *K8sDeployTarget) Diff(ctx context.Context, artifacts *deploy.DeployArtifacts) (string, error)

func (*K8sDeployTarget) Generate

func (*K8sDeployTarget) Logs

func (t *K8sDeployTarget) Logs(ctx context.Context, appName, namespace string, opts deploy.LogOpts) (io.ReadCloser, error)

func (*K8sDeployTarget) Name

func (t *K8sDeployTarget) Name() string

func (*K8sDeployTarget) Status

func (t *K8sDeployTarget) Status(ctx context.Context, appName, namespace string) (*deploy.DeployStatus, error)

type ManifestSet

type ManifestSet struct {
	Objects []*unstructured.Unstructured
}

ManifestSet is an ordered collection of Kubernetes objects.

func Build

func Build(req *deploy.DeployRequest) (*ManifestSet, error)

Build produces a ManifestSet from a DeployRequest.

func (*ManifestSet) Add

func (m *ManifestSet) Add(obj *unstructured.Unstructured)

Add appends an object to the manifest set.

func (*ManifestSet) AddRuntime

func (m *ManifestSet) AddRuntime(obj runtime.Object) error

AddRuntime converts a typed k8s object to unstructured and adds it.

func (*ManifestSet) Sort

func (m *ManifestSet) Sort()

Sort orders objects by the canonical resource ordering.

func (*ManifestSet) WriteJSON

func (m *ManifestSet) WriteJSON(path string) error

WriteJSON writes all objects as a JSON array to the given path.

func (*ManifestSet) WriteYAML

func (m *ManifestSet) WriteYAML(dir string, singleFile bool) error

WriteYAML writes all objects as YAML to the given directory. If singleFile is true, writes a multi-document YAML to manifests.yaml. Otherwise writes each object to a separate file named by kind-name.yaml.

type PodStatus

type PodStatus struct {
	Name       string            `json:"name"`
	Phase      string            `json:"phase"`
	Ready      bool              `json:"ready"`
	Restarts   int32             `json:"restarts"`
	Age        time.Duration     `json:"age"`
	Containers []ContainerStatus `json:"containers,omitempty"`
}

PodStatus describes the status of a single pod.

type RuntimeInfo

type RuntimeInfo struct {
	Runtime     imageloader.Runtime
	ContextName string
	ClusterName string // extracted from context (e.g. "mycluster" from "kind-mycluster")
}

RuntimeInfo holds detected cluster runtime information.

func DetectRuntime

func DetectRuntime(kubeconfigPath, contextOverride string) (*RuntimeInfo, error)

DetectRuntime determines the cluster runtime from the kubeconfig context name.

type StatusResult

type StatusResult struct {
	AppName   string      `json:"appName"`
	Namespace string      `json:"namespace"`
	Phase     string      `json:"phase"`
	Ready     int         `json:"ready"`
	Desired   int         `json:"desired"`
	Pods      []PodStatus `json:"pods,omitempty"`
	Message   string      `json:"message,omitempty"`
	UpdatedAt time.Time   `json:"updatedAt"`
}

StatusResult describes the overall status of a deployed application.

func GetStatus

func GetStatus(ctx context.Context, client *Client, appName, namespace string) (*StatusResult, error)

GetStatus returns the current deployment status for an app.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL