2022-03-02 23:47:27 +00:00
|
|
|
//go:build windows
|
2021-06-10 19:27:00 +00:00
|
|
|
// +build windows
|
|
|
|
|
|
|
|
package agent
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io/ioutil"
|
|
|
|
"os"
|
|
|
|
"path/filepath"
|
|
|
|
|
2022-03-02 23:47:27 +00:00
|
|
|
"github.com/k3s-io/k3s/pkg/cli/cmds"
|
|
|
|
"github.com/k3s-io/k3s/pkg/daemons/config"
|
2021-06-10 19:27:00 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
containerdSock = "npipe:////./pipe/containerd-containerd"
|
|
|
|
)
|
|
|
|
|
|
|
|
// setupCriCtlConfig creates the crictl config file and populates it
|
|
|
|
// with the given data from config.
|
|
|
|
func setupCriCtlConfig(cfg cmds.Agent, nodeConfig *config.Node) error {
|
|
|
|
cre := nodeConfig.ContainerRuntimeEndpoint
|
2022-04-20 21:13:29 +00:00
|
|
|
if cre == "" {
|
2021-06-10 19:27:00 +00:00
|
|
|
cre = containerdSock
|
|
|
|
}
|
2022-04-20 21:13:29 +00:00
|
|
|
|
2021-06-10 19:27:00 +00:00
|
|
|
agentConfDir := filepath.Join(cfg.DataDir, "agent", "etc")
|
|
|
|
if _, err := os.Stat(agentConfDir); os.IsNotExist(err) {
|
|
|
|
if err := os.MkdirAll(agentConfDir, 0700); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
crp := "runtime-endpoint: " + cre + "\n"
|
|
|
|
return ioutil.WriteFile(filepath.Join(agentConfDir, "crictl.yaml"), []byte(crp), 0600)
|
|
|
|
}
|