virtualkubelet

package
v0.0.0-...-cea1cc6 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2024 License: Apache-2.0 Imports: 34 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
)

Variables

This section is empty.

Functions

func BuildKey

func BuildKey(pod *v1.Pod) (string, error)

func BuildKeyFromNames

func BuildKeyFromNames(namespace string, name string) (string, error)

func LogRetrieval

func LogRetrieval(ctx context.Context, config VirtualKubeletConfig, logsRequest commonIL.LogStruct) (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 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.

func PingInterLink(ctx context.Context, config VirtualKubeletConfig) (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 RemoteExecution

func RemoteExecution(ctx context.Context, config VirtualKubeletConfig, p *VirtualKubeletProvider, 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

Types

type VirtualKubeletConfig

type VirtualKubeletConfig 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"`
	CPU               string `yaml:"cpu,omitempty"`
	Memory            string `yaml:"memory,omitempty"`
	Pods              string `yaml:"pods,omitempty"`
	GPU               string `yaml:"nvidia.com/gpu,omitempty"`
}

VirtualKubeletConfig holds the whole configuration

func LoadConfig

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

loadConfig loads the given json configuration files and yaml to communicate with InterLink.

type VirtualKubeletProvider

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

func NewProvider

func NewProvider(providerConfig, nodeName, operatingSystem string, internalIP string, daemonEndpointPort int32, ctx context.Context) (*VirtualKubeletProvider, error)

NewProvider creates a new Provider, which implements the PodNotifier interface

func NewProviderConfig

func NewProviderConfig(
	config VirtualKubeletConfig,
	nodeName string,
	operatingSystem string,
	internalIP string,
	daemonEndpointPort int32,
) (*VirtualKubeletProvider, error)

func (*VirtualKubeletProvider) CreatePod

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

CreatePod accepts a Pod definition and stores it in memory.

func (*VirtualKubeletProvider) DeletePod

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

DeletePod deletes the specified pod out of memory.

func (*VirtualKubeletProvider) GetLogs

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

func (*VirtualKubeletProvider) GetNode

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

func (*VirtualKubeletProvider) GetPod

func (p *VirtualKubeletProvider) GetPod(ctx context.Context, namespace, name string) (pod *v1.Pod, err error)

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

func (*VirtualKubeletProvider) GetPodStatus

func (p *VirtualKubeletProvider) 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 (*VirtualKubeletProvider) GetPods

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

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

func (*VirtualKubeletProvider) GetStatsSummary

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

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

func (*VirtualKubeletProvider) InitClientSet

func (p *VirtualKubeletProvider) InitClientSet(ctx context.Context) error

func (*VirtualKubeletProvider) NotifyNodeStatus

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

func (*VirtualKubeletProvider) NotifyPods

func (p *VirtualKubeletProvider) NotifyPods(ctx context.Context, f func(*v1.Pod))

NotifyPods is called to set a pod notifier callback function. This should be called before any operations are done within the provider.

func (*VirtualKubeletProvider) Ping

func (p *VirtualKubeletProvider) RetrievePodsFromInterlink(ctx context.Context) error

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

func (*VirtualKubeletProvider) UpdatePod

func (p *VirtualKubeletProvider) 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