virtualkubelet

package
v0.0.0-...-a69401a Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2024 License: Apache-2.0 Imports: 37 Imported by: 0

Documentation

Index

Constants

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

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, 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 PingInterLink(ctx context.Context, config Config) (bool, int, 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.

func PodPhase

func PodPhase(p Provider, phase 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 Config

type Config struct {
	InterlinkURL      string `yaml:"InterlinkURL"`
	Interlinkport     string `yaml:"InterlinkPort"`
	VKConfigPath      string `yaml:"VKConfigPath"`
	VKTokenFile       string `yaml:"VKTokenFile"`
	ServiceAccount    string `yaml:"ServiceAccount"`
	Namespace         string `yaml:"Namespace"`
	PodIP             string `yaml:"PodIP"`
	VerboseLogging    bool   `yaml:"VerboseLogging"`
	ErrorsOnlyLogging bool   `yaml:"ErrorsOnlyLogging"`
	HTTP              HTTP   `yaml:"HTTP"`
	KubeletHTTP       HTTP   `yaml:"KubeletHTTP"`
	CPU               string `yaml:"CPU,omitempty"`
	Memory            string `yaml:"Memory,omitempty"`
	Pods              string `yaml:"Pods,omitempty"`
	GPU               string `yaml:"nvidia.com/gpu,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"`
}

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,
) (*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,
) (*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(ctx context.Context, namespace, name string) (pod *v1.Pod, err error)

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

func (*Provider) GetPodStatus

func (p *Provider) GetPodStatus(ctx context.Context, namespace, name string) (*v1.PodStatus, error)

GetPodStatus 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(ctx 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.

Jump to

Keyboard shortcuts

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