From a284d12300e579f430d88d78bc7bad0b02543ec0 Mon Sep 17 00:00:00 2001 From: Brad Davidson Date: Tue, 1 Nov 2022 23:28:19 +0000 Subject: [PATCH] Bump k3s-root and remove embedded strongswan support Signed-off-by: Brad Davidson --- pkg/agent/config/config.go | 1 - pkg/agent/flannel/setup.go | 38 +++++-------------------------------- pkg/daemons/config/types.go | 1 - scripts/version.sh | 2 +- 4 files changed, 6 insertions(+), 36 deletions(-) diff --git a/pkg/agent/config/config.go b/pkg/agent/config/config.go index 62ad5c9e3557..b46ed7568d58 100644 --- a/pkg/agent/config/config.go +++ b/pkg/agent/config/config.go @@ -461,7 +461,6 @@ func get(ctx context.Context, envInfo *cmds.Agent, proxy proxy.Proxy) (*config.N } nodeConfig.AgentConfig.Snapshotter = envInfo.Snapshotter nodeConfig.AgentConfig.IPSECPSK = controlConfig.IPSECPSK - nodeConfig.AgentConfig.StrongSwanDir = filepath.Join(envInfo.DataDir, "agent", "strongswan") nodeConfig.Containerd.Config = filepath.Join(envInfo.DataDir, "agent", "etc", "containerd", "config.toml") nodeConfig.Containerd.Root = filepath.Join(envInfo.DataDir, "agent", "containerd") nodeConfig.CRIDockerd.Root = filepath.Join(envInfo.DataDir, "agent", "cri-dockerd") diff --git a/pkg/agent/flannel/setup.go b/pkg/agent/flannel/setup.go index ff7ee21bb2e3..b82fa630d599 100644 --- a/pkg/agent/flannel/setup.go +++ b/pkg/agent/flannel/setup.go @@ -4,13 +4,12 @@ import ( "context" "fmt" "net" - "os" + "os/exec" "path/filepath" "strings" "github.com/k3s-io/k3s/pkg/agent/util" "github.com/k3s-io/k3s/pkg/daemons/config" - "github.com/k3s-io/k3s/pkg/version" "github.com/pkg/errors" "github.com/sirupsen/logrus" v1 "k8s.io/api/core/v1" @@ -230,12 +229,13 @@ func createFlannelConf(nodeConfig *config.Node) error { backendConf = hostGWBackend case config.FlannelBackendIPSEC: backendConf = strings.ReplaceAll(ipsecBackend, "%psk%", nodeConfig.AgentConfig.IPSECPSK) - if err := setupStrongSwan(nodeConfig); err != nil { - return err + if _, err := exec.LookPath("swanctl"); err != nil { + return errors.Wrap(err, "k3s no longer includes swanctl - please install the strongswan package on your host") } + logrus.Warnf("The ipsec backend is deprecated and will be removed in k3s v1.27; please switch to wireguard-native. Check our docs for information on how to migrate.") case config.FlannelBackendWireguard: backendConf = strings.ReplaceAll(wireguardBackend, "%flannelConfDir%", filepath.Dir(nodeConfig.FlannelConfFile)) - logrus.Warnf("The wireguard backend is deprecated and will be removed in k3s v1.26, please switch to wireguard-native. Check our docs for information about how to migrate") + logrus.Warnf("The wireguard backend is deprecated and will be removed in k3s v1.26, please switch to wireguard-native. Check our docs for information about how to migrate.") case config.FlannelBackendWireguardNative: mode, ok := backendOptions["Mode"] if !ok { @@ -256,34 +256,6 @@ func createFlannelConf(nodeConfig *config.Node) error { return util.WriteFile(nodeConfig.FlannelConfFile, confJSON) } -func setupStrongSwan(nodeConfig *config.Node) error { - // if data dir env is not set point to root - dataDir := os.Getenv(version.ProgramUpper + "_DATA_DIR") - if dataDir == "" { - dataDir = "/" - } - dataDir = filepath.Join(dataDir, "etc", "strongswan") - - info, err := os.Lstat(nodeConfig.AgentConfig.StrongSwanDir) - // something exists but is not a symlink, return - if err == nil && info.Mode()&os.ModeSymlink == 0 { - return nil - } - if err == nil { - target, err := os.Readlink(nodeConfig.AgentConfig.StrongSwanDir) - // current link is the same, return - if err == nil && target == dataDir { - return nil - } - } - - // clean up strongswan old link - os.Remove(nodeConfig.AgentConfig.StrongSwanDir) - - // make new strongswan link - return os.Symlink(dataDir, nodeConfig.AgentConfig.StrongSwanDir) -} - // fundNetMode returns the mode (ipv4, ipv6 or dual-stack) in which flannel is operating func findNetMode(cidrs []*net.IPNet) (int, error) { dualStack, err := utilsnet.IsDualStackCIDRs(cidrs) diff --git a/pkg/daemons/config/types.go b/pkg/daemons/config/types.go index 1a7965acd65f..4df9ed9c8605 100644 --- a/pkg/daemons/config/types.go +++ b/pkg/daemons/config/types.go @@ -112,7 +112,6 @@ type Agent struct { ImageCredProvConfig string IPSECPSK string FlannelCniConfFile string - StrongSwanDir string PrivateRegistry string SystemDefaultRegistry string AirgapExtraRegistry []string diff --git a/scripts/version.sh b/scripts/version.sh index d955d965f5dc..4fe601fadaf7 100755 --- a/scripts/version.sh +++ b/scripts/version.sh @@ -48,7 +48,7 @@ fi VERSION_CNIPLUGINS="v1.1.1-k3s1" -VERSION_ROOT="v0.11.0" +VERSION_ROOT="v0.12.0-rc.0" if [[ -n "$GIT_TAG" ]]; then if [[ ! "$GIT_TAG" =~ ^"$VERSION_K8S"[+-] ]]; then