sealer icon indicating copy to clipboard operation
sealer copied to clipboard

在使用具有sudo权限的用户运行sudo sealer run遇到错误

Open Tesladw opened this issue 2 years ago • 1 comments

What happen?

在使用具有sudo权限的用户运行sudo sealer run遇到错误

Relevant log output?

[duwei@master0 ~]$ sudo sealer run kubernetes:v1.24.3 --masters 172.31.4.15  --nodes 172.31.4.14 --user duwei  --passwd @wer -d
2022-08-10 21:09:48 [INFO] [local.go:287] Start to create a new cluster: master [172.31.4.15], worker [172.31.4.14]
2022-08-10 21:09:48 [DEBUG] [default_image.go:75] image kubernetes:v1.24.3 already exists
2022-08-10 21:09:48 [DEBUG] [default_image.go:75] image kubernetes:v1.24.3 already exists
2022-08-10 21:09:48 [DEBUG] [default_image.go:75] image kubernetes:v1.24.3 already exists
2022-08-10 21:09:48 [DEBUG] [overlay2.go:103] mount data : index=off,lowerdir=/var/lib/sealer/data/overlay2/59927e67c5fa2be412428a395d328504559f57be187f89ec8805dd5fd6b1940c:/var/lib/sealer/data/overlay2/c54d906b90889d7b8afb8da40bcc757b4493da2c354add8bf7effd28c0ef297a:/var/lib/sealer/data/overlay2/2187e617561194667dc1d86e5e55a013f92315d5b1992f26fcbafd7276ef7408:/var/lib/sealer/data/overlay2/c04ed94e022d6df0a9108b448d887b9b8f61859beceeb27aa472c7496ee64e06:/var/lib/sealer/data/overlay2/8a62a5c4e272152dbc7fe8c6ce7c9211451d54177340942dce530a6abe201243:/var/lib/sealer/data/overlay2/21e7f74dc80203e021cb5c9e13efd3f2bd987a2fe7d1820006045918f8bdc421:/var/lib/sealer/data/overlay2/c4c150bb26ed69c71cd22d26465837f1d84ca7cdaf7d7a86ee187c4bc0d18a5f:/var/lib/sealer/data/overlay2/3b93c68a916d7b447f4a515b0ff9a6fdfb1322c64ede899bb6f7d19afe73b1f1,upperdir=/var/lib/sealer/data/my-cluster/mount/linux_amd64_/upper,workdir=/var/lib/sealer/data/my-cluster/mount/linux_amd64_/work
2022-08-10 21:09:48 [DEBUG] [registry.go:139] show registry info, IP: 172.31.4.15, Domain: sea.hub
2022-08-10 21:09:48 [DEBUG] [config.go:74] clusterfile config is empty!
2022-08-10 21:09:48 [DEBUG] [registry.go:139] show registry info, IP: 172.31.4.15, Domain: sea.hub
2022-08-10 21:09:48 [DEBUG] [registry.go:139] show registry info, IP: 172.31.4.15, Domain: sea.hub
2022-08-10 21:09:48 [DEBUG] [scp.go:145] remote copy files src /var/lib/sealer/data/my-cluster/mount/linux_amd64_/Kubefile to dst /var/lib/sealer/data/my-cluster/rootfs/Kubefile
2022-08-10 21:09:48 [DEBUG] [scp.go:142] local copy files src /var/lib/sealer/data/my-cluster/mount/linux_amd64_/Kubefile to dst /var/lib/sealer/data/my-cluster/rootfs/Kubefile
2022-08-10 21:09:48 [DEBUG] [scp.go:142] local copy files src /var/lib/sealer/data/my-cluster/mount/linux_amd64_/Metadata to dst /var/lib/sealer/data/my-cluster/rootfs/Metadata
2022-08-10 21:09:48 [DEBUG] [scp.go:142] local copy files src /var/lib/sealer/data/my-cluster/mount/linux_amd64_/README.md to dst /var/lib/sealer/data/my-cluster/rootfs/README.md
2022-08-10 21:09:48 [DEBUG] [scp.go:142] local copy files src /var/lib/sealer/data/my-cluster/mount/linux_amd64_/bin to dst /var/lib/sealer/data/my-cluster/rootfs/bin
2022-08-10 21:09:48 [DEBUG] [scp.go:142] local copy files src /var/lib/sealer/data/my-cluster/mount/linux_amd64_/cri to dst /var/lib/sealer/data/my-cluster/rootfs/cri
2022-08-10 21:09:48 [DEBUG] [scp.go:142] local copy files src /var/lib/sealer/data/my-cluster/mount/linux_amd64_/etc to dst /var/lib/sealer/data/my-cluster/rootfs/etc
2022-08-10 21:09:48 [DEBUG] [scp.go:142] local copy files src /var/lib/sealer/data/my-cluster/mount/linux_amd64_/images to dst /var/lib/sealer/data/my-cluster/rootfs/images
2022-08-10 21:09:48 [DEBUG] [scp.go:142] local copy files src /var/lib/sealer/data/my-cluster/mount/linux_amd64_/lib64 to dst /var/lib/sealer/data/my-cluster/rootfs/lib64
2022-08-10 21:09:48 [DEBUG] [scp.go:142] local copy files src /var/lib/sealer/data/my-cluster/mount/linux_amd64_/manifests to dst /var/lib/sealer/data/my-cluster/rootfs/manifests
2022-08-10 21:09:48 [DEBUG] [scp.go:142] local copy files src /var/lib/sealer/data/my-cluster/mount/linux_amd64_/scripts to dst /var/lib/sealer/data/my-cluster/rootfs/scripts
2022-08-10 21:09:48 [DEBUG] [scp.go:142] local copy files src /var/lib/sealer/data/my-cluster/mount/linux_amd64_/statics to dst /var/lib/sealer/data/my-cluster/rootfs/statics
2022-08-10 21:09:48 [DEBUG] [sshcmd.go:114] failed to execute command(sudo -E /bin/sh <<EOF
cd /var/lib/sealer/data/my-cluster/rootfs  && chmod +x scripts/* && cd scripts && bash init.sh /var/lib/docker sea.hub 5000
EOF) on host(172.31.4.15): error(failed to execute command(sudo -E /bin/sh <<EOF
cd /var/lib/sealer/data/my-cluster/rootfs  && chmod +x scripts/* && cd scripts && bash init.sh /var/lib/docker sea.hub 5000
EOF) on host(172.31.4.15): error(exit status 127))
Usage:
  sealer run [flags]

Examples:

create cluster to your bare metal server, appoint the iplist:
	sealer run kubernetes:v1.19.8 --masters 192.168.0.2,192.168.0.3,192.168.0.4 \
		--nodes 192.168.0.5,192.168.0.6,192.168.0.7 --passwd xxx

specify server SSH port :
  All servers use the same SSH port (default port: 22):
	sealer run kubernetes:v1.19.8 --masters 192.168.0.2,192.168.0.3,192.168.0.4 \
	--nodes 192.168.0.5,192.168.0.6,192.168.0.7 --port 24 --passwd xxx

  Different SSH port numbers exist:
	sealer run kubernetes:v1.19.8 --masters 192.168.0.2,192.168.0.3:23,192.168.0.4:24 \
	--nodes 192.168.0.5:25,192.168.0.6:25,192.168.0.7:27 --passwd xxx

create a cluster with custom environment variables:
	sealer run -e DashBoardPort=8443 mydashboard:latest  --masters 192.168.0.2,192.168.0.3,192.168.0.4 \
	--nodes 192.168.0.5,192.168.0.6,192.168.0.7 --passwd xxx


Flags:
      --cluster-name string   set cluster name (default "my-cluster")
      --cmd-args strings      set args for image cmd instruction
  -e, --env strings           set custom environment variables
  -h, --help                  help for run
  -m, --masters string        set count or IPList to masters
  -n, --nodes string          set count or IPList to nodes
  -p, --passwd string         set cloud provider or baremetal server password
      --pk string             set baremetal server private key (default "/root/.ssh/id_rsa")
      --pk-passwd string      set baremetal server private key password
      --port uint16           set the sshd service port number for the server (default port: 22) (default 22)
      --provider ALI_CLOUD    set infra provider, example ALI_CLOUD, the local server need ignore this
  -u, --user string           set baremetal server username (default "root")

Global Flags:
      --color string               set the log color mode, the possible values can be [never always] (default "always")
      --config string              config file of sealer tool (default is $HOME/.sealer.json)
  -d, --debug                      turn on debug mode
      --hide-path                  hide the log path
      --hide-time                  hide the log time
      --log-to-file                write log message to disk
  -q, --quiet                      silence the usage when fail
      --remote-logger-url string   remote logger url, if not empty, will send log to this url
      --task-name string           task name which will embedded in the remote logger header, only valid when --remote-logger-url is set

2022-08-10 21:09:48 [ERROR] [root.go:70] sealer-v0.8.6: failed to mount rootfs(/var/lib/sealer/data/my-cluster/rootfs): failed to copy rootfs: failed to copy sub files: failed to new sftp client of host(172.31.4.14): failed to execute cmd(grep -oP "Subsystem\s+sftp\s+\K.*" /etc/ssh/sshd_config): Process exited with status 2

What you expected to happen?

No response

How to reproduce it (as minimally and precisely as possible)?

2022-08-10 21:09:48 [ERROR] [root.go:70] sealer-v0.8.6: failed to mount rootfs(/var/lib/sealer/data/my-cluster/rootfs): failed to copy rootfs: failed to copy sub files: failed to new sftp client of host(172.31.4.14): failed to execute cmd(grep -oP "Subsystem\s+sftp\s+\K.*" /etc/ssh/sshd_config): Process exited with status 2

Anything else we need to know?

单节点(镜像和sealer所在的节点)不报错可以正常部署,问题就出在远程节点

What is the version of Sealer you using?

v0.8.6

What is your OS environment?

CentOS Linux release 7.9.2009

What is the Kernel version?

Linux master0 3.10.0-1160.el7.x86_64 CentOS Linux release 7.9.2009

Other environment you want to tell us?

kubernetes:v1.24.3 用户具有sudo 权限 防火箱 selinux 都关了

Tesladw avatar Aug 11 '22 01:08 Tesladw

You can execute this command to see more information!

sudo -E /bin/sh <<EOF cd /var/lib/sealer/data/my-cluster/rootfs && chmod +x scripts/* && cd scripts && bash init.sh /var/lib/docker sea.hub 5000

Stevent-fei avatar Aug 11 '22 03:08 Stevent-fei