virtualkubelet

package
v0.0.0-...-9ed14a4 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2025 License: Apache-2.0 Imports: 46 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PodPhaseInitialize = "Initializing"
	PodPhaseCompleted  = "Completed"
)
View Source
const (
	DefaultCPUCapacity    = "100"
	DefaultMemoryCapacity = "3000G"
	DefaultPodCapacity    = "10000"
	DefaultGPUCapacity    = "0"
	DefaultFPGACapacity   = "0"
	DefaultListenPort     = 10250
	NamespaceKey          = "namespace"
	NameKey               = "name"
	CREATE                = 0
	DELETE                = 1

	DefaultProtocol        = "TCP"
	DefaultWstunnelCommand = "" /* 238-byte string literal not displayed */
)

Variables

View Source
var (
	KubeletVersion = "test"
)

Functions

func AddSessionContext

func AddSessionContext(req *http.Request, sessionContext string)

func CheckIfAnnotationExists

func CheckIfAnnotationExists(pod *v1.Pod, key string) bool

CheckIfAnnotationExists checks if a specific annotation (key) is available between the annotation of a pod

func GetResources

func GetResources(config Config) v1.ResourceList

func GetSessionContextMessage

func GetSessionContextMessage(sessionContext string) string

func LogRetrieval

func LogRetrieval(
	ctx context.Context,
	config Config,
	logsRequest types.LogStruct,
	clientHTTPTransport *http.Transport,
	sessionContext string,
) (io.ReadCloser, error)

LogRetrieval performs a REST call to the InterLink API when the user ask for a log retrieval. Compared to create/delete/status request, a way smaller struct is marshalled and sent. This struct only includes a minimum data set needed to identify the job/container to get the logs from. Returns the call response and/or the first encountered error

func NodeCondition

func NodeCondition(ready bool) []v1.NodeCondition
func NodeConditionWithInterlink(ready bool, interlinkStatus v1.ConditionStatus, interlinkReason, interlinkMessage string) []v1.NodeCondition
func PingInterLink(ctx context.Context, config Config) (bool, int, string, error)

PingInterLink pings the InterLink API and returns true if there's an answer. The second return value is given by the answer provided by the API. The third return value contains the response body from the ping call.

func PodPhase

func PodPhase(_ Provider, phase string, podIP string) (v1.PodStatus, error)

func RemoteExecution

func RemoteExecution(ctx context.Context, config Config, p *Provider, pod *v1.Pod, mode int8) error

RemoteExecution is called by the VK everytime a Pod is being registered or deleted to/from the VK. Depending on the mode (CREATE/DELETE), it performs different actions, making different REST calls. Note: for the CREATE mode, the function gets stuck up to 5 minutes waiting for every missing ConfigMap/Secret. If after 5m they are not still available, the function errors out

func SetDefaultResource

func SetDefaultResource(config *Config)

func TracerUpdate

func TracerUpdate(ctx *context.Context, name string, pod *v1.Pod)

Types

type Accelerator

type Accelerator struct {
	ResourceType string `yaml:"ResourceType"`
	Model        string `yaml:"Model"`
	Available    int    `yaml:"Available"`
}

type Config

type Config struct {
	InterlinkURL            string      `yaml:"InterlinkURL"`
	InterlinkPort           string      `yaml:"InterlinkPort"`
	KubernetesAPIAddr       string      `yaml:"KubernetesApiAddr"`
	KubernetesAPIPort       string      `yaml:"KubernetesApiPort"`
	KubernetesAPICaCrt      string      `yaml:"KubernetesApiCaCrt"`
	DisableProjectedVolumes bool        `yaml:"DisableProjectedVolumes"`
	JobScriptBuilderURL     string      `yaml:"JobScriptBuilderURL,omitempty"`
	VKConfigPath            string      `yaml:"VKConfigPath"`
	VKTokenFile             string      `yaml:"VKTokenFile"`
	ServiceAccount          string      `yaml:"ServiceAccount"`
	Namespace               string      `yaml:"Namespace"`
	PodIP                   string      `yaml:"PodIP"`
	PodCIDR                 PodCIDR     `yaml:"PodCIDR"`
	VerboseLogging          bool        `yaml:"VerboseLogging"`
	ErrorsOnlyLogging       bool        `yaml:"ErrorsOnlyLogging"`
	HTTP                    HTTP        `yaml:"HTTP"`
	KubeletHTTP             HTTP        `yaml:"KubeletHTTP"`
	Resources               Resources   `yaml:"Resources"`
	NodeLabels              []string    `yaml:"NodeLabels"`
	NodeTaints              []TaintSpec `yaml:"NodeTaints"`
	TLS                     TLSConfig   `yaml:"TLS,omitempty"`
	Network                 Network     `yaml:"Network,omitempty"`
}

Config holds the whole configuration

func LoadConfig

func LoadConfig(ctx context.Context, providerConfig string) (config Config, err error)

LoadConfig loads the given json configuration files and return a VirtualKubeletConfig struct

type Crtretriever

type Crtretriever func(*tls.ClientHelloInfo) (*tls.Certificate, error)

func NewCertificateRetriever

func NewCertificateRetriever(kubeClient kubernetes.Interface, signer, nodeName string, nodeIP net.IP) (Crtretriever, error)

NewCertificateManager creates a certificate manager for the kubelet when retrieving a server certificate, or returns an error. This function is inspired by Liqo implementation: https://github.com/liqotech/liqo/blob/master/cmd/virtual-kubelet/root/http.go#L149

func NewSelfSignedCertificateRetriever

func NewSelfSignedCertificateRetriever(nodeName string, nodeIP net.IP) Crtretriever

newSelfSignedCertificateRetriever creates a new retriever for self-signed certificates.

