Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: clean binary layout and gomod tidy #377

Merged
merged 1 commit into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ https://getk8e.com/docs/install/200-quick-start/

Acknowledgments
--------------
- Thanks [k3s](https://github.com/rancher/k3s) for the great open source project.
- Thanks [k3s](https://github.com/k3s-io/k3s) for the great open source project.
2 changes: 1 addition & 1 deletion contrib/util/check-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ set -e

EXITCODE=0

# rancher/k3s modified from
# modified from
# https://github.com/moby/moby/blob/c831882/contrib/check-config.sh

# bits of this were adapted from lxc-checkconfig for moby
Expand Down
4 changes: 2 additions & 2 deletions contrib/util/generate-custom-ca-certs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
# This script will generate files sufficient to bootstrap K8e cluster certificate
# authorities. By default, the script will create the required files under
# /var/lib/rancher/k8e/server/tls, where they will be found and used by K8e during initial
# /var/lib/k8e/server/tls, where they will be found and used by K8e during initial
# cluster startup. Note that these files MUST be present before K8e is started the first
# time; certificate data SHOULD NOT be changed once the cluster has been initialized.
#
Expand Down Expand Up @@ -153,7 +153,7 @@ echo "CA certificate generation complete. Required files are now present in: ${D
echo "For security purposes, you should make a secure copy of the following files and remove them from cluster members:"
ls ${DATA_DIR}/server/tls/root-ca.* ${DATA_DIR}/server/tls/intermediate-ca.* | xargs -n1 echo -e "\t"

if [ "${DATA_DIR}" != "/var/lib/rancher/${PRODUCT}" ]; then
if [ "${DATA_DIR}" != "/var/lib/${PRODUCT}" ]; then
echo
echo "To update certificates on an existing cluster, you may now run:"
echo " k8e certificate rotate-ca --path=${DATA_DIR}/server"
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ require (
github.com/containerd/fuse-overlayfs-snapshotter v1.0.8
github.com/containerd/stargz-snapshotter v0.15.1
github.com/containerd/zfs v1.1.0
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e
github.com/coreos/go-systemd/v22 v22.5.0
github.com/docker/docker v27.1.1+incompatible
github.com/erikdubbelboer/gspt v0.0.0-20190125194910-e68493906b83
Expand Down
1 change: 0 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,6 @@ github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3Ee
github.com/coreos/go-semver v0.3.1 h1:yi21YpKnrx1gt5R+la8n5WgS0kCrsPp33dmEyHReZr4=
github.com/coreos/go-semver v0.3.1/go.mod h1:irMmmIw/7yzSRPWryHsK7EYSg09caPQL03VsM8rvUec=
github.com/coreos/go-systemd v0.0.0-20181012123002-c6f51f82210d/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e h1:Wf6HqHfScWJN9/ZjdUKyjop4mf3Qdd+1TvvltAvM3m8=
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
github.com/coreos/go-systemd/v22 v22.1.0/go.mod h1:xO0FLkIi5MaZafQlIrOotqXZ90ih+1atmu1JpKERPPk=
github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
Expand Down
10 changes: 5 additions & 5 deletions pkg/agent/containerd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import (
"strings"

"github.com/containerd/containerd/remotes/docker"
"github.com/rancher/wharfie/pkg/registries"
"github.com/sirupsen/logrus"
"github.com/xiaods/k8e/pkg/agent/templates"
util2 "github.com/xiaods/k8e/pkg/agent/util"
"github.com/xiaods/k8e/pkg/daemons/config"
"github.com/xiaods/k8e/pkg/spegel"
"github.com/xiaods/k8e/pkg/version"
"github.com/rancher/wharfie/pkg/registries"
"github.com/sirupsen/logrus"
)

type HostConfigs map[string]templates.HostConfig
Expand Down Expand Up @@ -71,7 +71,7 @@ func writeContainerdHosts(cfg *config.Node, containerdConfig templates.Container
}

// cleanContainerdHosts removes any registry host config dirs containing a hosts.toml file
// with a header that indicates it was created by k3s, or directories where a hosts.toml
// with a header that indicates it was created by k8e, or directories where a hosts.toml
// is about to be written. Unmanaged directories not containing this file, or containing
// a file without the header, are left alone.
func cleanContainerdHosts(dir string, hosts HostConfigs) error {
Expand All @@ -81,7 +81,7 @@ func cleanContainerdHosts(dir string, hosts HostConfigs) error {
os.RemoveAll(hostsDir)
}

// clean directories that contain a hosts.toml with a header indicating it was created by k3s
// clean directories that contain a hosts.toml with a header indicating it was created by k8e
ents, err := os.ReadDir(dir)
if err != nil && !os.IsNotExist(err) {
return err
Expand Down Expand Up @@ -285,4 +285,4 @@ func endpointHasConfig(ep *templates.RegistryEndpoint) bool {
return ep.OverridePath || ep.Config.Auth != nil || ep.Config.TLS != nil || len(ep.Rewrites) > 0
}
return false
}
}
8 changes: 4 additions & 4 deletions pkg/cli/cmds/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,13 +197,13 @@ var (
Name: "image-credential-provider-bin-dir",
Usage: "(agent/node) The path to the directory where credential provider plugin binaries are located",
Destination: &AgentConfig.ImageCredProvBinDir,
Value: "/var/lib/rancher/credentialprovider/bin",
Value: "/var/lib/k8e/credentialprovider/bin",
}
ImageCredProvConfigFlag = &cli.StringFlag{
Name: "image-credential-provider-config",
Usage: "(agent/node) The path to the credential provider plugin config file",
Destination: &AgentConfig.ImageCredProvConfig,
Value: "/var/lib/rancher/credentialprovider/config.yaml",
Value: "/var/lib/k8e/credentialprovider/config.yaml",
}
DisableAgentLBFlag = &cli.BoolFlag{
Name: "disable-apiserver-lb",
Expand Down Expand Up @@ -259,7 +259,7 @@ func NewAgentCommand(action func(ctx *cli.Context) error) cli.Command {
Name: "data-dir,d",
Usage: "(agent/data) Folder to hold state",
Destination: &AgentConfig.DataDir,
Value: "/var/lib/rancher/" + version.Program + "",
Value: "/var/lib/" + version.Program + "",
EnvVar: version.ProgramUpper + "_DATA_DIR",
},
NodeNameFlag,
Expand Down Expand Up @@ -301,4 +301,4 @@ func NewAgentCommand(action func(ctx *cli.Context) error) cli.Command {
DisableAgentLBFlag,
},
}
}
}
8 changes: 4 additions & 4 deletions pkg/cli/cmds/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"sync"
"time"

"github.com/xiaods/k8e/pkg/version"
"github.com/urfave/cli"
"github.com/xiaods/k8e/pkg/version"
)

