kubernetes

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2025 License: MPL-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DevPodCreatedLabel      = "devpod.sh/created"
	DevPodWorkspaceLabel    = "devpod.sh/workspace"
	DevPodWorkspaceUIDLabel = "devpod.sh/workspace-uid"

	DevPodInfoAnnotation                   = "devpod.sh/info"
	DevPodLastAppliedAnnotation            = "devpod.sh/last-applied-configuration"
	ClusterAutoscalerSaveToEvictAnnotation = "cluster-autoscaler.kubernetes.io/safe-to-evict"
)
View Source
const DaemonConfigKey = "daemon_config"
View Source
const DevContainerName = "devpod"
View Source
const InitContainerName = "devpod-init"
View Source
const OfficialDockerRegistry = "https://index.docker.io/v1/"

Variables

View Source
var ExtraDevPodLabels = map[string]string{
	DevPodCreatedLabel: "true",
}

Functions

func DecodeAuthTokenFromPullSecret

func DecodeAuthTokenFromPullSecret(secret *k8sv1.Secret, host string) (string, error)

func GetRegistryFromImageName

func GetRegistryFromImageName(imageName string) (string, error)

GetRegistryFromImageName retrieves the registry name from an imageName

func IsCritical

func IsCritical(status *corev1.ContainerStatus) bool

func IsReady

func IsReady(status *corev1.ContainerStatus) bool

func IsRunning

func IsRunning(status *corev1.ContainerStatus) bool

func IsStarted

func IsStarted(status *corev1.ContainerStatus) bool

func IsTerminated

func IsTerminated(status *corev1.ContainerStatus) bool

func IsWaiting

func IsWaiting(status *corev1.ContainerStatus) bool

func NewKubernetesDriver

func NewKubernetesDriver(workspaceInfo *provider2.AgentWorkspaceInfo, log log.Logger) (driver.ReprovisioningDriver, error)

NewKubernetesDriver constructs a struct capable of provisioning a workspace and it's resources using kubernetes

func PreparePullSecretData

func PreparePullSecretData(registryURL, authToken, email string) (string, error)

func Succeeded

func Succeeded(status *corev1.ContainerStatus) bool

Types

type Client

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

func NewClient

func NewClient(kubeConfig, kubeContext string) (*Client, string, error)

NewClient constructs a struct wrapping the kubernetes client that is used by the kubernetes driver

func (*Client) Client

func (c *Client) Client() *kubernetes.Clientset

func (*Client) Config

func (c *Client) Config() *rest.Config

func (*Client) Exec

func (c *Client) Exec(ctx context.Context, options *ExecStreamOptions) error

Exec executes a kubectl exec with given transport round tripper and upgrader

func (*Client) FullLogs

func (c *Client) FullLogs(ctx context.Context, namespace, pod, container string) ([]byte, error)

func (*Client) Logs

func (c *Client) Logs(ctx context.Context, namespace, pod, container string, follow bool) (io.ReadCloser, error)

type DevContainerInfo

type DevContainerInfo struct {
	WorkspaceID string
	Options     *driver.RunOptions
}

type DockerConfig

type DockerConfig map[string]DockerConfigEntry

DockerConfig represents the config file used by the docker CLI. This config that represents the credentials that should be used when pulling images from specific image repositories.

type DockerConfigEntry

type DockerConfigEntry struct {
	Auth  string `json:"auth"`
	Email string `json:"email"`
}

DockerConfigEntry holds the user information that grant the access to docker registry

type DockerConfigJSON

type DockerConfigJSON struct {
	Auths DockerConfig `json:"auths"`
}

DockerConfigJSON represents a local docker auth config file for pulling images.

type ExecStreamOptions

type ExecStreamOptions struct {
	Stdin     io.Reader
	Stdout    io.Writer
	Stderr    io.Writer
	Pod       string
	Namespace string
	Container string
	Command   []string
}

type KubernetesDriver

type KubernetesDriver struct {
	Log log.Logger
	// contains filtered or unexported fields
}

func (*KubernetesDriver) CanReprovision

func (k *KubernetesDriver) CanReprovision() bool

func (*KubernetesDriver) CommandDevContainer

func (k *KubernetesDriver) CommandDevContainer(ctx context.Context, workspaceId, user, command string, stdin io.Reader, stdout io.Writer, stderr io.Writer) error

func (*KubernetesDriver) DeleteDaemonConfigSecret

func (k *KubernetesDriver) DeleteDaemonConfigSecret(
	ctx context.Context,
	secretName string) error

func (*KubernetesDriver) DeleteDevContainer

func (k *KubernetesDriver) DeleteDevContainer(ctx context.Context, workspaceId string) error

func (*KubernetesDriver) DeleteSecret

func (k *KubernetesDriver) DeleteSecret(
	ctx context.Context,
	secretName string) error

func (*KubernetesDriver) EnsureDaemonConfigSecret

func (k *KubernetesDriver) EnsureDaemonConfigSecret(
	ctx context.Context,
	secretName string,
	data string,
) error

func (*KubernetesDriver) EnsurePullSecret

func (k *KubernetesDriver) EnsurePullSecret(
	ctx context.Context,
	pullSecretName string,
	dockerImage string,
) (bool, error)

func (*KubernetesDriver) FindDevContainer

func (k *KubernetesDriver) FindDevContainer(ctx context.Context, workspaceId string) (*config.ContainerDetails, error)

func (*KubernetesDriver) GetDevContainerLogs

func (k *KubernetesDriver) GetDevContainerLogs(ctx context.Context, workspaceID string, stdout io.Writer, stderr io.Writer) error

func (*KubernetesDriver) ReadSecretContents

func (k *KubernetesDriver) ReadSecretContents(
	ctx context.Context,
	pullSecretName string,
	host string,
) (string, error)

func (*KubernetesDriver) RunDevContainer

func (k *KubernetesDriver) RunDevContainer(
	ctx context.Context,
	workspaceId string,
	options *driver.RunOptions,
) error

func (*KubernetesDriver) StartDevContainer

func (k *KubernetesDriver) StartDevContainer(ctx context.Context, workspaceId string) error

func (*KubernetesDriver) StopDevContainer

func (k *KubernetesDriver) StopDevContainer(ctx context.Context, workspaceId string) error

func (*KubernetesDriver) TargetArchitecture

func (k *KubernetesDriver) TargetArchitecture(ctx context.Context, workspaceId string) (string, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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