Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

New Plugin: Per node resources plugin implementation #4

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea/**
16 changes: 16 additions & 0 deletions cmd/per-node-resources/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright 2019-2022 The Liqo Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// Package main bootstraps the main plugin
package main
52 changes: 52 additions & 0 deletions cmd/per-node-resources/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package main

import (
"os"
"time"

"github.com/spf13/cobra"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/client-go/kubernetes"
ctrl "sigs.k8s.io/controller-runtime"

grpcserver "github.com/liqotech/liqo-resource-plugins/pkg/per-node-resources"
"github.com/liqotech/liqo/pkg/utils/restcfg"
)

func main() {
var port int
var selector string
var resyncPeriod time.Duration
var nodeSelector labels.Selector
var includeVirtualNodes bool

var rootCmd = &cobra.Command{
Use: os.Args[0],
Short: "Liqo plugin which devides the available resource among peered clusters",
SilenceUsage: true,
PreRunE: func(cmd *cobra.Command, args []string) error {
var err error
if nodeSelector, err = labels.Parse(selector); err != nil {
return err
}
return nil
},
RunE: func(cmd *cobra.Command, args []string) error {
config := restcfg.SetRateLimiter(ctrl.GetConfigOrDie())
clientset := kubernetes.NewForConfigOrDie(config)

return grpcserver.ListenAndServeGRPCServer(port, clientset, resyncPeriod, nodeSelector, includeVirtualNodes)
},
}

rootCmd.PersistentFlags().BoolVar(&includeVirtualNodes, "include-virtual-nodes", false,
"if true resources of virtual nodes are considered, otherwise ignored")
rootCmd.PersistentFlags().DurationVar(&resyncPeriod, "resync-period", 10*time.Hour, "the resync period for the informers")
rootCmd.PersistentFlags().IntVar(&port, "port", 6001, "set port where the server will listen on.")
rootCmd.PersistentFlags().StringVar(&selector, "selector", "", "the selector to filter nodes. This flag can be used multiple times.")

err := rootCmd.Execute()
if err != nil {
os.Exit(1)
}
}
43 changes: 31 additions & 12 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,27 @@ go 1.19

require (
github.com/liqotech/liqo v0.6.0
github.com/onsi/ginkgo/v2 v2.6.1
github.com/spf13/cobra v1.6.1
google.golang.org/grpc v1.50.1
k8s.io/apimachinery v0.25.3
k8s.io/apimachinery v0.26.0
)

require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/evanphx/json-patch v5.6.0+incompatible // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2 // indirect
github.com/prometheus/client_golang v1.14.0 // indirect
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.37.0 // indirect
github.com/prometheus/procfs v0.8.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
k8s.io/apiextensions-apiserver v0.26.0 // indirect
k8s.io/component-base v0.26.0 // indirect
)

require (
Expand All @@ -31,29 +49,30 @@ require (
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/onsi/gomega v1.24.2
github.com/pkg/errors v0.9.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/virtual-kubelet/virtual-kubelet v1.6.1-0.20220831210300-d2523fe808a2 // indirect
golang.org/x/net v0.1.0 // indirect
golang.org/x/net v0.4.0 // indirect
golang.org/x/oauth2 v0.0.0-20220909003341-f21342109be1 // indirect
golang.org/x/sys v0.1.0 // indirect
golang.org/x/term v0.1.0 // indirect
golang.org/x/text v0.4.0 // indirect
golang.org/x/time v0.0.0-20220922220347-f3bd1da661af // indirect
golang.org/x/sys v0.3.0 // indirect
golang.org/x/term v0.3.0 // indirect
golang.org/x/text v0.5.0 // indirect
golang.org/x/time v0.3.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20220930163606-c98284e70a91 // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/api v0.25.3 // indirect
k8s.io/client-go v0.25.3 // indirect
k8s.io/api v0.26.0
k8s.io/client-go v0.26.0
k8s.io/klog/v2 v2.80.1 // indirect
k8s.io/kube-openapi v0.0.0-20220928191237-829ce0c27909 // indirect
k8s.io/kubectl v0.25.3 // indirect
k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280 // indirect
k8s.io/kubectl v0.25.3
k8s.io/metrics v0.25.3 // indirect
k8s.io/utils v0.0.0-20220922133306-665eaaec4324 // indirect
sigs.k8s.io/controller-runtime v0.13.0 // indirect
k8s.io/utils v0.0.0-20221128185143-99ec85e7a448 // indirect
sigs.k8s.io/controller-runtime v0.14.0
sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
Expand Down
Loading