diff --git a/cmd/k8e/main.go b/cmd/k8e/main.go index 60a79e37..3ac05bb2 100644 --- a/cmd/k8e/main.go +++ b/cmd/k8e/main.go @@ -48,6 +48,7 @@ func main() { cmds.NewCRICTL(externalCLIAction("crictl", dataDir)), cmds.NewCtrCommand(externalCLIAction("ctr", dataDir)), cmds.NewCheckConfigCommand(externalCLIAction("check-config", dataDir)), + cmds.NewInitOSConfigCommand(externalCLIAction("init-os-config", dataDir)), cmds.NewEtcdSnapshotCommand(etcdsnapshotCommand, cmds.NewEtcdSnapshotSubcommands( etcdsnapshotCommand, diff --git a/contrib/install.sh b/contrib/install.sh index ff35bf8e..fc6e5c92 100644 --- a/contrib/install.sh +++ b/contrib/install.sh @@ -514,7 +514,8 @@ download_and_verify() { # --- check-config --- check_config() { - info "Checking k8e configuration" + info "init OS config && Checking k8e config" + $SUDO $BIN_DIR/k8e init-os $SUDO $BIN_DIR/k8e check-config } diff --git a/contrib/util/cilium-sysctlfix.sh b/contrib/util/cilium-sysctlfix.sh deleted file mode 100644 index 381e6fbe..00000000 --- a/contrib/util/cilium-sysctlfix.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/sh -set -e -set -o noglob - -# fix Ubuntu 20.04 systemd bug for rp_filter sysctl setting - -# --- helper functions for logs --- -info() -{ - echo '[INFO] ' "$@" -} -warn() -{ - echo '[WARN] ' "$@" >&2 -} -fatal() -{ - echo '[ERROR] ' "$@" >&2 - exit 1 -} - - -# --- sysctl fix for rp_filter --- -do_cilium_sysctlfix() { - info "Fixing rp_filter sysctl setting for Cilium on Ubuntu 20.04" - if [ -f /etc/sysctl.d/99-zzz-override_cilium.conf ]; then - warn "File /etc/sysctl.d/99-zzz-override_cilium.conf already exists" - return - fi - cat > /etc/sysctl.d/99-zzz-override_cilium.conf < /etc/modules-load.d/kube_proxy-ipvs.conf fi sysctl -p -sed -i ':a;$!{N;ba};s@# kubekey hosts BEGIN.*# kubekey hosts END@@' /etc/hosts -sed -i '/^$/N;/\n$/N;//D' /etc/hosts -cat >>/etc/hosts< /proc/sys/vm/drop_caches # Make sure the iptables utility doesn't use the nftables backend. update-alternatives --set iptables /usr/sbin/iptables-legacy >/dev/null 2>&1 || true diff --git a/hack/package-cli b/hack/package-cli index d014fb76..90fc6847 100755 --- a/hack/package-cli +++ b/hack/package-cli @@ -13,6 +13,7 @@ for i in crictl kubectl k8e-agent k8e-server k8e-etcd-snapshot k8e-secrets-encry done cp contrib/util/check-config.sh bin/check-config +cp contrib/util/init-os-config.sh bin/init-os-config rm -rf build/data mkdir -p build/data build/out diff --git a/pkg/cli/cmds/check-config.go b/pkg/cli/cmds/check-config.go index ead97e47..5484b384 100644 --- a/pkg/cli/cmds/check-config.go +++ b/pkg/cli/cmds/check-config.go @@ -13,3 +13,13 @@ func NewCheckConfigCommand(action func(*cli.Context) error) cli.Command { Action: action, } } + +func NewInitOSConfigCommand(action func(*cli.Context) error) cli.Command { + return cli.Command{ + Name: "init-os-config", + Usage: "Initialize OS configuration", + SkipFlagParsing: true, + SkipArgReorder: true, + Action: action, + } +}