Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

341 enable defining additional custom taints and labels to virtual nodes from interlink config #362

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ci/manifests/interlink-config-local.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#InterlinkAddress: "unix:///var/run/interlink.socket"
InterlinkAddress: "http://0.0.0.0"
InterlinkPort: "3000"
#SidecarURL: "http://plugin"
#sidecarURL: "http://plugin"
SidecarURL: "http://0.0.0.0"
SidecarPort: "4000"
VerboseLogging: true
Expand Down
2 changes: 1 addition & 1 deletion ci/manifests/interlink-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
InterlinkAddress: "http://0.0.0.0"
InterlinkPort: "3000"
SidecarURL: "http://plugin"
#SidecarURL: "http://0.0.0.0"
#sidecarURL: "http://0.0.0.0"
SidecarPort: "4000"
VerboseLogging: true
ErrorsOnlyLogging: false
Expand Down
7 changes: 4 additions & 3 deletions ci/manifests/virtual-kubelet-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ data:
ServiceAccount: "virtual-kubelet"
Namespace: interlink
VKTokenFile: ""
CPU: "100"
Memory: "128Gi"
Pods: "100"
Resources:
CPU: "100"
Memory: "128Gi"
Pods: "100"
HTTP:
Insecure: true
KubeletHTTP:
Expand Down
7 changes: 4 additions & 3 deletions cmd/installer/templates/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ interlink:
port: {{.InterLinkPort}}

virtualNode:
CPUs: {{.VKLimits.CPU}}
MemGiB: {{.VKLimits.Memory}}
Pods: {{.VKLimits.Pods}}
Resources:
CPU: {{.VKLimits.CPU}}
Memory: {{.VKLimits.Memory}}
Pods: {{.VKLimits.Pods}}
HTTPProxies:
HTTP: null
HTTPs: null
Expand Down
56 changes: 37 additions & 19 deletions pkg/virtualkubelet/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,45 @@ package virtualkubelet

// Config holds the whole configuration
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"`
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"`
InterlinkURL string `yaml:"InterlinkURL"`
InterlinkPort string `yaml:"InterlinkPort"`
KubernetesAPIAddr string `yaml:"KubernetesApiAddr"`
KubernetesAPIPort string `yaml:"KubernetesApiPort"`
KubernetesAPICaCrt string `yaml:"KubernetesApiCaCrt"`
DisableProjectedVolumes bool `yaml:"DisableProjectedVolumes"`
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"`
Resources Resources `yaml:"Resources"`
NodeLabels []string `yaml:"NodeLabels"`
NodeTaints []TaintSpec `yaml:"NodeTaints"`
}

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

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

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

type TaintSpec struct {
Key string `yaml:"Key"`
Value string `yaml:"Value"`
Effect string `yaml:"Effect"`
}
12 changes: 6 additions & 6 deletions pkg/virtualkubelet/execute.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func getSidecarEndpoint(ctx context.Context, interLinkURL string, interLinkPort
// 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 PingInterLink(ctx context.Context, config Config) (bool, int, error) {
tracer := otel.Tracer("interlink-service")
interLinkEndpoint := getSidecarEndpoint(ctx, config.InterlinkURL, config.Interlinkport)
interLinkEndpoint := getSidecarEndpoint(ctx, config.InterlinkURL, config.InterlinkPort)
log.G(ctx).Info("Pinging: " + interLinkEndpoint + "/pinglink")
retVal := -1
req, err := http.NewRequest(http.MethodPost, interLinkEndpoint+"/pinglink", nil)
Expand Down Expand Up @@ -145,7 +145,7 @@ func updateCacheRequest(ctx context.Context, config Config, pod v1.Pod, token st
return err
}

interLinkEndpoint := getSidecarEndpoint(ctx, config.InterlinkURL, config.Interlinkport)
interLinkEndpoint := getSidecarEndpoint(ctx, config.InterlinkURL, config.InterlinkPort)
reader := bytes.NewReader(bodyBytes)
req, err := http.NewRequest(http.MethodPost, interLinkEndpoint+"/updateCache", reader)
if err != nil {
Expand Down Expand Up @@ -183,7 +183,7 @@ func updateCacheRequest(ctx context.Context, config Config, pod v1.Pod, token st
// Returns the call response expressed in bytes and/or the first encountered error
func createRequest(ctx context.Context, config Config, pod types.PodCreateRequests, token string) ([]byte, error) {
tracer := otel.Tracer("interlink-service")
interLinkEndpoint := getSidecarEndpoint(ctx, config.InterlinkURL, config.Interlinkport)
interLinkEndpoint := getSidecarEndpoint(ctx, config.InterlinkURL, config.InterlinkPort)

bodyBytes, err := json.Marshal(pod)
if err != nil {
Expand Down Expand Up @@ -232,7 +232,7 @@ func createRequest(ctx context.Context, config Config, pod types.PodCreateReques
// deleteRequest performs a REST call to the InterLink API when a Pod is deleted from the VK. It Marshals the standard v1.Pod struct and sends it to InterLink.
// Returns the call response expressed in bytes and/or the first encountered error
func deleteRequest(ctx context.Context, config Config, pod *v1.Pod, token string) ([]byte, error) {
interLinkEndpoint := getSidecarEndpoint(ctx, config.InterlinkURL, config.Interlinkport)
interLinkEndpoint := getSidecarEndpoint(ctx, config.InterlinkURL, config.InterlinkPort)
var returnValue []byte
bodyBytes, err := json.Marshal(pod)
if err != nil {
Expand Down Expand Up @@ -288,7 +288,7 @@ func deleteRequest(ctx context.Context, config Config, pod *v1.Pod, token string
func statusRequest(ctx context.Context, config Config, podsList []*v1.Pod, token string) ([]byte, error) {
tracer := otel.Tracer("interlink-service")

interLinkEndpoint := getSidecarEndpoint(ctx, config.InterlinkURL, config.Interlinkport)
interLinkEndpoint := getSidecarEndpoint(ctx, config.InterlinkURL, config.InterlinkPort)

bodyBytes, err := json.Marshal(podsList)
if err != nil {
Expand Down Expand Up @@ -349,7 +349,7 @@ func LogRetrieval(
sessionContext string,
) (io.ReadCloser, error) {
tracer := otel.Tracer("interlink-service")
interLinkEndpoint := getSidecarEndpoint(ctx, config.InterlinkURL, config.Interlinkport)
interLinkEndpoint := getSidecarEndpoint(ctx, config.InterlinkURL, config.InterlinkPort)

token := ""

Expand Down
Loading
Loading