yunionio / service-images

Apache License 2.0
8 stars 10 forks source link

构建k8s镜像的问题 #23

Open guinanlin opened 10 months ago

guinanlin commented 10 months ago

构建k8s的镜像的时候, 有这么2个问题,还有一个疑问:

  1. 如下的 iso_url iso_checksum的原先地址已经做了更改, source可以改一下: `[root@test001 kubernetes]# pwd /root/service-images/kubernetes [root@test001 kubernetes]# cat k8s-centos-7.json { "builders": [{ "type": "qemu", "accelerator": "kvm", "qemuargs": [ ["-m", "2048M"], ["-smp", "cpus=1,maxcpus=16,cores=4"] ], "disk_interface": "virtio", "disk_compression": false, "disk_size": 30720, "format": "qcow2", "net_device": "virtio-net",

    "iso_url": "https://mirrors.aliyun.com/centos/7/isos/x86_64/CentOS-7-x86_64-Minimal-2009.iso",
    "iso_checksum": "07b94e6b1a0b0260b94c83d6bb76b26bf7a310dc78d7a9c7432809fb9bc6194a",
    "iso_checksum_type": "sha256",
    
    "vm_name": "k8s-centos7-base",
    "output_directory": "./_output/k8s",

    `

  2. 执行的时候,总是停在如下的位置过不去: Waiting for SSH to become available `[root@test001 service-images]# make k8s ./tools/build-image.sh ./kubernetes/k8s-centos-7.json qemu output will be in this color.

==> qemu: Retrieving ISO ==> qemu: Trying https://mirrors.aliyun.com/centos/7/isos/x86_64/CentOS-7-x86_64-Minimal-2009.iso ==> qemu: Trying https://mirrors.aliyun.com/centos/7/isos/x86_64/CentOS-7-x86_64-Minimal-2009.iso?checksum=sha256%3A07b94e6b1a0b0260b94c83d6bb76b26bf7a310dc78d7a9c7432809fb9bc6194a CentOS-7-x86_64-Minimal-2009.iso 973.00 MiB / 973.00 MiB [================================================================================================================================================================] 100.00% 3m52s ==> qemu: https://mirrors.aliyun.com/centos/7/isos/x86_64/CentOS-7-x86_64-Minimal-2009.iso?checksum=sha256%3A07b94e6b1a0b0260b94c83d6bb76b26bf7a310dc78d7a9c7432809fb9bc6194a => /root/service-images/packer_cache/d95e59a9419e542b55bdd04a34cb64705af752eb.iso ==> qemu: leaving retrieve loop for ISO ==> qemu: Creating hard drive... ==> qemu: Starting HTTP server on port 8037 ==> qemu: Found port for communicator (SSH, WinRM, etc): 4233. ==> qemu: Looking for available port between 5900 and 6000 on 0.0.0.0 ==> qemu: Starting VM, booting from CD-ROM qemu: The VM will be run headless, without a GUI. If you want to qemu: view the screen of the VM, connect via VNC without a password to qemu: vnc://0.0.0.0:5962 ==> qemu: Overriding defaults Qemu arguments with QemuArgs... ==> qemu: Waiting 5s for boot... ==> qemu: Connecting to VM via VNC (0.0.0.0:5962) ==> qemu: Typing the boot command over VNC... ==> qemu: Using ssh communicator to connect: 127.0.0.1 ==> qemu: Waiting for SSH to become available...`

  1. 这个如果要构建k8s的其他版本, 是不是只要改scripts/k8s/install-kubeadm.sh 里头的这个语句就可以 yum install --assumeyes bridge-utils conntrack-tools jq kubelet-1.14.1-0 kubeadm kubectl
guinanlin commented 10 months ago

