Documentation
¶
Overview ¶
Package k8s provides functionalities to interact with the Kubernetes API server
Index ¶
- Constants
- func FetchBastionIpAddress(clusterName, namespace, kubeConfigPath string) (string, error)
- func FetchWorkloadConfig(clusterName, clusterNamespace, mgmtKubeConfigPath string) (string, error)
- func GetNodeAddresses(ctx context.Context, kubeconfigPath string, names, labels []string) ([]string, error)
- func GetSecretData(ctx context.Context, client kubernetes.Interface, namespace string, ...) (map[string][]byte, error)
- func NewPortForwarder(kubeconfigPath, portForwardNS, portForwardPodName string, ...) (*portforward.PortForwarder, error)
- type Client
- type Config
- type Container
- type ContainerLogsImpl
- type ExecOptions
- type Executor
- type KubeConfig
- type ObjectWriter
- type ResultWriter
- type SearchParams
- type SearchResult
Constants ¶
const BaseDirname = "kubecapture"
const (
LegacyGroupName = "core"
)
Variables ¶
This section is empty.
Functions ¶
func FetchBastionIpAddress ¶ added in v0.3.0
func FetchWorkloadConfig ¶ added in v0.3.0
FetchWorkloadConfig...
func GetNodeAddresses ¶ added in v0.3.0
func GetSecretData ¶ added in v0.4.2
func NewPortForwarder ¶ added in v0.4.2
func NewPortForwarder(kubeconfigPath, portForwardNS, portForwardPodName string, localPort, targetPort int, stopCh <-chan struct{}, readyCh chan struct{}) (*portforward.PortForwarder, error)
Types ¶
type Client ¶ added in v0.2.0
type Client struct {
Client dynamic.Interface
Typed kubernetesclient.Interface
Disco discovery.DiscoveryInterface
CoreRest rest.Interface
Mapper meta.RESTMapper
JsonPrinter printers.JSONPrinter
RestConfig rest.Config
}
Client prepares and exposes a core, dynamic, discovery, and Rest clients
func New ¶ added in v0.2.0
New returns a *Client built with the kubecontext file path and an optional (at most one) K8s CLI context name.
func NewFromRestConfig ¶ added in v0.4.2
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
func LoadKubeCfg ¶ added in v0.3.0
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 ExecOptions ¶ added in v0.4.1
type Executor ¶ added in v0.4.1
type Executor struct {
Executor remotecommand.Executor
}
Executor is a struct that facilitates the execution of commands in Kubernetes pods. It uses the SPDYExecutor to stream command
func NewExecutor ¶ added in v0.4.1
func NewExecutor(kubeconfig string, clusterCtxName string, opts ExecOptions) (*Executor, error)
func (*Executor) ExecCommand ¶ added in v0.4.1
func (k8sc *Executor) ExecCommand(ctx context.Context, outputFilePath string, execOptions ExecOptions) error
ExecCommand executes a command inside a specified Kubernetes pod using the SPDYExecutor.
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, outputFormat, outputMode 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