34 lines
652 B
Go
34 lines
652 B
Go
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
|
|
}
|