Skip to content

Commit 19616e6

Browse files
committed
feat: add nerdctl configuration file creation and offline checks
- Add a function to create the nerdctl configuration file if it doesn't already exist - Specify the address and namespace in the newly created nerdctl configuration - Update the installation process to include the creation of the nerdctl configuration file - Introduce an offline installation check in the joinNode function for cluster management Signed-off-by: ysicing <i@ysicing.me>
1 parent 5ff1633 commit 19616e6

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

hack/manifests/scripts/node.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,26 @@ service_enable_and_start() {
105105
return 0
106106
}
107107
108+
# create nerdctl config
109+
create_nerdctl_file() {
110+
[ -d "/etc/nerdctl" ] || mkdir /etc/nerdctl
111+
file="/etc/nerdctl/nerdctl.toml"
112+
if [ -f "$file" ]; then
113+
file="/etc/nerdctl/z.nerdctl.toml"
114+
fi
115+
cat > "$file" <<EOF
116+
# $file
117+
address = "unix:///run/k3s/containerd/containerd.sock"
118+
namespace = "k8s.io"
119+
EOF
120+
}
121+
108122
# --- run the install process --
109123
{
110124
create_symlinks
111125
systemd_disable
112126
# check_docker
113127
# create_env_file
128+
create_nerdctl_file
114129
service_enable_and_start
115130
}

pkg/cluster/cluster.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,7 @@ func (c *Cluster) joinNode(ip string, master bool, cfg *config.Config, sshClient
413413
if err := sshClient.Copy(ip, tplSrc, tplDst); err != nil {
414414
return errors.Errorf("%s copy tpl (%s:%s->%s:%s) failed, reason: %v", t, cfg.Cluster.InitNode, tplSrc, ip, tplDst, err)
415415
}
416+
c.OffLine = cfg.Install.Type == "offline"
416417
if err := c.preinit(cfg.Cluster.InitNode, ip, sshClient); err != nil {
417418
return err
418419
}

0 commit comments

Comments
 (0)