Some basic agent startup
This commit is contained in:
@@ -38,6 +38,7 @@ func NewRegistry(ctx *node.NodeContext) *Registry {
|
||||
"RunKubeadmUpgradeApply": node.RunKubeadmUpgradeApply,
|
||||
"RunKubeadmUpgradeNode": node.RunKubeadmUpgradeNode,
|
||||
"StartCRIO": node.StartCRIO,
|
||||
"StartControlAgent": node.StartControlAgent,
|
||||
"ValidateNodeIPAndAPIServerReachability": node.ValidateNodeIPAndAPIServerReachability,
|
||||
"ValidateRequiredImagesPresent": node.ValidateRequiredImagesPresent,
|
||||
"WaitForExistingClusterIfNeeded": node.WaitForExistingClusterIfNeeded,
|
||||
@@ -45,14 +46,6 @@ func NewRegistry(ctx *node.NodeContext) *Registry {
|
||||
}
|
||||
}
|
||||
|
||||
func (r *Registry) MustGet(name string) node.Step {
|
||||
step, ok := r.steps[name]
|
||||
if !ok {
|
||||
panic(fmt.Sprintf("unknown step %q", name))
|
||||
}
|
||||
return step
|
||||
}
|
||||
|
||||
func (r *Registry) Get(name string) (node.Step, error) {
|
||||
step, ok := r.steps[name]
|
||||
if !ok {
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"k8s.io/klog/v2"
|
||||
monov1alpha1 "undecided.project/monok8s/pkg/apis/monok8s/v1alpha1"
|
||||
"undecided.project/monok8s/pkg/node"
|
||||
"undecided.project/monok8s/pkg/system"
|
||||
@@ -131,6 +132,11 @@ func NewRunner(cfg *monov1alpha1.MonoKSConfig) *Runner {
|
||||
Name: "Apply node metadata",
|
||||
Desc: "Apply labels/annotations to the local node if API server is reachable",
|
||||
},
|
||||
{
|
||||
RegKey: "StartControlAgent",
|
||||
Name: "Starts the Control Agent",
|
||||
Desc: "Handles OSUpgrade resources polling",
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -153,6 +159,7 @@ func (r *Runner) Init(ctx context.Context) error {
|
||||
return fmt.Errorf("step %d (%s): %w", i+1, step.Name, err)
|
||||
}
|
||||
}
|
||||
klog.Info("All steps completed successfully")
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -5,19 +5,19 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
monov1alpha1 "undecided.project/monok8s/pkg/apis/monok8s/v1alpha1"
|
||||
"undecided.project/monok8s/pkg/kube"
|
||||
"github.com/spf13/cobra"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"k8s.io/cli-runtime/pkg/genericclioptions"
|
||||
"k8s.io/klog/v2"
|
||||
monov1alpha1 "undecided.project/monok8s/pkg/apis/monok8s/v1alpha1"
|
||||
"undecided.project/monok8s/pkg/kube"
|
||||
)
|
||||
|
||||
func NewCmdAgent(flags *genericclioptions.ConfigFlags) *cobra.Command {
|
||||
var namespace string
|
||||
cmd := &cobra.Command{
|
||||
Use: "agent",
|
||||
Use: "agent --env-file path",
|
||||
Short: "Watch OSUpgrade resources and do nothing for now",
|
||||
RunE: func(cmd *cobra.Command, _ []string) error {
|
||||
clients, err := kube.NewClients(flags)
|
||||
|
||||
@@ -81,6 +81,7 @@ Supported formats:
|
||||
rendered := templates.DefaultMonoKSConfig(vals)
|
||||
cfg = &rendered
|
||||
|
||||
klog.InfoS("starting init", "node", cfg.Spec.NodeName, "envFile", envFile)
|
||||
default:
|
||||
path, err := (config.Loader{}).ResolvePath(configPath)
|
||||
if err != nil {
|
||||
@@ -92,7 +93,7 @@ Supported formats:
|
||||
return err
|
||||
}
|
||||
cfg = loaded
|
||||
klog.InfoS("starting init", "config", path, "node", cfg.Spec.NodeName, "envFile", envFile)
|
||||
klog.InfoS("starting init", "node", cfg.Spec.NodeName, "config", path)
|
||||
}
|
||||
|
||||
runner := bootstrap.NewRunner(cfg)
|
||||
|
||||
11
clitools/pkg/node/agent.go
Normal file
11
clitools/pkg/node/agent.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package node
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
system "undecided.project/monok8s/pkg/system"
|
||||
)
|
||||
|
||||
func StartControlAgent(ctx context.Context, n *NodeContext) error {
|
||||
return system.EnsureServiceRunning(ctx, n.SystemRunner, "control-agent")
|
||||
}
|
||||
@@ -429,7 +429,7 @@ func ValidateRequiredImagesPresent(ctx context.Context, n *NodeContext) error {
|
||||
missing = append(missing, img)
|
||||
continue
|
||||
}
|
||||
klog.Infof("found image: %s", img)
|
||||
klog.V(4).Infof("found image: %s", img)
|
||||
}
|
||||
|
||||
if len(missing) > 0 {
|
||||
|
||||
Reference in New Issue
Block a user