Fixup items after move provider from vk/vk
This commit is contained in:
@@ -19,7 +19,6 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/virtual-kubelet/virtual-kubelet/providers/register"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewCommand creates a new providers subcommand
|
// NewCommand creates a new providers subcommand
|
||||||
@@ -33,12 +32,9 @@ func NewCommand() *cobra.Command {
|
|||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
switch len(args) {
|
switch len(args) {
|
||||||
case 0:
|
case 0:
|
||||||
ls := register.List()
|
fmt.Fprintln(cmd.OutOrStdout(), "alibabacloud")
|
||||||
for _, p := range ls {
|
|
||||||
fmt.Fprintln(cmd.OutOrStdout(), p)
|
|
||||||
}
|
|
||||||
case 1:
|
case 1:
|
||||||
if !register.Exists(args[0]) {
|
if args[0] != "alibabacloud" {
|
||||||
fmt.Fprintln(cmd.OutOrStderr(), "no such provider", args[0])
|
fmt.Fprintln(cmd.OutOrStderr(), "no such provider", args[0])
|
||||||
|
|
||||||
// TODO(@cpuuy83): would be nice to not short-circuit the exit here
|
// TODO(@cpuuy83): would be nice to not short-circuit the exit here
|
||||||
|
|||||||
@@ -20,21 +20,14 @@ import (
|
|||||||
|
|
||||||
"github.com/virtual-kubelet/virtual-kubelet/errdefs"
|
"github.com/virtual-kubelet/virtual-kubelet/errdefs"
|
||||||
"github.com/virtual-kubelet/virtual-kubelet/providers"
|
"github.com/virtual-kubelet/virtual-kubelet/providers"
|
||||||
"github.com/virtual-kubelet/virtual-kubelet/version"
|
|
||||||
corev1 "k8s.io/api/core/v1"
|
corev1 "k8s.io/api/core/v1"
|
||||||
v1 "k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
|
||||||
// vkVersion is a concatenation of the Kubernetes version the VK is built against, the string "vk" and the VK release version.
|
|
||||||
// TODO @pires revisit after VK 1.0 is released as agreed in https://github.com/virtual-kubelet/virtual-kubelet/pull/446#issuecomment-448423176.
|
|
||||||
vkVersion = strings.Join([]string{"v1.13.1", "vk", version.Version}, "-")
|
|
||||||
)
|
|
||||||
|
|
||||||
// NodeFromProvider builds a kubernetes node object from a provider
|
// NodeFromProvider builds a kubernetes node object from a provider
|
||||||
// This is a temporary solution until node stuff actually split off from the provider interface itself.
|
// This is a temporary solution until node stuff actually split off from the provider interface itself.
|
||||||
func NodeFromProvider(ctx context.Context, name string, taint *v1.Taint, p providers.Provider) *v1.Node {
|
func NodeFromProvider(ctx context.Context, name string, taint *v1.Taint, p providers.Provider, version string) *v1.Node {
|
||||||
taints := make([]v1.Taint, 0)
|
taints := make([]v1.Taint, 0)
|
||||||
|
|
||||||
if taint != nil {
|
if taint != nil {
|
||||||
@@ -59,7 +52,7 @@ func NodeFromProvider(ctx context.Context, name string, taint *v1.Taint, p provi
|
|||||||
NodeInfo: v1.NodeSystemInfo{
|
NodeInfo: v1.NodeSystemInfo{
|
||||||
OperatingSystem: p.OperatingSystem(),
|
OperatingSystem: p.OperatingSystem(),
|
||||||
Architecture: "amd64",
|
Architecture: "amd64",
|
||||||
KubeletVersion: vkVersion,
|
KubeletVersion: version,
|
||||||
},
|
},
|
||||||
Capacity: p.Capacity(ctx),
|
Capacity: p.Capacity(ctx),
|
||||||
Allocatable: p.Capacity(ctx),
|
Allocatable: p.Capacity(ctx),
|
||||||
|
|||||||
@@ -80,6 +80,8 @@ type Opts struct {
|
|||||||
|
|
||||||
// Startup Timeout is how long to wait for the kubelet to start
|
// Startup Timeout is how long to wait for the kubelet to start
|
||||||
StartupTimeout time.Duration
|
StartupTimeout time.Duration
|
||||||
|
|
||||||
|
Version string
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetDefaultOpts sets default options for unset values on the passed in option struct.
|
// SetDefaultOpts sets default options for unset values on the passed in option struct.
|
||||||
|
|||||||
@@ -22,12 +22,12 @@ import (
|
|||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
"github.com/virtual-kubelet/alibabacloud-eci"
|
||||||
"github.com/virtual-kubelet/virtual-kubelet/errdefs"
|
"github.com/virtual-kubelet/virtual-kubelet/errdefs"
|
||||||
"github.com/virtual-kubelet/virtual-kubelet/log"
|
"github.com/virtual-kubelet/virtual-kubelet/log"
|
||||||
"github.com/virtual-kubelet/virtual-kubelet/manager"
|
"github.com/virtual-kubelet/virtual-kubelet/manager"
|
||||||
"github.com/virtual-kubelet/virtual-kubelet/node"
|
"github.com/virtual-kubelet/virtual-kubelet/node"
|
||||||
"github.com/virtual-kubelet/virtual-kubelet/providers"
|
"github.com/virtual-kubelet/virtual-kubelet/providers"
|
||||||
"github.com/virtual-kubelet/virtual-kubelet/providers/register"
|
|
||||||
corev1 "k8s.io/api/core/v1"
|
corev1 "k8s.io/api/core/v1"
|
||||||
k8serrors "k8s.io/apimachinery/pkg/api/errors"
|
k8serrors "k8s.io/apimachinery/pkg/api/errors"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
@@ -120,16 +120,18 @@ func runRootCommand(ctx context.Context, c Opts) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
initConfig := register.InitConfig{
|
if c.Provider != "" && c.Provider != "alibabacloud" {
|
||||||
ConfigPath: c.ProviderConfigPath,
|
return errors.Errorf("provider not supported %q: alibabacloud is the only support provider", c.Provider)
|
||||||
NodeName: c.NodeName,
|
|
||||||
OperatingSystem: c.OperatingSystem,
|
|
||||||
ResourceManager: rm,
|
|
||||||
DaemonPort: int32(c.ListenPort),
|
|
||||||
InternalIP: os.Getenv("VKUBELET_POD_IP"),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
p, err := register.GetProvider(c.Provider, initConfig)
|
p, err := alibabacloud.NewECIProvider(
|
||||||
|
c.ProviderConfigPath,
|
||||||
|
rm,
|
||||||
|
c.NodeName,
|
||||||
|
c.OperatingSystem,
|
||||||
|
os.Getenv("VKUBELET_POD_IP"),
|
||||||
|
c.ListenPort,
|
||||||
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -146,7 +148,7 @@ func runRootCommand(ctx context.Context, c Opts) error {
|
|||||||
leaseClient = client.CoordinationV1beta1().Leases(corev1.NamespaceNodeLease)
|
leaseClient = client.CoordinationV1beta1().Leases(corev1.NamespaceNodeLease)
|
||||||
}
|
}
|
||||||
|
|
||||||
pNode := NodeFromProvider(ctx, c.NodeName, taint, p)
|
pNode := NodeFromProvider(ctx, c.NodeName, taint, p, c.Version)
|
||||||
nodeRunner, err := node.NewNodeController(
|
nodeRunner, err := node.NewNodeController(
|
||||||
node.NaiveNodeProvider{},
|
node.NaiveNodeProvider{},
|
||||||
pNode,
|
pNode,
|
||||||
|
|||||||
@@ -18,17 +18,16 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/virtual-kubelet/virtual-kubelet/version"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewCommand creates a new version subcommand command
|
// NewCommand creates a new version subcommand command
|
||||||
func NewCommand() *cobra.Command {
|
func NewCommand(version, buildTime string) *cobra.Command {
|
||||||
return &cobra.Command{
|
return &cobra.Command{
|
||||||
Use: "version",
|
Use: "version",
|
||||||
Short: "Show the version of the program",
|
Short: "Show the version of the program",
|
||||||
Long: `Show the version of the program`,
|
Long: `Show the version of the program`,
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
fmt.Printf("Version: %s, Built: %s\n", version.Version, version.BuildTime)
|
fmt.Printf("Version: %s, Built: %s\n", version, buildTime)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,20 +19,27 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/virtual-kubelet/virtual-kubelet/cmd/virtual-kubelet/commands/providers"
|
"github.com/virtual-kubelet/alibabacloud-eci/cmd/virtual-kubelet/commands/providers"
|
||||||
"github.com/virtual-kubelet/virtual-kubelet/cmd/virtual-kubelet/commands/root"
|
"github.com/virtual-kubelet/alibabacloud-eci/cmd/virtual-kubelet/commands/root"
|
||||||
"github.com/virtual-kubelet/virtual-kubelet/cmd/virtual-kubelet/commands/version"
|
"github.com/virtual-kubelet/alibabacloud-eci/cmd/virtual-kubelet/commands/version"
|
||||||
"github.com/virtual-kubelet/virtual-kubelet/log"
|
"github.com/virtual-kubelet/virtual-kubelet/log"
|
||||||
logruslogger "github.com/virtual-kubelet/virtual-kubelet/log/logrus"
|
logruslogger "github.com/virtual-kubelet/virtual-kubelet/log/logrus"
|
||||||
"github.com/virtual-kubelet/virtual-kubelet/trace"
|
"github.com/virtual-kubelet/virtual-kubelet/trace"
|
||||||
"github.com/virtual-kubelet/virtual-kubelet/trace/opencensus"
|
"github.com/virtual-kubelet/virtual-kubelet/trace/opencensus"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
buildVersion = "N/A"
|
||||||
|
buildTime = "N/A"
|
||||||
|
k8sVersion = "v1.13.1" // This should follow the version of k8s.io/kubernetes we are importing
|
||||||
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
sig := make(chan os.Signal, 1)
|
sig := make(chan os.Signal, 1)
|
||||||
@@ -47,9 +54,10 @@ func main() {
|
|||||||
|
|
||||||
var opts root.Opts
|
var opts root.Opts
|
||||||
optsErr := root.SetDefaultOpts(&opts)
|
optsErr := root.SetDefaultOpts(&opts)
|
||||||
|
opts.Version = strings.Join([]string{k8sVersion, "vk-alibabacloud", buildVersion}, "-")
|
||||||
|
|
||||||
rootCmd := root.NewCommand(ctx, filepath.Base(os.Args[0]), opts)
|
rootCmd := root.NewCommand(ctx, filepath.Base(os.Args[0]), opts)
|
||||||
rootCmd.AddCommand(version.NewCommand(), providers.NewCommand())
|
rootCmd.AddCommand(version.NewCommand(buildVersion, buildTime), providers.NewCommand())
|
||||||
preRun := rootCmd.PreRunE
|
preRun := rootCmd.PreRunE
|
||||||
|
|
||||||
var logLevel string
|
var logLevel string
|
||||||
|
|||||||
2
eci.go
2
eci.go
@@ -17,11 +17,11 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests"
|
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests"
|
||||||
|
"github.com/virtual-kubelet/alibabacloud-eci/eci"
|
||||||
"github.com/virtual-kubelet/virtual-kubelet/errdefs"
|
"github.com/virtual-kubelet/virtual-kubelet/errdefs"
|
||||||
"github.com/virtual-kubelet/virtual-kubelet/log"
|
"github.com/virtual-kubelet/virtual-kubelet/log"
|
||||||
"github.com/virtual-kubelet/virtual-kubelet/manager"
|
"github.com/virtual-kubelet/virtual-kubelet/manager"
|
||||||
"github.com/virtual-kubelet/virtual-kubelet/node/api"
|
"github.com/virtual-kubelet/virtual-kubelet/node/api"
|
||||||
"github.com/virtual-kubelet/virtual-kubelet/providers/alibabacloud/eci"
|
|
||||||
v1 "k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
k8serr "k8s.io/apimachinery/pkg/api/errors"
|
k8serr "k8s.io/apimachinery/pkg/api/errors"
|
||||||
"k8s.io/apimachinery/pkg/api/resource"
|
"k8s.io/apimachinery/pkg/api/resource"
|
||||||
|
|||||||
Reference in New Issue
Block a user