Split action into kubectl
This commit is contained in:
33
clitools/pkg/node/kubectl.go
Normal file
33
clitools/pkg/node/kubectl.go
Normal file
@@ -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
|
||||||
|
}
|
||||||
@@ -8,15 +8,9 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"k8s.io/klog/v2"
|
|
||||||
|
|
||||||
system "example.com/monok8s/pkg/system"
|
system "example.com/monok8s/pkg/system"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
|
||||||
crdsPath = "/usr/lib/monok8s/crds/"
|
|
||||||
)
|
|
||||||
|
|
||||||
func StartKubelet(ctx context.Context, n *NodeContext) error {
|
func StartKubelet(ctx context.Context, n *NodeContext) error {
|
||||||
return system.EnsureServiceRunning(ctx, n.SystemRunner, "kubelet")
|
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
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user