const (
Expand Down Expand Up @@ -36,7 +36,7 @@ type Server struct {
ClusterDomain string
// The port which kubectl clients can access k8s
HTTPSPort int
// The port which custom k3s API runs on
// The port which custom k8e API runs on
SupervisorPort int
// The port which kube-apiserver runs on
APIServerPort int
Expand Down Expand Up @@ -110,7 +110,7 @@ var (
ServerConfig Server
DataDirFlag = &cli.StringFlag{
Name: "data-dir,d",
Usage: "(data) Folder to hold state default /var/lib/rancher/" + version.Program + " or ${HOME}/.rancher/" + version.Program + " if not root",
Usage: "(data) Folder to hold state default /var/lib/" + version.Program + " or ${HOME}/.rancher/" + version.Program + " if not root",
Destination: &ServerConfig.DataDir,
EnvVar: version.ProgramUpper + "_DATA_DIR",
}
Expand Down Expand Up @@ -553,4 +553,4 @@ func NewServerCommand(action func(*cli.Context) error) cli.Command {
Action: action,
Flags: ServerFlags,
}
}
}
4 changes: 2 additions & 2 deletions pkg/cli/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"github.com/xiaods/k8e/pkg/daemons/config"
"github.com/xiaods/k8e/pkg/datadir"
"github.com/xiaods/k8e/pkg/etcd"
k3smetrics "github.com/xiaods/k8e/pkg/metrics"
k8emetrics "github.com/xiaods/k8e/pkg/metrics"
"github.com/xiaods/k8e/pkg/proctitle"
"github.com/xiaods/k8e/pkg/profile"
"github.com/xiaods/k8e/pkg/rootless"
Expand Down Expand Up @@ -553,7 +553,7 @@ func run(app *cli.Context, cfg *cmds.Server, leaderControllers server.CustomCont
}

// same deal for metrics - these are not used if the extra metrics listener is not enabled.
metrics := k3smetrics.DefaultMetrics
metrics := k8emetrics.DefaultMetrics
metrics.Router = func(ctx context.Context, nodeConfig *config.Node) (*mux.Router, error) {
return https.Start(ctx, nodeConfig, serverConfig.ControlConfig.Runtime)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/nodeconfig/nodeconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func getNodeEnv() (string, error) {
return string(k8eEnvJSON), nil
}

// SetNodeConfigAnnotations stores a redacted version of the k3s cli args and
// SetNodeConfigAnnotations stores a redacted version of the k8e cli args and
// environment variables as annotations on the node object. It also stores a
// hash of the combined args + variables. These are used by other components
// to determine if the node configuration has been changed.
Expand Down
2 changes: 1 addition & 1 deletion pkg/rootless/mounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func setupMounts(stateDir string) error {
{"/var/lib/cni", filepath.Join(stateDir, "cni")},
{"/var/lib/kubelet", filepath.Join(stateDir, "kubelet")},
{"/etc/rancher", filepath.Join(stateDir, "etc", "rancher")},
{"/run/k3s/containerd", filepath.Join(runDir, "k3s", "containerd")},
{"/run/k8e/containerd", filepath.Join(runDir, "k8e", "containerd")},
}

for _, v := range mountMap {
Expand Down
22 changes: 11 additions & 11 deletions pkg/rootless/rootless.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@ import (
)

var (
pipeFD = "_K3S_ROOTLESS_FD"
childEnv = "_K3S_ROOTLESS_SOCK"
evacuateCgroup2Env = "_K3S_ROOTLESS_EVACUATE_CGROUP2" // boolean
pipeFD = "_K8E_ROOTLESS_FD"
childEnv = "_K8E_ROOTLESS_SOCK"
evacuateCgroup2Env = "_K8E_ROOTLESS_EVACUATE_CGROUP2" // boolean
Sock = ""

mtuEnv = "K3S_ROOTLESS_MTU"
cidrEnv = "K3S_ROOTLESS_CIDR"
enableIPv6Env = "K3S_ROOTLESS_ENABLE_IPV6"
portDriverEnv = "K3S_ROOTLESS_PORT_DRIVER"
disableLoopbackEnv = "K3S_ROOTLESS_DISABLE_HOST_LOOPBACK"
copyUpDirsEnv = "K3S_ROOTLESS_COPYUPDIRS"
mtuEnv = "K8E_ROOTLESS_MTU"
cidrEnv = "K8E_ROOTLESS_CIDR"
enableIPv6Env = "K8E_ROOTLESS_ENABLE_IPV6"
portDriverEnv = "K8E_ROOTLESS_PORT_DRIVER"
disableLoopbackEnv = "K8E_ROOTLESS_DISABLE_HOST_LOOPBACK"
copyUpDirsEnv = "K8E_ROOTLESS_COPYUPDIRS"
)

func Rootless(stateDir string, enableIPv6 bool) error {
Expand Down Expand Up @@ -152,9 +152,9 @@ func createParentOpt(driver portDriver, stateDir string, enableIPv6 bool) (*pare
} else {
selfCgroup2Dir := filepath.Join("/sys/fs/cgroup", selfCgroup2)
if unix.Access(selfCgroup2Dir, unix.W_OK) == nil {
opt.EvacuateCgroup2 = "k3s_evac"
opt.EvacuateCgroup2 = "k8e_evac"
} else {
logrus.Warn("Cannot set cgroup2 evacuation, make sure to run k3s as a systemd unit")
logrus.Warn("Cannot set cgroup2 evacuation, make sure to run k8e as a systemd unit")
}
}

Expand Down
Loading
Loading