Move around some packages (#658)
* Move tracing exporter registration This doesn't belong in the library and should be configured by the consumer of the opencensus package. * Rename `vkublet` package to `node` `vkubelet` does not convey any information to the consumers of the package. Really it would be nice to move this package to the root of the repo, but then you wind up with... interesting... import semantics due to the repo name... and after thinking about it some, a subpackage is really not so bad as long as it has a name that convey's some information. `node` was chosen since this package deals with all the semantics of operating a node in Kubernetes.
This commit is contained in:
@@ -22,7 +22,6 @@ import (
|
|||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/spf13/pflag"
|
"github.com/spf13/pflag"
|
||||||
"github.com/virtual-kubelet/virtual-kubelet/trace/opencensus"
|
|
||||||
"k8s.io/klog"
|
"k8s.io/klog"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -74,7 +73,7 @@ func installFlags(flags *pflag.FlagSet, c *Opts) {
|
|||||||
flags.IntVar(&c.PodSyncWorkers, "pod-sync-workers", c.PodSyncWorkers, `set the number of pod synchronization workers`)
|
flags.IntVar(&c.PodSyncWorkers, "pod-sync-workers", c.PodSyncWorkers, `set the number of pod synchronization workers`)
|
||||||
flags.BoolVar(&c.EnableNodeLease, "enable-node-lease", c.EnableNodeLease, `use node leases (1.13) for node heartbeats`)
|
flags.BoolVar(&c.EnableNodeLease, "enable-node-lease", c.EnableNodeLease, `use node leases (1.13) for node heartbeats`)
|
||||||
|
|
||||||
flags.StringSliceVar(&c.TraceExporters, "trace-exporter", c.TraceExporters, fmt.Sprintf("sets the tracing exporter to use, available exporters: %s", opencensus.AvailableTraceExporters()))
|
flags.StringSliceVar(&c.TraceExporters, "trace-exporter", c.TraceExporters, fmt.Sprintf("sets the tracing exporter to use, available exporters: %s", AvailableTraceExporters()))
|
||||||
flags.StringVar(&c.TraceConfig.ServiceName, "trace-service-name", c.TraceConfig.ServiceName, "sets the name of the service used to register with the trace exporter")
|
flags.StringVar(&c.TraceConfig.ServiceName, "trace-service-name", c.TraceConfig.ServiceName, "sets the name of the service used to register with the trace exporter")
|
||||||
flags.Var(mapVar(c.TraceConfig.Tags), "trace-tag", "add tags to include with traces in key=value form")
|
flags.Var(mapVar(c.TraceConfig.Tags), "trace-tag", "add tags to include with traces in key=value form")
|
||||||
flags.StringVar(&c.TraceSampleRate, "trace-sample-rate", c.TraceSampleRate, "set probability of tracing samples")
|
flags.StringVar(&c.TraceSampleRate, "trace-sample-rate", c.TraceSampleRate, "set probability of tracing samples")
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ import (
|
|||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/virtual-kubelet/virtual-kubelet/log"
|
"github.com/virtual-kubelet/virtual-kubelet/log"
|
||||||
|
"github.com/virtual-kubelet/virtual-kubelet/node/api"
|
||||||
"github.com/virtual-kubelet/virtual-kubelet/providers"
|
"github.com/virtual-kubelet/virtual-kubelet/providers"
|
||||||
"github.com/virtual-kubelet/virtual-kubelet/vkubelet/api"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// AcceptedCiphers is the list of accepted TLS ciphers, with known weak ciphers elided
|
// AcceptedCiphers is the list of accepted TLS ciphers, with known weak ciphers elided
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ import (
|
|||||||
|
|
||||||
"github.com/mitchellh/go-homedir"
|
"github.com/mitchellh/go-homedir"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/virtual-kubelet/virtual-kubelet/trace/opencensus"
|
|
||||||
corev1 "k8s.io/api/core/v1"
|
corev1 "k8s.io/api/core/v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -77,7 +76,7 @@ type Opts struct {
|
|||||||
|
|
||||||
TraceExporters []string
|
TraceExporters []string
|
||||||
TraceSampleRate string
|
TraceSampleRate string
|
||||||
TraceConfig opencensus.TracingExporterOptions
|
TraceConfig TracingExporterOptions
|
||||||
|
|
||||||
// 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
|
||||||
|
|||||||
@@ -25,9 +25,9 @@ import (
|
|||||||
"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/providers"
|
"github.com/virtual-kubelet/virtual-kubelet/providers"
|
||||||
"github.com/virtual-kubelet/virtual-kubelet/providers/register"
|
"github.com/virtual-kubelet/virtual-kubelet/providers/register"
|
||||||
"github.com/virtual-kubelet/virtual-kubelet/vkubelet"
|
|
||||||
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"
|
||||||
@@ -147,12 +147,12 @@ func runRootCommand(ctx context.Context, c Opts) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pNode := NodeFromProvider(ctx, c.NodeName, taint, p)
|
pNode := NodeFromProvider(ctx, c.NodeName, taint, p)
|
||||||
node, err := vkubelet.NewNode(
|
nodeRunner, err := node.NewNodeController(
|
||||||
vkubelet.NaiveNodeProvider{},
|
node.NaiveNodeProvider{},
|
||||||
pNode,
|
pNode,
|
||||||
client.CoreV1().Nodes(),
|
client.CoreV1().Nodes(),
|
||||||
vkubelet.WithNodeEnableLeaseV1Beta1(leaseClient, nil),
|
node.WithNodeEnableLeaseV1Beta1(leaseClient, nil),
|
||||||
vkubelet.WithNodeStatusUpdateErrorHandler(func(ctx context.Context, err error) error {
|
node.WithNodeStatusUpdateErrorHandler(func(ctx context.Context, err error) error {
|
||||||
if !k8serrors.IsNotFound(err) {
|
if !k8serrors.IsNotFound(err) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -176,7 +176,7 @@ func runRootCommand(ctx context.Context, c Opts) error {
|
|||||||
eb.StartLogging(log.G(ctx).Infof)
|
eb.StartLogging(log.G(ctx).Infof)
|
||||||
eb.StartRecordingToSink(&corev1client.EventSinkImpl{Interface: client.CoreV1().Events(c.KubeNamespace)})
|
eb.StartRecordingToSink(&corev1client.EventSinkImpl{Interface: client.CoreV1().Events(c.KubeNamespace)})
|
||||||
|
|
||||||
pc, err := vkubelet.NewPodController(vkubelet.PodControllerConfig{
|
pc, err := node.NewPodController(node.PodControllerConfig{
|
||||||
PodClient: client.CoreV1(),
|
PodClient: client.CoreV1(),
|
||||||
PodInformer: podInformer,
|
PodInformer: podInformer,
|
||||||
EventRecorder: eb.NewRecorder(scheme.Scheme, corev1.EventSource{Component: path.Join(pNode.Name, "pod-controller")}),
|
EventRecorder: eb.NewRecorder(scheme.Scheme, corev1.EventSource{Component: path.Join(pNode.Name, "pod-controller")}),
|
||||||
@@ -210,7 +210,7 @@ func runRootCommand(ctx context.Context, c Opts) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
if err := node.Run(ctx); err != nil {
|
if err := nodeRunner.Run(ctx); err != nil {
|
||||||
log.G(ctx).Fatal(err)
|
log.G(ctx).Fatal(err)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ import (
|
|||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"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/trace/opencensus"
|
|
||||||
octrace "go.opencensus.io/trace"
|
octrace "go.opencensus.io/trace"
|
||||||
"go.opencensus.io/zpages"
|
"go.opencensus.io/zpages"
|
||||||
)
|
)
|
||||||
@@ -55,7 +54,7 @@ func setupTracing(ctx context.Context, c Opts) error {
|
|||||||
setupZpages(ctx)
|
setupZpages(ctx)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
exporter, err := opencensus.GetTracingExporter(e, c.TraceConfig)
|
exporter, err := GetTracingExporter(e, c.TraceConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package opencensus
|
package root
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/virtual-kubelet/virtual-kubelet/errdefs"
|
"github.com/virtual-kubelet/virtual-kubelet/errdefs"
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
// +build !no_jaeger_exporter
|
// +build !no_jaeger_exporter
|
||||||
|
|
||||||
package opencensus
|
package root
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
// +build !no_ocagent_exporter
|
// +build !no_ocagent_exporter
|
||||||
|
|
||||||
package opencensus
|
package root
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package opencensus
|
package root
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
@@ -7,9 +7,9 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/virtual-kubelet/virtual-kubelet/vkubelet"
|
"github.com/virtual-kubelet/virtual-kubelet/node"
|
||||||
"gotest.tools/assert"
|
"gotest.tools/assert"
|
||||||
"k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||||
"k8s.io/kubernetes/pkg/kubelet/apis/stats/v1alpha1"
|
"k8s.io/kubernetes/pkg/kubelet/apis/stats/v1alpha1"
|
||||||
)
|
)
|
||||||
@@ -237,7 +237,7 @@ func TestCreatePodWithOptionalInexistentSecrets(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Wait for an event concerning the missing secret to be reported on the pod.
|
// Wait for an event concerning the missing secret to be reported on the pod.
|
||||||
if err := f.WaitUntilPodEventWithReason(pod, vkubelet.ReasonOptionalSecretNotFound); err != nil {
|
if err := f.WaitUntilPodEventWithReason(pod, node.ReasonOptionalSecretNotFound); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -266,7 +266,7 @@ func TestCreatePodWithMandatoryInexistentSecrets(t *testing.T) {
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
// Wait for an event concerning the missing secret to be reported on the pod.
|
// Wait for an event concerning the missing secret to be reported on the pod.
|
||||||
if err := f.WaitUntilPodEventWithReason(pod, vkubelet.ReasonMandatorySecretNotFound); err != nil {
|
if err := f.WaitUntilPodEventWithReason(pod, node.ReasonMandatorySecretNotFound); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -300,7 +300,7 @@ func TestCreatePodWithOptionalInexistentConfigMap(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Wait for an event concerning the missing config map to be reported on the pod.
|
// Wait for an event concerning the missing config map to be reported on the pod.
|
||||||
if err := f.WaitUntilPodEventWithReason(pod, vkubelet.ReasonOptionalConfigMapNotFound); err != nil {
|
if err := f.WaitUntilPodEventWithReason(pod, node.ReasonOptionalConfigMapNotFound); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -329,7 +329,7 @@ func TestCreatePodWithMandatoryInexistentConfigMap(t *testing.T) {
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
// Wait for an event concerning the missing config map to be reported on the pod.
|
// Wait for an event concerning the missing config map to be reported on the pod.
|
||||||
if err := f.WaitUntilPodEventWithReason(pod, vkubelet.ReasonMandatoryConfigMapNotFound); err != nil {
|
if err := f.WaitUntilPodEventWithReason(pod, node.ReasonMandatoryConfigMapNotFound); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
48
node/doc.go
Normal file
48
node/doc.go
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
Package node implements the components for operating a node in Kubernetes.
|
||||||
|
This includes controllers for managin the node object, running scheduled pods,
|
||||||
|
and exporting HTTP endpoints expected by the Kubernets API server.
|
||||||
|
|
||||||
|
There are two primary controllers, the node runner and the pod runner.
|
||||||
|
|
||||||
|
nodeRunner, _ := node.NewNodeController(...)
|
||||||
|
// setup other things
|
||||||
|
podRunner, _ := node.NewPodController(...)
|
||||||
|
|
||||||
|
go podRunner.Run(ctx)
|
||||||
|
|
||||||
|
select {
|
||||||
|
case <-podRunner.Ready():
|
||||||
|
go nodeRunner.Run(ctx)
|
||||||
|
case <-ctx.Done()
|
||||||
|
return ctx.Err()
|
||||||
|
}
|
||||||
|
|
||||||
|
After calling start, cancelling the passed in context will shutdown the
|
||||||
|
controller.
|
||||||
|
Note this example elides error handling.
|
||||||
|
|
||||||
|
Up to this point you have an active node in Kubernetes which can have pods scheduled
|
||||||
|
to it. However the API server expects nodes to implement API endpoints in order
|
||||||
|
to support certain features such as fetching logs or execing a new process.
|
||||||
|
The api package provides some helpers for this:
|
||||||
|
`api.AttachPodRoutes` and `api.AttachMetricsRoutes`.
|
||||||
|
|
||||||
|
mux := http.NewServeMux()
|
||||||
|
api.AttachPodRoutes(provider, mux)
|
||||||
|
|
||||||
|
You must configure your own HTTP server, but these helpers will add handlers at
|
||||||
|
the correct URI paths to your serve mux. You are not required to use go's
|
||||||
|
built-in `*http.ServeMux`, but it does implement the `ServeMux` interface
|
||||||
|
defined in this package which is used for these helpers.
|
||||||
|
|
||||||
|
Note: The metrics routes may need to be attached to a different HTTP server,
|
||||||
|
depending on your configuration.
|
||||||
|
|
||||||
|
For more fine-grained control over the API, see the `node/api` package which
|
||||||
|
only implements the HTTP handlers that you can use in whatever way you want.
|
||||||
|
|
||||||
|
This uses open-cenesus to implement tracing (but no internal metrics yet) which
|
||||||
|
is propagated through the context. This is passed on even to the providers.
|
||||||
|
*/
|
||||||
|
package node
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package vkubelet
|
package node
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package vkubelet
|
package node
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package vkubelet
|
package node
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
@@ -40,16 +40,16 @@ type NodeProvider interface {
|
|||||||
NotifyNodeStatus(ctx context.Context, cb func(*corev1.Node))
|
NotifyNodeStatus(ctx context.Context, cb func(*corev1.Node))
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewNode creates a new node.
|
// NewNodeController creates a new node controller.
|
||||||
// This does not have any side-effects on the system or kubernetes.
|
// This does not have any side-effects on the system or kubernetes.
|
||||||
//
|
//
|
||||||
// Use the node's `Run` method to register and run the loops to update the node
|
// Use the node's `Run` method to register and run the loops to update the node
|
||||||
// in Kubernetes.
|
// in Kubernetes.
|
||||||
//
|
//
|
||||||
// Note: When if there are multiple NodeOpts which apply against the same
|
// Note: When if there are multiple NodeControllerOpts which apply against the same
|
||||||
// underlying options, the last NodeOpt will win.
|
// underlying options, the last NodeControllerOpt will win.
|
||||||
func NewNode(p NodeProvider, node *corev1.Node, nodes v1.NodeInterface, opts ...NodeOpt) (*Node, error) {
|
func NewNodeController(p NodeProvider, node *corev1.Node, nodes v1.NodeInterface, opts ...NodeControllerOpt) (*NodeController, error) {
|
||||||
n := &Node{p: p, n: node, nodes: nodes, chReady: make(chan struct{})}
|
n := &NodeController{p: p, n: node, nodes: nodes, chReady: make(chan struct{})}
|
||||||
for _, o := range opts {
|
for _, o := range opts {
|
||||||
if err := o(n); err != nil {
|
if err := o(n); err != nil {
|
||||||
return nil, pkgerrors.Wrap(err, "error applying node option")
|
return nil, pkgerrors.Wrap(err, "error applying node option")
|
||||||
@@ -58,8 +58,8 @@ func NewNode(p NodeProvider, node *corev1.Node, nodes v1.NodeInterface, opts ...
|
|||||||
return n, nil
|
return n, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// NodeOpt are the functional options used for configuring a node
|
// NodeControllerOpt are the functional options used for configuring a node
|
||||||
type NodeOpt func(*Node) error
|
type NodeControllerOpt func(*NodeController) error // nolint: golint
|
||||||
|
|
||||||
// WithNodeEnableLeaseV1Beta1 enables support for v1beta1 leases.
|
// WithNodeEnableLeaseV1Beta1 enables support for v1beta1 leases.
|
||||||
// If client is nil, leases will not be enabled.
|
// If client is nil, leases will not be enabled.
|
||||||
@@ -75,8 +75,8 @@ type NodeOpt func(*Node) error
|
|||||||
// - When node leases are enabled, node status updates are colled by the
|
// - When node leases are enabled, node status updates are colled by the
|
||||||
// node status update interval option.
|
// node status update interval option.
|
||||||
// To set a custom node status update interval, see WithNodeStatusUpdateInterval().
|
// To set a custom node status update interval, see WithNodeStatusUpdateInterval().
|
||||||
func WithNodeEnableLeaseV1Beta1(client v1beta1.LeaseInterface, baseLease *coord.Lease) NodeOpt {
|
func WithNodeEnableLeaseV1Beta1(client v1beta1.LeaseInterface, baseLease *coord.Lease) NodeControllerOpt {
|
||||||
return func(n *Node) error {
|
return func(n *NodeController) error {
|
||||||
n.leases = client
|
n.leases = client
|
||||||
n.lease = baseLease
|
n.lease = baseLease
|
||||||
return nil
|
return nil
|
||||||
@@ -86,8 +86,8 @@ func WithNodeEnableLeaseV1Beta1(client v1beta1.LeaseInterface, baseLease *coord.
|
|||||||
// WithNodePingInterval sets the interval for checking node status
|
// WithNodePingInterval sets the interval for checking node status
|
||||||
// If node leases are not supported (or not enabled), this is the frequency
|
// If node leases are not supported (or not enabled), this is the frequency
|
||||||
// with which the node status will be updated in Kubernetes.
|
// with which the node status will be updated in Kubernetes.
|
||||||
func WithNodePingInterval(d time.Duration) NodeOpt {
|
func WithNodePingInterval(d time.Duration) NodeControllerOpt {
|
||||||
return func(n *Node) error {
|
return func(n *NodeController) error {
|
||||||
n.pingInterval = d
|
n.pingInterval = d
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -98,8 +98,8 @@ func WithNodePingInterval(d time.Duration) NodeOpt {
|
|||||||
// node status, not the node lease.
|
// node status, not the node lease.
|
||||||
// When node leases are not enabled (or are not supported on the cluster) this
|
// When node leases are not enabled (or are not supported on the cluster) this
|
||||||
// has no affect and node status is updated on the "ping" interval.
|
// has no affect and node status is updated on the "ping" interval.
|
||||||
func WithNodeStatusUpdateInterval(d time.Duration) NodeOpt {
|
func WithNodeStatusUpdateInterval(d time.Duration) NodeControllerOpt {
|
||||||
return func(n *Node) error {
|
return func(n *NodeController) error {
|
||||||
n.statusInterval = d
|
n.statusInterval = d
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -112,8 +112,8 @@ func WithNodeStatusUpdateInterval(d time.Duration) NodeOpt {
|
|||||||
//
|
//
|
||||||
// The error passed to the handler will be the error received from kubernetes
|
// The error passed to the handler will be the error received from kubernetes
|
||||||
// when updating node status.
|
// when updating node status.
|
||||||
func WithNodeStatusUpdateErrorHandler(h ErrorHandler) NodeOpt {
|
func WithNodeStatusUpdateErrorHandler(h ErrorHandler) NodeControllerOpt {
|
||||||
return func(n *Node) error {
|
return func(n *NodeController) error {
|
||||||
n.nodeStatusUpdateErrorHandler = h
|
n.nodeStatusUpdateErrorHandler = h
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -124,9 +124,10 @@ func WithNodeStatusUpdateErrorHandler(h ErrorHandler) NodeOpt {
|
|||||||
// progress can continue (or a retry is possible).
|
// progress can continue (or a retry is possible).
|
||||||
type ErrorHandler func(context.Context, error) error
|
type ErrorHandler func(context.Context, error) error
|
||||||
|
|
||||||
// Node deals with creating and managing a node object in Kubernetes.
|
// NodeController deals with creating and managing a node object in Kubernetes.
|
||||||
// It can register a node with Kubernetes and periodically update its status.
|
// It can register a node with Kubernetes and periodically update its status.
|
||||||
type Node struct {
|
// NodeController manages a single node entity.
|
||||||
|
type NodeController struct { // nolint: golint
|
||||||
p NodeProvider
|
p NodeProvider
|
||||||
n *corev1.Node
|
n *corev1.Node
|
||||||
|
|
||||||
@@ -162,7 +163,7 @@ const (
|
|||||||
// node status update (because some things still expect the node to be updated
|
// node status update (because some things still expect the node to be updated
|
||||||
// periodically), otherwise it will only use node status update with the configured
|
// periodically), otherwise it will only use node status update with the configured
|
||||||
// ping interval.
|
// ping interval.
|
||||||
func (n *Node) Run(ctx context.Context) error {
|
func (n *NodeController) Run(ctx context.Context) error {
|
||||||
if n.pingInterval == time.Duration(0) {
|
if n.pingInterval == time.Duration(0) {
|
||||||
n.pingInterval = DefaultPingInterval
|
n.pingInterval = DefaultPingInterval
|
||||||
}
|
}
|
||||||
@@ -201,7 +202,7 @@ func (n *Node) Run(ctx context.Context) error {
|
|||||||
return n.controlLoop(ctx)
|
return n.controlLoop(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *Node) ensureNode(ctx context.Context) error {
|
func (n *NodeController) ensureNode(ctx context.Context) error {
|
||||||
err := n.updateStatus(ctx, true)
|
err := n.updateStatus(ctx, true)
|
||||||
if err == nil || !errors.IsNotFound(err) {
|
if err == nil || !errors.IsNotFound(err) {
|
||||||
return err
|
return err
|
||||||
@@ -219,11 +220,11 @@ func (n *Node) ensureNode(ctx context.Context) error {
|
|||||||
// Ready returns a channel that gets closed when the node is fully up and
|
// Ready returns a channel that gets closed when the node is fully up and
|
||||||
// running. Note that if there is an error on startup this channel will never
|
// running. Note that if there is an error on startup this channel will never
|
||||||
// be started.
|
// be started.
|
||||||
func (n *Node) Ready() <-chan struct{} {
|
func (n *NodeController) Ready() <-chan struct{} {
|
||||||
return n.chReady
|
return n.chReady
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *Node) controlLoop(ctx context.Context) error {
|
func (n *NodeController) controlLoop(ctx context.Context) error {
|
||||||
pingTimer := time.NewTimer(n.pingInterval)
|
pingTimer := time.NewTimer(n.pingInterval)
|
||||||
defer pingTimer.Stop()
|
defer pingTimer.Stop()
|
||||||
|
|
||||||
@@ -278,7 +279,7 @@ func (n *Node) controlLoop(ctx context.Context) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *Node) handlePing(ctx context.Context) (retErr error) {
|
func (n *NodeController) handlePing(ctx context.Context) (retErr error) {
|
||||||
ctx, span := trace.StartSpan(ctx, "node.handlePing")
|
ctx, span := trace.StartSpan(ctx, "node.handlePing")
|
||||||
defer span.End()
|
defer span.End()
|
||||||
defer func() {
|
defer func() {
|
||||||
@@ -296,7 +297,7 @@ func (n *Node) handlePing(ctx context.Context) (retErr error) {
|
|||||||
return n.updateLease(ctx)
|
return n.updateLease(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *Node) updateLease(ctx context.Context) error {
|
func (n *NodeController) updateLease(ctx context.Context) error {
|
||||||
l, err := UpdateNodeLease(ctx, n.leases, newLease(n.lease))
|
l, err := UpdateNodeLease(ctx, n.leases, newLease(n.lease))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -306,7 +307,7 @@ func (n *Node) updateLease(ctx context.Context) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *Node) updateStatus(ctx context.Context, skipErrorCb bool) error {
|
func (n *NodeController) updateStatus(ctx context.Context, skipErrorCb bool) error {
|
||||||
updateNodeStatusHeartbeat(n.n)
|
updateNodeStatusHeartbeat(n.n)
|
||||||
|
|
||||||
node, err := UpdateNodeStatus(ctx, n.nodes, n.n)
|
node, err := UpdateNodeStatus(ctx, n.nodes, n.n)
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package vkubelet
|
package node
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
@@ -33,14 +33,14 @@ func testNodeRun(t *testing.T, enableLease bool) {
|
|||||||
leases := c.Coordination().Leases(corev1.NamespaceNodeLease)
|
leases := c.Coordination().Leases(corev1.NamespaceNodeLease)
|
||||||
|
|
||||||
interval := 1 * time.Millisecond
|
interval := 1 * time.Millisecond
|
||||||
opts := []NodeOpt{
|
opts := []NodeControllerOpt{
|
||||||
WithNodePingInterval(interval),
|
WithNodePingInterval(interval),
|
||||||
WithNodeStatusUpdateInterval(interval),
|
WithNodeStatusUpdateInterval(interval),
|
||||||
}
|
}
|
||||||
if enableLease {
|
if enableLease {
|
||||||
opts = append(opts, WithNodeEnableLeaseV1Beta1(leases, nil))
|
opts = append(opts, WithNodeEnableLeaseV1Beta1(leases, nil))
|
||||||
}
|
}
|
||||||
node, err := NewNode(testP, testNode(t), nodes, opts...)
|
node, err := NewNodeController(testP, testNode(t), nodes, opts...)
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
|
|
||||||
chErr := make(chan error)
|
chErr := make(chan error)
|
||||||
@@ -160,7 +160,7 @@ func TestNodeCustomUpdateStatusErrorHandler(t *testing.T) {
|
|||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
node, err := NewNode(testP, testNode(t), nodes,
|
node, err := NewNodeController(testP, testNode(t), nodes,
|
||||||
WithNodeStatusUpdateErrorHandler(func(_ context.Context, err error) error {
|
WithNodeStatusUpdateErrorHandler(func(_ context.Context, err error) error {
|
||||||
cancel()
|
cancel()
|
||||||
return nil
|
return nil
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package vkubelet
|
package node
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package vkubelet
|
package node
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
package vkubelet
|
package node
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package vkubelet
|
package node
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
@@ -20,8 +20,8 @@ import (
|
|||||||
"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/providers/alibabacloud/eci"
|
"github.com/virtual-kubelet/virtual-kubelet/providers/alibabacloud/eci"
|
||||||
"github.com/virtual-kubelet/virtual-kubelet/vkubelet/api"
|
|
||||||
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"
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import (
|
|||||||
"github.com/aws/aws-sdk-go/service/cloudwatchlogs"
|
"github.com/aws/aws-sdk-go/service/cloudwatchlogs"
|
||||||
"github.com/aws/aws-sdk-go/service/ecs"
|
"github.com/aws/aws-sdk-go/service/ecs"
|
||||||
"github.com/virtual-kubelet/virtual-kubelet/errdefs"
|
"github.com/virtual-kubelet/virtual-kubelet/errdefs"
|
||||||
"github.com/virtual-kubelet/virtual-kubelet/vkubelet/api"
|
"github.com/virtual-kubelet/virtual-kubelet/node/api"
|
||||||
k8sTypes "k8s.io/apimachinery/pkg/types"
|
k8sTypes "k8s.io/apimachinery/pkg/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"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/providers/aws/fargate"
|
"github.com/virtual-kubelet/virtual-kubelet/providers/aws/fargate"
|
||||||
"github.com/virtual-kubelet/virtual-kubelet/vkubelet/api"
|
|
||||||
corev1 "k8s.io/api/core/v1"
|
corev1 "k8s.io/api/core/v1"
|
||||||
"k8s.io/apimachinery/pkg/api/resource"
|
"k8s.io/apimachinery/pkg/api/resource"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ import (
|
|||||||
"github.com/aws/aws-sdk-go/service/ec2"
|
"github.com/aws/aws-sdk-go/service/ec2"
|
||||||
"github.com/aws/aws-sdk-go/service/ecs"
|
"github.com/aws/aws-sdk-go/service/ecs"
|
||||||
"github.com/aws/aws-sdk-go/service/iam"
|
"github.com/aws/aws-sdk-go/service/iam"
|
||||||
|
"github.com/virtual-kubelet/virtual-kubelet/node/api"
|
||||||
vkAWS "github.com/virtual-kubelet/virtual-kubelet/providers/aws"
|
vkAWS "github.com/virtual-kubelet/virtual-kubelet/providers/aws"
|
||||||
"github.com/virtual-kubelet/virtual-kubelet/vkubelet/api"
|
|
||||||
v1 "k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
"k8s.io/apimachinery/pkg/api/resource"
|
"k8s.io/apimachinery/pkg/api/resource"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
|||||||
@@ -26,8 +26,8 @@ import (
|
|||||||
"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/trace"
|
"github.com/virtual-kubelet/virtual-kubelet/trace"
|
||||||
"github.com/virtual-kubelet/virtual-kubelet/vkubelet/api"
|
|
||||||
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"
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ import (
|
|||||||
"github.com/Azure/go-autorest/autorest/to"
|
"github.com/Azure/go-autorest/autorest/to"
|
||||||
"github.com/lawrencegripper/pod2docker"
|
"github.com/lawrencegripper/pod2docker"
|
||||||
"github.com/virtual-kubelet/virtual-kubelet/manager"
|
"github.com/virtual-kubelet/virtual-kubelet/manager"
|
||||||
|
"github.com/virtual-kubelet/virtual-kubelet/node/api"
|
||||||
azureCreds "github.com/virtual-kubelet/virtual-kubelet/providers/azure"
|
azureCreds "github.com/virtual-kubelet/virtual-kubelet/providers/azure"
|
||||||
"github.com/virtual-kubelet/virtual-kubelet/vkubelet/api"
|
|
||||||
v1 "k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
"k8s.io/apimachinery/pkg/api/resource"
|
"k8s.io/apimachinery/pkg/api/resource"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import (
|
|||||||
|
|
||||||
"github.com/Azure/azure-sdk-for-go/services/batch/2017-09-01.6.0/batch"
|
"github.com/Azure/azure-sdk-for-go/services/batch/2017-09-01.6.0/batch"
|
||||||
"github.com/Azure/go-autorest/autorest"
|
"github.com/Azure/go-autorest/autorest"
|
||||||
"github.com/virtual-kubelet/virtual-kubelet/vkubelet/api"
|
"github.com/virtual-kubelet/virtual-kubelet/node/api"
|
||||||
|
|
||||||
apiv1 "k8s.io/api/core/v1"
|
apiv1 "k8s.io/api/core/v1"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -19,8 +19,8 @@ import (
|
|||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"github.com/virtual-kubelet/virtual-kubelet/errdefs"
|
"github.com/virtual-kubelet/virtual-kubelet/errdefs"
|
||||||
"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/providers"
|
"github.com/virtual-kubelet/virtual-kubelet/providers"
|
||||||
"github.com/virtual-kubelet/virtual-kubelet/vkubelet/api"
|
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
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"
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ import (
|
|||||||
|
|
||||||
"github.com/virtual-kubelet/virtual-kubelet/errdefs"
|
"github.com/virtual-kubelet/virtual-kubelet/errdefs"
|
||||||
"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/providers/huawei/auth"
|
"github.com/virtual-kubelet/virtual-kubelet/providers/huawei/auth"
|
||||||
"github.com/virtual-kubelet/virtual-kubelet/vkubelet/api"
|
|
||||||
v1 "k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
"k8s.io/apimachinery/pkg/api/resource"
|
"k8s.io/apimachinery/pkg/api/resource"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ import (
|
|||||||
|
|
||||||
"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/node/api"
|
||||||
"github.com/virtual-kubelet/virtual-kubelet/trace"
|
"github.com/virtual-kubelet/virtual-kubelet/trace"
|
||||||
"github.com/virtual-kubelet/virtual-kubelet/vkubelet/api"
|
|
||||||
v1 "k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
"k8s.io/apimachinery/pkg/api/resource"
|
"k8s.io/apimachinery/pkg/api/resource"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
@@ -37,7 +37,7 @@ const (
|
|||||||
var (
|
var (
|
||||||
_ providers.Provider = (*MockLegacyProvider)(nil)
|
_ providers.Provider = (*MockLegacyProvider)(nil)
|
||||||
_ providers.PodMetricsProvider = (*MockLegacyProvider)(nil)
|
_ providers.PodMetricsProvider = (*MockLegacyProvider)(nil)
|
||||||
_ vkubelet.PodNotifier = (*MockProvider)(nil)
|
_ node.PodNotifier = (*MockProvider)(nil)
|
||||||
)
|
)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ package mock
|
|||||||
/*
|
/*
|
||||||
func TestMockLegacyInterface(t *testing.T) {
|
func TestMockLegacyInterface(t *testing.T) {
|
||||||
var mlp providers.Provider = &MockLegacyProvider{}
|
var mlp providers.Provider = &MockLegacyProvider{}
|
||||||
_, ok := mlp.(vkubelet.PodNotifier)
|
_, ok := mlp.(node.PodNotifier)
|
||||||
assert.Assert(t, !ok)
|
assert.Assert(t, !ok)
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ import (
|
|||||||
|
|
||||||
nomad "github.com/hashicorp/nomad/api"
|
nomad "github.com/hashicorp/nomad/api"
|
||||||
"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/providers"
|
"github.com/virtual-kubelet/virtual-kubelet/providers"
|
||||||
"github.com/virtual-kubelet/virtual-kubelet/vkubelet/api"
|
|
||||||
v1 "k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
"k8s.io/apimachinery/pkg/api/resource"
|
"k8s.io/apimachinery/pkg/api/resource"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ import (
|
|||||||
"github.com/gophercloud/gophercloud/openstack/container/v1/capsules"
|
"github.com/gophercloud/gophercloud/openstack/container/v1/capsules"
|
||||||
"github.com/gophercloud/gophercloud/pagination"
|
"github.com/gophercloud/gophercloud/pagination"
|
||||||
"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/providers"
|
"github.com/virtual-kubelet/virtual-kubelet/providers"
|
||||||
"github.com/virtual-kubelet/virtual-kubelet/vkubelet/api"
|
|
||||||
v1 "k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
"k8s.io/apimachinery/pkg/api/resource"
|
"k8s.io/apimachinery/pkg/api/resource"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"io"
|
"io"
|
||||||
|
|
||||||
"github.com/virtual-kubelet/virtual-kubelet/vkubelet"
|
"github.com/virtual-kubelet/virtual-kubelet/node"
|
||||||
"github.com/virtual-kubelet/virtual-kubelet/vkubelet/api"
|
"github.com/virtual-kubelet/virtual-kubelet/node/api"
|
||||||
v1 "k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
stats "k8s.io/kubernetes/pkg/kubelet/apis/stats/v1alpha1"
|
stats "k8s.io/kubernetes/pkg/kubelet/apis/stats/v1alpha1"
|
||||||
)
|
)
|
||||||
@@ -16,7 +16,7 @@ import (
|
|||||||
// github.com/virtual-kubelet/virtual-kubelet/errdefs package in order for the
|
// github.com/virtual-kubelet/virtual-kubelet/errdefs package in order for the
|
||||||
// core logic to be able to understand the type of failure.
|
// core logic to be able to understand the type of failure.
|
||||||
type Provider interface {
|
type Provider interface {
|
||||||
vkubelet.PodLifecycleHandler
|
node.PodLifecycleHandler
|
||||||
|
|
||||||
// GetContainerLogs retrieves the logs of a container by name from the provider.
|
// GetContainerLogs retrieves the logs of a container by name from the provider.
|
||||||
GetContainerLogs(ctx context.Context, namespace, podName, containerName string, opts api.ContainerLogOpts) (io.ReadCloser, error)
|
GetContainerLogs(ctx context.Context, namespace, podName, containerName string, opts api.ContainerLogOpts) (io.ReadCloser, error)
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ import (
|
|||||||
|
|
||||||
"github.com/cenkalti/backoff"
|
"github.com/cenkalti/backoff"
|
||||||
"github.com/virtual-kubelet/virtual-kubelet/errdefs"
|
"github.com/virtual-kubelet/virtual-kubelet/errdefs"
|
||||||
"github.com/virtual-kubelet/virtual-kubelet/vkubelet/api"
|
"github.com/virtual-kubelet/virtual-kubelet/node/api"
|
||||||
v1 "k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -1,44 +0,0 @@
|
|||||||
/*
|
|
||||||
Package vkubelet implements the core virtual-kubelet framework.
|
|
||||||
It contains everything reuired to implement a virtuak-kubelet, including the
|
|
||||||
core controller which reconciles pod states and API endpoints for things like
|
|
||||||
pod logs, exec, attach, etc.
|
|
||||||
|
|
||||||
To get started, call the `New` with the appropriate config. When you are ready
|
|
||||||
to start the controller, which registers the node and starts watching for pod
|
|
||||||
changes, call `Run`. Taints can be used ensure the sceduler only schedules
|
|
||||||
certain workloads to your virtual-kubelet.
|
|
||||||
|
|
||||||
vk := vkubelet.New(...)
|
|
||||||
// setup other things
|
|
||||||
...
|
|
||||||
vk.Run(ctx, ...)
|
|
||||||
|
|
||||||
After calling start, cancelling the passed in context will shutdown the
|
|
||||||
controller.
|
|
||||||
|
|
||||||
Up to this point you have a running virtual kubelet controller, but no HTTP
|
|
||||||
handlers to deal with requests forwarded from the API server for things like
|
|
||||||
pod logs (e.g. user calls `kubectl logs myVKPod`). The api package provides some
|
|
||||||
helpers for this: `api.AttachPodRoutes` and `api.AttachMetricsRoutes`.
|
|
||||||
|
|
||||||
mux := http.NewServeMux()
|
|
||||||
api.AttachPodRoutes(provider, mux)
|
|
||||||
|
|
||||||
You must configure your own HTTP server, but these helpers will add handlers at
|
|
||||||
the correct URI paths to your serve mux. You are not required to use go's
|
|
||||||
built-in `*http.ServeMux`, but it does implement the `ServeMux` interface
|
|
||||||
defined in this package which is used for these helpers.
|
|
||||||
|
|
||||||
Note: The metrics routes may need to be attached to a different HTTP server,
|
|
||||||
depending on your configuration.
|
|
||||||
|
|
||||||
For more fine-grained control over the API, see the `vkubelet/api` package which
|
|
||||||
only implements the HTTP handlers that you can use in whatever way you want.
|
|
||||||
|
|
||||||
This uses open-cenesus to implement tracing (but no internal metrics yet) which
|
|
||||||
is propagated through the context. This is passed on even to the providers. We
|
|
||||||
may look at supporting custom propagaters for providers who would like to use a
|
|
||||||
different tracing format.
|
|
||||||
*/
|
|
||||||
package vkubelet
|
|
||||||
Reference in New Issue
Block a user