Documentation
¶
Index ¶
- Constants
- Variables
- func AddSessionContext(req *http.Request, sessionContext string)
- func CheckIfAnnotationExists(pod *v1.Pod, key string) bool
- func GetResources(config Config) v1.ResourceList
- func GetSessionContextMessage(sessionContext string) string
- func LogRetrieval(ctx context.Context, config Config, logsRequest types.LogStruct, ...) (io.ReadCloser, error)
- func NodeCondition(ready bool) []v1.NodeCondition
- func NodeConditionWithInterlink(ready bool, interlinkStatus v1.ConditionStatus, ...) []v1.NodeCondition
- func PingInterLink(ctx context.Context, config Config) (bool, int, string, error)
- func PodPhase(_ Provider, phase string, podIP string) (v1.PodStatus, error)
- func RemoteExecution(ctx context.Context, config Config, p *Provider, pod *v1.Pod, mode int8) error
- func SetDefaultResource(config *Config)
- func TracerUpdate(ctx *context.Context, name string, pod *v1.Pod)
- type Accelerator
- type Config
- type Crtretriever
- type HTTP
- type Network
- type PodCIDR
- type PortMapping
- type Provider
- func (p *Provider) CreatePod(ctx context.Context, pod *v1.Pod) error
- func (p *Provider) DeletePod(ctx context.Context, pod *v1.Pod) (err error)
- func (p *Provider) GetLogs(ctx context.Context, namespace, podName, containerName string, ...) (io.ReadCloser, error)
- func (p *Provider) GetNode() *v1.Node
- func (p *Provider) GetPod(_ context.Context, _ string, _ string) (*v1.Pod, error)
- func (p *Provider) GetPodByUID(ctx context.Context, namespace, name string, uid k8stypes.UID) (pod *v1.Pod, err error)
- func (p *Provider) GetPodStatus(_ context.Context, _ string, _ string) (*v1.PodStatus, error)
- func (p *Provider) GetPodStatusByUID(ctx context.Context, namespace, name string, uid k8stypes.UID) (*v1.PodStatus, error)
- func (p *Provider) GetPods(ctx context.Context) ([]*v1.Pod, error)
- func (p *Provider) GetStatsSummary(ctx context.Context) (*stats.Summary, error)
- func (p *Provider) NotifyNodeStatus(ctx context.Context, f func(*v1.Node))
- func (p *Provider) NotifyPods(_ context.Context, f func(*v1.Pod))
- func (p *Provider) Ping(_ context.Context) error
- func (p *Provider) RetrievePodsFromCluster(ctx context.Context) error
- func (p *Provider) UpdatePod(ctx context.Context, pod *v1.Pod) error
- type Resources
- type TLSConfig
- type TaintSpec
- type WstunnelTemplateData
Constants ¶
const ( PodPhaseInitialize = "Initializing" PodPhaseCompleted = "Completed" )
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 ¶
var (
KubeletVersion = "test"
)
Functions ¶
func AddSessionContext ¶
func CheckIfAnnotationExists ¶
CheckIfAnnotationExists checks if a specific annotation (key) is available between the annotation of a pod
func GetResources ¶
func GetResources(config Config) v1.ResourceList
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 ¶
func NodeConditionWithInterlink(ready bool, interlinkStatus v1.ConditionStatus, interlinkReason, interlinkMessage string) []v1.NodeCondition
func PingInterLink ¶
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 RemoteExecution ¶
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)
Types ¶
type Accelerator ¶
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
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 PortMapping ¶
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) 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) 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 (*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) GetStatsSummary ¶
GetStatsSummary returns dummy stats for all pods known by this provider.
func (*Provider) NotifyNodeStatus ¶
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 ¶
NotifyPods is called to set a pod notifier callback function. Also starts the go routine to monitor all vk pods
func (*Provider) Ping ¶
Ping the kubelet from the cluster, this will always be ok by design probably
func (*Provider) RetrievePodsFromCluster ¶
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
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 WstunnelTemplateData ¶
type WstunnelTemplateData struct { Name string Namespace string RandomPassword string ExposedPorts []PortMapping WildcardDNS string }