commit a14fa23e7ae896f53f9a13cb3b8d6f4354c54c72dd302161d980460581647ede
| author | 斟酌 鵬兄 <tgckpg@gmail.com> |
| date | 2026-04-02T19:26:39Z |
| subject | Split action into kubectl |
commit a14fa23e7ae896f53f9a13cb3b8d6f4354c54c72dd302161d980460581647ede
Author: 斟酌 鵬兄 <tgckpg@gmail.com>
Date: 2026-04-02T19:26:39Z
Split action into kubectl
---
clitools/pkg/node/kubectl.go | 33 +++++++++++++++++++++++++++++++++
clitools/pkg/node/kubelet.go | 25 -------------------------
2 files changed, 33 insertions(+), 25 deletions(-)
diff --git a/clitools/pkg/node/kubectl.go b/clitools/pkg/node/kubectl.go
new file mode 100644
index 0000000..6c25223
--- /dev/null
+++ b/clitools/pkg/node/kubectl.go
@@ -0,0 +1,33 @@
+package node
+
+import (
+ "context"
+ "time"
+
+ "k8s.io/klog/v2"
+
+ system "example.com/monok8s/pkg/system"
+)
+
+const (
+ crdsPath = "/usr/lib/monok8s/crds/"
+)
+
+func ApplyCRDs(ctx context.Context, nctx *NodeContext) error {
+ if nctx.Config.Spec.ClusterRole != "control-plane" {
+ return nil
+ }
+
+ _, err := nctx.SystemRunner.RunWithOptions(
+ ctx,
+ "kubectl",
+ []string{"--kubeconfig", adminKubeconfigPath, "apply", "-f", crdsPath},
+ system.RunOptions{
+ Timeout: 10 * time.Minute,
+ OnStdoutLine: func(line string) { klog.Infof("[kubectl] %s", line) },
+ OnStderrLine: func(line string) { klog.Infof("[kubectl] %s", line) },
+ },
+ )
+
+ return err
+}
diff --git a/clitools/pkg/node/kubelet.go b/clitools/pkg/node/kubelet.go
index 725f147..08334ae 100644
--- a/clitools/pkg/node/kubelet.go
+++ b/clitools/pkg/node/kubelet.go
@@ -8,15 +8,9 @@ import (
"strings"
"time"
- "k8s.io/klog/v2"
-
system "example.com/monok8s/pkg/system"
)
-const (
- crdsPath = "/usr/lib/monok8s/crds/"
-)
-
func StartKubelet(ctx context.Context, n *NodeContext) error {
return system.EnsureServiceRunning(ctx, n.SystemRunner, "kubelet")
}
@@ -53,22 +47,3 @@ func waitForKubeletHealthy(ctx context.Context, timeout time.Duration) error {
}
}
}
-
-func ApplyCRDs(ctx context.Context, nctx *NodeContext) error {
- if nctx.Config.Spec.ClusterRole != "control-plane" {
- return nil
- }
-
- _, err := nctx.SystemRunner.RunWithOptions(
- ctx,
- "kubectl",
- []string{"apply", "-f", crdsPath},
- system.RunOptions{
- Timeout: 10 * time.Minute,
- OnStdoutLine: func(line string) { klog.Infof("[kubectl] %s", line) },
- OnStderrLine: func(line string) { klog.Infof("[kubectl] %s", line) },
- },
- )
-
- return err
-}