kubernetes

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2025 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Overview

Package kubernetes provides a client for the Kubernetes runtime including creating, starting, stopping, and retrieving container information.

Index

Constants

View Source
const RuntimeName = "kubernetes"

RuntimeName is the name identifier for the Kubernetes runtime

View Source
const (
	// UnknownStatus represents an unknown container status
	UnknownStatus = "unknown"
)

Constants for container status

Variables

This section is empty.

Functions

func GetCurrentNamespace added in v0.3.2

func GetCurrentNamespace() string

GetCurrentNamespace attempts to determine the current Kubernetes namespace using multiple methods, falling back to "default" if none succeed.

func IsAvailable added in v0.2.12

func IsAvailable() bool

IsAvailable checks if kubernetes is available

Types

type Client

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

Client implements the Deployer interface for container operations

func NewClient

func NewClient(_ context.Context) (*Client, error)

NewClient creates a new container client

func NewClientWithConfig added in v0.2.11

func NewClientWithConfig(clientset kubernetes.Interface, config *rest.Config) *Client

NewClientWithConfig creates a new container client with a provided config This is primarily used for testing with fake clients

func NewClientWithConfigAndPlatformDetector added in v0.2.11

func NewClientWithConfigAndPlatformDetector(
	clientset kubernetes.Interface,
	config *rest.Config,
	platformDetector PlatformDetector,
) *Client

NewClientWithConfigAndPlatformDetector creates a new container client with a provided config and platform detector This is primarily used for testing with fake clients and mock platform detectors

func (*Client) AttachToWorkload added in v0.0.37

func (c *Client) AttachToWorkload(ctx context.Context, workloadName string) (io.WriteCloser, io.ReadCloser, error)

AttachToWorkload implements runtime.Runtime.

func (*Client) DeployWorkload added in v0.0.37

func (c *Client) DeployWorkload(ctx context.Context,
	image string,
	containerName string,
	command []string,
	envVars map[string]string,
	containerLabels map[string]string,
	_ *permissions.Profile,
	transportType string,
	options *runtime.DeployWorkloadOptions,
	_ bool,
) (int, error)

DeployWorkload implements runtime.Runtime.

func (*Client) GetWorkloadInfo added in v0.0.37

func (c *Client) GetWorkloadInfo(ctx context.Context, workloadName string) (runtime.ContainerInfo, error)

GetWorkloadInfo implements runtime.Runtime.

func (*Client) GetWorkloadLogs added in v0.0.37

func (c *Client) GetWorkloadLogs(ctx context.Context, workloadName string, follow bool) (string, error)

GetWorkloadLogs implements runtime.Runtime.

func (*Client) IsRunning added in v0.1.1

func (c *Client) IsRunning(ctx context.Context) error

IsRunning checks the health of the container runtime. This is used to verify that the runtime is operational and can manage workloads.

func (*Client) IsWorkloadRunning added in v0.0.37

func (c *Client) IsWorkloadRunning(ctx context.Context, workloadName string) (bool, error)

IsWorkloadRunning implements runtime.Runtime.

func (*Client) ListWorkloads added in v0.0.37

func (c *Client) ListWorkloads(ctx context.Context) ([]runtime.ContainerInfo, error)

ListWorkloads implements runtime.Runtime.

func (*Client) RemoveWorkload added in v0.0.37

func (c *Client) RemoveWorkload(ctx context.Context, workloadName string) error

RemoveWorkload implements runtime.Runtime.

func (*Client) StopWorkload added in v0.0.37

func (*Client) StopWorkload(_ context.Context, _ string) error

StopWorkload implements runtime.Runtime.

type ConfigMapReader added in v0.3.0

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

ConfigMapReader implements RunConfigMapReader using real Kubernetes API

func NewConfigMapReader added in v0.3.0

func NewConfigMapReader() (*ConfigMapReader, error)