type HTTP

type HTTP struct {
	Insecure bool   `yaml:"Insecure"`
	CaCert   string `yaml:"CaCert"`
}

type Network

type Network struct {
	EnableTunnel         bool   `yaml:"EnableTunnel" default:"false"`
	WildcardDNS          string `yaml:"WildcardDNS,omitempty"`
	WstunnelTemplatePath string `yaml:"WstunnelTemplatePath,omitempty"`
	WstunnelCommand      string `yaml:"WstunnelCommand,omitempty"`
}

type PodCIDR

type PodCIDR struct {
	Subnet string `yaml:"Subnet"`
	MaxIP  int    `yaml:"MaxIP"`
	MinIP  int    `yaml:"MinIP"`
}

type PortMapping

type PortMapping struct {
	Port     int32
	Name     string
	Protocol string
}

type Provider

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

Provider defines the properties of the virtual kubelet provider

func NewProvider

func NewProvider(
	ctx context.Context,
	providerConfig,
	nodeName,
	nodeVersion,
	operatingSystem string,
	internalIP string,
	daemonEndpointPort int32,
	clientHTTPTransport *http.Transport,
) (*Provider, error)

NewProvider creates a new Provider, which implements the PodNotifier and other virtual-kubelet interfaces

func NewProviderConfig

func NewProviderConfig(
	config Config,
	nodeName string,
	nodeVersion string,
	operatingSystem string,
	internalIP string,
	daemonEndpointPort int32,
	clientHTTPTransport *http.Transport,
) (*Provider, error)

NewProviderConfig takes user-defined configuration and fills the Virtual Kubelet provider struct

func (*Provider) CreatePod

func (p *Provider) CreatePod(ctx context.Context, pod *v1.Pod) error

CreatePod accepts a Pod definition and stores it in memory in p.pods

func (*Provider) DeletePod

func (p *Provider) DeletePod(ctx context.Context, pod *v1.Pod) (err error)

DeletePod deletes the specified pod and drops it out of p.pods

func (*Provider) GetLogs

func (p *Provider) GetLogs(ctx context.Context, namespace, podName, containerName string, opts api.ContainerLogOpts) (io.ReadCloser, error)

GetLogs implements the logic for interLink pod logs retrieval.

func (*Provider) GetNode

func (p *Provider) GetNode() *v1.Node

GetNode return the Node information at the initiation of a virtual node

func (*Provider) GetPod

func (p *Provider) GetPod(_ context.Context, _ string, _ string) (*v1.Pod, error)

func (*Provider) GetPodByUID

func (p *Provider) GetPodByUID(ctx context.Context, namespace, name string, uid k8stypes.UID) (pod *v1.Pod, err error)

GetPodByUID returns a pod by name that is stored in memory.

func (*Provider) GetPodStatus

func (p *Provider) GetPodStatus(_ context.Context, _ string, _ string) (*v1.PodStatus, error)

func (*Provider) GetPodStatusByUID

func (p *Provider) GetPodStatusByUID(ctx context.Context, namespace, name string, uid k8stypes.UID) (*v1.PodStatus, error)

GetPodStatusByUID returns the status of a pod by name that is "running". returns nil if a pod by that name is not found.

func (*Provider) GetPods

func (p *Provider) GetPods(ctx context.Context) ([]*v1.Pod, error)

GetPods returns a list of all pods known to be "running".

func (*Provider) GetStatsSummary

func (p *Provider) GetStatsSummary(ctx context.Context) (*stats.Summary, error)

GetStatsSummary returns dummy stats for all pods known by this provider.

func (*Provider) NotifyNodeStatus

func (p *Provider) NotifyNodeStatus(ctx context.Context, f func(*v1.Node))

NotifyNodeStatus runs once at initiation time and set the function to be used for node change notification (native of vk) it also starts a go routine for continously checking the node status and availability

func (*Provider) NotifyPods

func (p *Provider) NotifyPods(_ context.Context, f func(*v1.Pod))

NotifyPods is called to set a pod notifier callback function. Also starts the go routine to monitor all vk pods

func (*Provider) Ping

func (p *Provider) Ping(_ context.Context) error

Ping the kubelet from the cluster, this will always be ok by design probably

func (*Provider) RetrievePodsFromCluster

func (p *Provider) RetrievePodsFromCluster(ctx context.Context) error

RetrievePodsFromCluster scans all pods registered to the K8S cluster and re-assigns the ones with a valid JobID to the Virtual Kubelet. This will run at the initiation time only

func (*Provider) UpdatePod

func (p *Provider) UpdatePod(ctx context.Context, pod *v1.Pod) error

UpdatePod accepts a Pod definition and updates its reference.

type Resources

type Resources struct {
	CPU          string        `yaml:"CPU,omitempty"`
	Memory       string        `yaml:"Memory,omitempty"`
	Pods         string        `yaml:"Pods,omitempty"`
	Accelerators []Accelerator `yaml:"Accelerators"`
}

type TLSConfig

type TLSConfig struct {
	Enabled    bool   `yaml:"Enabled"`
	CertFile   string `yaml:"CertFile,omitempty"`
	KeyFile    string `yaml:"KeyFile,omitempty"`
	CACertFile string `yaml:"CACertFile,omitempty"`
}

TLSConfig holds TLS/mTLS configuration for secure communication with interLink API

type TaintSpec

type TaintSpec struct {
	Key    string `yaml:"Key"`
	Value  string `yaml:"Value"`
	Effect string `yaml:"Effect"`
}

type WstunnelTemplateData

type WstunnelTemplateData struct {
	Name           string
	Namespace      string
	RandomPassword string
	ExposedPorts   []PortMapping
	WildcardDNS    string
}

Jump to

Keyboard shortcuts

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