关于第2个问题, 运行了很久,但是还是报错结束, 报错的日志为: `==> qemu: Importing GPG key 0x352C64E5: ==> qemu: Userid : "Fedora EPEL (7) epel@fedoraproject.org" ==> qemu: Fingerprint: 91e9 7d7c 4a5e 96f1 7f3e 888f 6a2f aea2 352c 64e5 ==> qemu: Package : epel-release-7-14.noarch (@epel-release) ==> qemu: From : /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 qemu: Running transaction check qemu: Running transaction test qemu: Transaction test succeeded qemu: Running transaction qemu: Installing : libnetfilter_cthelper-1.0.0-11.el7.x86_64 1/13 qemu: Installing : socat-1.7.3.2-2.el7.x86_64 2/13 qemu: Installing : libnetfilter_cttimeout-1.0.0-7.el7.x86_64 3/13 qemu: Installing : oniguruma-6.8.2-2.el7.x86_64 4/13 qemu: Installing : cri-tools-1.26.0-0.x86_64 5/13 qemu: Installing : libnetfilter_queue-1.0.2-2.el7_2.x86_64 6/13 qemu: Installing : conntrack-tools-1.4.4-7.el7.x86_64 7/13 qemu: Installing : kubernetes-cni-1.2.0-0.x86_64 8/13 qemu: Installing : kubelet-1.28.2-0.x86_64 9/13 qemu: Installing : kubectl-1.28.2-0.x86_64 10/13 qemu: Installing : kubeadm-1.28.2-0.x86_64 11/13 qemu: Installing : jq-1.6-2.el7.x86_64 12/13 qemu: Installing : bridge-utils-1.5-9.el7.x86_64 13/13 qemu: Verifying : kubectl-1.28.2-0.x86_64 1/13 qemu: Verifying : conntrack-tools-1.4.4-7.el7.x86_64 2/13 qemu: Verifying : libnetfilter_queue-1.0.2-2.el7_2.x86_64 3/13 qemu: Verifying : cri-tools-1.26.0-0.x86_64 4/13 qemu: Verifying : kubernetes-cni-1.2.0-0.x86_64 5/13 qemu: Verifying : bridge-utils-1.5-9.el7.x86_64 6/13 qemu: Verifying : kubelet-1.28.2-0.x86_64 7/13 qemu: Verifying : oniguruma-6.8.2-2.el7.x86_64 8/13 qemu: Verifying : jq-1.6-2.el7.x86_64 9/13 qemu: Verifying : libnetfilter_cttimeout-1.0.0-7.el7.x86_64 10/13 qemu: Verifying : socat-1.7.3.2-2.el7.x86_64 11/13 qemu: Verifying : libnetfilter_cthelper-1.0.0-11.el7.x86_64 12/13 qemu: Verifying : kubeadm-1.28.2-0.x86_64 13/13 qemu: qemu: Installed: qemu: bridge-utils.x86_64 0:1.5-9.el7 conntrack-tools.x86_64 0:1.4.4-7.el7 qemu: jq.x86_64 0:1.6-2.el7 kubeadm.x86_64 0:1.28.2-0 qemu: kubectl.x86_64 0:1.28.2-0 qemu: qemu: Dependency Installed: qemu: cri-tools.x86_64 0:1.26.0-0 qemu: kubelet.x86_64 0:1.28.2-0 qemu: kubernetes-cni.x86_64 0:1.2.0-0 qemu: libnetfilter_cthelper.x86_64 0:1.0.0-11.el7 qemu: libnetfilter_cttimeout.x86_64 0:1.0.0-7.el7 qemu: libnetfilter_queue.x86_64 0:1.0.2-2.el7_2 qemu: oniguruma.x86_64 0:6.8.2-2.el7 qemu: socat.x86_64 0:1.7.3.2-2.el7 qemu: qemu: Complete! ==> qemu: Provisioning with shell script: scripts/k8s/k8s-config.sh ==> qemu: modprobe: FATAL: Module nf_conntrack_ipv4 not found. ==> qemu: Deleting output directory... Build 'qemu' errored: Script exited with non-zero exit status: 1.Allowed exit codes are: [0]

==> Some builds didn't complete successfully and had errors: --> qemu: Script exited with non-zero exit status: 1.Allowed exit codes are: [0]

==> Builds finished but no artifacts were created.`

即使我做了如下的操作, 再去运行构建脚本,也是不行的. [root@test001 service-images]# lsmod | grep nf_conntrack_ipv4 [root@test001 service-images]# sudo modprobe nf_conntrack_ipv4 [root@test001 service-images]# lsmod | grep nf_conntrack_ipv4 nf_conntrack_ipv4 15053 0 nf_defrag_ipv4 12729 1 nf_conntrack_ipv4 nf_conntrack 137239 1 nf_conntrack_ipv4