mirror of
https://github.com/k3s-io/k3s.git
synced 2024-06-07 19:41:36 +00:00
get build on windows and get api_server to work
This commit is contained in:
parent
522e08872a
commit
2346ccc63f
15
pkg/agent/containerd/command.go
Normal file
15
pkg/agent/containerd/command.go
Normal file
@ -0,0 +1,15 @@
|
||||
// +build !windows
|
||||
|
||||
package containerd
|
||||
|
||||
import (
|
||||
"os/exec"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
func addDeathSig(cmd *exec.Cmd) {
|
||||
// not supported in this OS
|
||||
cmd.SysProcAttr = &syscall.SysProcAttr{
|
||||
Pdeathsig: syscall.SIGKILL,
|
||||
}
|
||||
}
|
7
pkg/agent/containerd/command_windows.go
Normal file
7
pkg/agent/containerd/command_windows.go
Normal file
@ -0,0 +1,7 @@
|
||||
package containerd
|
||||
|
||||
import "os/exec"
|
||||
|
||||
func addDeathSig(_ *exec.Cmd) {
|
||||
// not supported in this OS
|
||||
}
|
@ -8,7 +8,6 @@ import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/containerd/containerd"
|
||||
@ -66,9 +65,7 @@ func Run(ctx context.Context, cfg *config.Node) error {
|
||||
cmd := exec.Command(args[0], args[1:]...)
|
||||
cmd.Stdout = stdOut
|
||||
cmd.Stderr = stdErr
|
||||
cmd.SysProcAttr = &syscall.SysProcAttr{
|
||||
Pdeathsig: syscall.SIGKILL,
|
||||
}
|
||||
addDeathSig(cmd)
|
||||
if err := cmd.Run(); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "containerd: %s\n", err)
|
||||
}
|
||||
|
10
pkg/agent/netpol/netpol_windows.go
Normal file
10
pkg/agent/netpol/netpol_windows.go
Normal file
@ -0,0 +1,10 @@
|
||||
package netpol
|
||||
|
||||
import (
|
||||
"context"
|
||||
daemonconfig "github.com/rancher/k3s/pkg/daemons/config"
|
||||
)
|
||||
|
||||
func Run(ctx context.Context, nodeConfig *daemonconfig.Node) error{
|
||||
panic("Netpol is not supported on windows ensure to pass --disable-network-policy")
|
||||
}
|
@ -1,3 +1,5 @@
|
||||
// +build !windows
|
||||
|
||||
package netpol
|
||||
|
||||
import (
|
||||
|
@ -1,6 +1,8 @@
|
||||
// Apache License v2.0 (copyright Cloud Native Labs & Rancher Labs)
|
||||
// - modified from https://github.com/cloudnativelabs/kube-router/blob/d6f9f31a7b/pkg/controllers/netpol/network_policy_controller.go
|
||||
|
||||
// +build !windows
|
||||
|
||||
package netpol
|
||||
|
||||
import (
|
||||
|
@ -1,6 +1,8 @@
|
||||
// Apache License v2.0 (copyright Cloud Native Labs & Rancher Labs)
|
||||
// - modified from https://github.com/cloudnativelabs/kube-router/tree/d6f9f31a7b/pkg/utils
|
||||
|
||||
// +build !windows
|
||||
|
||||
package netpol
|
||||
|
||||
import (
|
||||
|
@ -1,3 +1,5 @@
|
||||
// +build !windows
|
||||
|
||||
package syssetup
|
||||
|
||||
import (
|
||||
|
3
pkg/agent/syssetup/setup_windows.go
Normal file
3
pkg/agent/syssetup/setup_windows.go
Normal file
@ -0,0 +1,3 @@
|
||||
package syssetup
|
||||
|
||||
func Configure() {}
|
@ -8,6 +8,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/rancher/k3s/pkg/token"
|
||||
"github.com/rancher/k3s/pkg/util"
|
||||
)
|
||||
|
||||
type entry struct {
|
||||
@ -141,7 +142,7 @@ func writePasswords(passwdFile string, records [][]string) error {
|
||||
}
|
||||
defer out.Close()
|
||||
|
||||
if err := out.Chmod(0600); err != nil {
|
||||
if err := util.SetFileModeForFile(out, 0600); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
// +build !windows
|
||||
|
||||
package rootless
|
||||
|
||||
import (
|
||||
|
@ -1,3 +1,5 @@
|
||||
// +build !windows
|
||||
|
||||
package rootless
|
||||
|
||||
import (
|
||||
|
9
pkg/rootless/rootless_windows.go
Normal file
9
pkg/rootless/rootless_windows.go
Normal file
@ -0,0 +1,9 @@
|
||||
package rootless
|
||||
|
||||
import (
|
||||
)
|
||||
|
||||
|
||||
func Rootless(stateDir string) error {
|
||||
panic("Rootless not supported on windows")
|
||||
}
|
@ -1,3 +1,5 @@
|
||||
// +build !windows
|
||||
|
||||
package rootlessports
|
||||
|
||||
import (
|
||||
|
10
pkg/rootlessports/controller_windows.go
Normal file
10
pkg/rootlessports/controller_windows.go
Normal file
@ -0,0 +1,10 @@
|
||||
package rootlessports
|
||||
|
||||
import (
|
||||
"context"
|
||||
coreClients "github.com/rancher/wrangler-api/pkg/generated/controllers/core/v1"
|
||||
)
|
||||
|
||||
func Register(ctx context.Context, serviceController coreClients.ServiceController, httpsPort int) error {
|
||||
panic("Rootless is not supported on windows")
|
||||
}
|
@ -24,6 +24,7 @@ import (
|
||||
"github.com/rancher/k3s/pkg/rootlessports"
|
||||
"github.com/rancher/k3s/pkg/servicelb"
|
||||
"github.com/rancher/k3s/pkg/static"
|
||||
"github.com/rancher/k3s/pkg/util"
|
||||
v1 "github.com/rancher/wrangler-api/pkg/generated/controllers/core/v1"
|
||||
"github.com/rancher/wrangler/pkg/leader"
|
||||
"github.com/rancher/wrangler/pkg/resolvehome"
|
||||
@ -263,12 +264,12 @@ func writeKubeConfig(certs string, config *Config) error {
|
||||
if config.ControlConfig.KubeConfigMode != "" {
|
||||
mode, err := strconv.ParseInt(config.ControlConfig.KubeConfigMode, 8, 0)
|
||||
if err == nil {
|
||||
os.Chmod(kubeConfig, os.FileMode(mode))
|
||||
util.SetFileModeForPath(kubeConfig, os.FileMode(mode))
|
||||
} else {
|
||||
logrus.Errorf("failed to set %s to mode %s: %v", kubeConfig, os.FileMode(mode), err)
|
||||
}
|
||||
} else {
|
||||
os.Chmod(kubeConfig, os.FileMode(0600))
|
||||
util.SetFileModeForPath(kubeConfig, os.FileMode(0600))
|
||||
}
|
||||
|
||||
if kubeConfigSymlink != kubeConfig {
|
||||
|
15
pkg/util/file.go
Normal file
15
pkg/util/file.go
Normal file
@ -0,0 +1,15 @@
|
||||
// +build !windows
|
||||
|
||||
package util
|
||||
|
||||
import (
|
||||
"os"
|
||||
)
|
||||
|
||||
func SetFileModeForPath(name string, mode os.FileMode) error {
|
||||
return os.Chmod(name, mode)
|
||||
}
|
||||
|
||||
func SetFileModeForFile(file *os.File, mode os.FileMode) error {
|
||||
return file.Chmod(mode)
|
||||
}
|
13
pkg/util/file_windows.go
Normal file
13
pkg/util/file_windows.go
Normal file
@ -0,0 +1,13 @@
|
||||
package util
|
||||
|
||||
import (
|
||||
"os"
|
||||
)
|
||||
|
||||
func SetFileModeForPath(name string, mode os.FileMode) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func SetFileModeForFile(file *os.File, mode os.FileMode) error {
|
||||
return nil
|
||||
}
|
Loading…
Reference in New Issue
Block a user