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
|
||||
}
|
||||
Reference in New Issue
Block a user