NewConfigMapReader creates a new ConfigMapReader using in-cluster configuration This is the standard way to create a reader in production Note: This function is not unit tested as it requires a real Kubernetes cluster. The business logic is tested via NewConfigMapReaderWithClient with mock clients.

func NewConfigMapReaderWithClient added in v0.3.0

func NewConfigMapReaderWithClient(clientset kubernetes.Interface) *ConfigMapReader

NewConfigMapReaderWithClient creates a new ConfigMapReader with the provided clientset This is useful for testing with a mock clientset

func (*ConfigMapReader) GetRunConfigMap added in v0.3.0

func (c *ConfigMapReader) GetRunConfigMap(ctx context.Context, configMapRef string) (string, error)

GetRunConfigMap retrieves the runconfig.json from a ConfigMap

type DefaultPlatformDetector added in v0.2.8

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

DefaultPlatformDetector implements PlatformDetector using the existing OpenShift detection logic

func (*DefaultPlatformDetector) DetectPlatform added in v0.2.8

func (d *DefaultPlatformDetector) DetectPlatform(config *rest.Config) (Platform, error)

DetectPlatform implements the PlatformDetector interface

type Platform added in v0.2.8

type Platform int

Platform represents the Kubernetes platform type

const (
	// PlatformKubernetes represents standard Kubernetes
	PlatformKubernetes Platform = iota
	// PlatformOpenShift represents OpenShift
	PlatformOpenShift
)

func (Platform) String added in v0.2.8

func (p Platform) String() string

String returns the string representation of the Platform

type PlatformDetector added in v0.2.8

type PlatformDetector interface {
	DetectPlatform(config *rest.Config) (Platform, error)
}

PlatformDetector defines the interface for detecting the Kubernetes platform type

func NewDefaultPlatformDetector added in v0.2.8

func NewDefaultPlatformDetector() PlatformDetector

NewDefaultPlatformDetector creates a new DefaultPlatformDetector

type RunConfigMapReader added in v0.3.0

type RunConfigMapReader interface {
	// GetRunConfigMap retrieves the runconfig.json from a ConfigMap
	// configMapRef should be in the format "namespace/configmap-name"
	// Returns the runconfig.json content as a string
	GetRunConfigMap(ctx context.Context, configMapRef string) (string, error)
}

RunConfigMapReader defines the interface for reading RunConfig from ConfigMaps This interface allows for easy mocking in tests

type SecurityContextBuilder added in v0.2.14

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

SecurityContextBuilder provides platform-aware security context configuration

func NewSecurityContextBuilder added in v0.2.14

func NewSecurityContextBuilder(platform Platform) *SecurityContextBuilder

NewSecurityContextBuilder creates a new SecurityContextBuilder for the given platform

func (*SecurityContextBuilder) BuildContainerSecurityContext added in v0.2.14

func (b *SecurityContextBuilder) BuildContainerSecurityContext() *corev1.SecurityContext

BuildContainerSecurityContext creates a platform-appropriate container security context

func (*SecurityContextBuilder) BuildContainerSecurityContextApplyConfiguration added in v0.2.14

func (b *SecurityContextBuilder) BuildContainerSecurityContextApplyConfiguration() *corev1apply.SecurityContextApplyConfiguration

BuildContainerSecurityContextApplyConfiguration creates a platform-appropriate container security context using the ApplyConfiguration types used by the client

func (*SecurityContextBuilder) BuildPodSecurityContext added in v0.2.14

func (b *SecurityContextBuilder) BuildPodSecurityContext() *corev1.PodSecurityContext

BuildPodSecurityContext creates a platform-appropriate pod security context

func (*SecurityContextBuilder) BuildPodSecurityContextApplyConfiguration added in v0.2.14

func (b *SecurityContextBuilder) BuildPodSecurityContextApplyConfiguration() *corev1apply.PodSecurityContextApplyConfiguration

BuildPodSecurityContextApplyConfiguration creates a platform-appropriate pod security context using the ApplyConfiguration types used by the client

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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