k8s

package
v0.3.10 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2023 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Overview

Package k8s provides functionalities to interact with the Kubernetes API server

Index

Constants

View Source
const BaseDirname = "kubecapture"
View Source
const (
	LegacyGroupName = "core"
)

Variables

This section is empty.

Functions

func FetchBastionIpAddress added in v0.3.0

func FetchBastionIpAddress(clusterName, namespace, kubeConfigPath string) (string, error)

func FetchWorkloadConfig added in v0.3.0

func FetchWorkloadConfig(clusterName, clusterNamespace, mgmtKubeConfigPath string) (string, error)

FetchWorkloadConfig...

func GetNodeAddresses added in v0.3.0

func GetNodeAddresses(ctx context.Context, kubeconfigPath string, names, labels []string) ([]string, error)

Types

type Client added in v0.2.0

type Client struct {
	Client      dynamic.Interface
	Disco       discovery.DiscoveryInterface
	CoreRest    rest.Interface
	Mapper      meta.RESTMapper
	JsonPrinter printers.JSONPrinter
}

Client prepares and exposes a dynamic, discovery, and Rest clients

func New added in v0.2.0

func New(kubeconfig string, clusterContextOptions ...string) (*Client, error)

New returns a *Client built with the kubecontext file path and an optional (at most one) K8s CLI context name.

func (*Client) Search added in v0.2.1

func (k8sc *Client) Search(ctx context.Context, params SearchParams) ([]SearchResult, error)

type Config added in v0.3.0

type Config interface {
	GetClusterName() (string, error)
	GetCurrentContext() string
}

func LoadKubeCfg added in v0.3.0

func LoadKubeCfg(kubeConfigPath string) (Config, error)

type Container added in v0.3.0

type Container interface {
	Fetch(context.Context, rest.Interface) (io.ReadCloser, error)
	Write(io.ReadCloser, string) error
}

func GetContainers added in v0.3.0

func GetContainers(podItem unstructured.Unstructured) ([]Container, error)

type ContainerLogsImpl added in v0.3.0

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

func NewContainerLogger added in v0.3.0

func NewContainerLogger(namespace, podName string, container corev1.Container) ContainerLogsImpl

func (ContainerLogsImpl) Fetch added in v0.3.0

func (c ContainerLogsImpl) Fetch(ctx context.Context, restApi rest.Interface) (io.ReadCloser, error)

func (ContainerLogsImpl) Write added in v0.3.0

func (c ContainerLogsImpl) Write(reader io.ReadCloser, rootDir string) error

type KubeConfig added in v0.3.0

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

func (*KubeConfig) GetClusterName added in v0.3.0

func (kcfg *KubeConfig) GetClusterName() (string, error)

func (*KubeConfig) GetCurrentContext added in v0.3.0

func (kcfg *KubeConfig) GetCurrentContext() string

type ObjectWriter added in v0.3.0

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

func (ObjectWriter) Write added in v0.3.0

func (w ObjectWriter) Write(result SearchResult) (string, error)

type ResultWriter added in v0.3.0

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

func NewResultWriter added in v0.3.0

func NewResultWriter(workdir, what string, restApi rest.Interface) (*ResultWriter, error)

func (*ResultWriter) GetResultDir added in v0.3.0

func (w *ResultWriter) GetResultDir() string

func (*ResultWriter) Write added in v0.3.0

func (w *ResultWriter) Write(ctx context.Context, searchResults []SearchResult) error

type SearchParams added in v0.3.0

type SearchParams struct {
	Groups     []string
	Categories []string
	Kinds      []string
	Namespaces []string
	Versions   []string
	Names      []string
	Labels     []string
	Containers []string
}

func NewSearchParams added in v0.3.0

func NewSearchParams(p *starlarkstruct.Struct) SearchParams

TODO: Change this to accept a string dictionary instead

func (SearchParams) ContainsContainer added in v0.3.0

func (sp SearchParams) ContainsContainer(container string) bool

func (SearchParams) ContainsGroup added in v0.3.0

func (sp SearchParams) ContainsGroup(group string) bool

func (SearchParams) ContainsKind added in v0.3.0

func (sp SearchParams) ContainsKind(kind string) bool

func (SearchParams) ContainsName added in v0.3.0

func (sp SearchParams) ContainsName(name string) bool

func (SearchParams) ContainsVersion added in v0.3.0

func (sp SearchParams) ContainsVersion(version string) bool

type SearchResult added in v0.2.2

type SearchResult struct {
	ListKind             string
	ResourceName         string
	ResourceKind         string
	GroupVersionResource schema.GroupVersionResource
	List                 *unstructured.UnstructuredList
	Namespaced           bool
	Namespace            string
}

SearchResult is the object representation of the kubernetes objects returned by querying the API server

func (SearchResult) ToStarlarkValue added in v0.3.0

func (sr SearchResult) ToStarlarkValue() *starlarkstruct.Struct

ToStarlarkValue converts the SearchResult object to a starlark dictionary

Jump to

Keyboard shortcuts

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