smartxworks / virtink

Lightweight Virtualization Add-on for Kubernetes
Apache License 2.0
481 stars 37 forks source link

ch.sock: connect: no such file or directory #55

Open wavemomo opened 1 year ago

wavemomo commented 1 year ago

I used CDI to do it. But there are some problems.

  1. the Dockerfile is:

    FROM ubuntu:jammy AS rootfs
    RUN apt-get update -y && \
    apt-get install -y --no-install-recommends systemd-sysv udev lsb-release cloud-init sudo openssh-server && \
    rm -rf /var/lib/apt/lists/*
  2. the vm.yaml:

    apiVersion: virt.virtink.smartx.com/v1alpha1
    kind: VirtualMachine
    metadata:
    name: test-vm
    spec:
    instance:
    memory:
      size: 4Gi
    kernel:
      image: smartxworks/virtink-kernel-5.15.12
      cmdline: "console=ttyS0 root=/dev/vda rw"
    disks:
      - name: ubuntu
      - name: cloud-init
    interfaces:
      - name: pod
    volumes:
    - name: ubuntu
      persistentVolumeClaim:
        claimName: rootfs-dv
      #dataVolume:
      # volumeName: ubuntu
    - name: cloud-init
      cloudInit:
        userData: |-
          #cloud-config
          password: password
          chpasswd: { expire: False }
          ssh_pwauth: True
    networks:
    - name: pod
      pod: {}

    when I apply the vm.yaml,the pod is runinng, but it would quit or block later. I try to solve the problem.

  3. use kubectl logs -f vm-test-vm-xxx: it looks like successfuly, but the pod will quit later.

    image
image
  1. use kubectl describe vm test-vm : image
fengye87 commented 1 year ago

@wavemomo There're some missing steps between the Dockerfile and the data volume? How did you create the image for CDI to import?

wavemomo commented 1 year ago

@fengye87 Thanks for your reply firstly. Here are my steps to create/import image.

  1. create image:

    truncate -s 10G input_raw
    mkfs.ext4 input_raw
    mkdir rootfs
    mount input_raw rootfs/
    docker create --name ubuntu-rootfs ubuntu-rootfs
    docker export ubuntu-rootfs | tar -xvf - -C ./rootfs/
    umount ./rootfs
    qemu-img convert -f raw input_raw -O qcow2 output_rootfs.qcow2
  2. import into datavolume:

    curl -v --insecure -H "Authorization: Bearer $TOKEN" --data-binary @/root/virtink/rootfs.qcow2 https://$(kube ip):31001/v1alpha1/upload
fengye87 commented 1 year ago

@wavemomo I followed your steps but could not reproduce the same problem. Both my VM and the VM pod stayed in the Running state, but I did see the VM didn't start up normally since there's no login prompt. I think there's something missing in the Dockerfile. I'll look into it further. Could you confirm that you create and start the VM after the data volume has been completed imported? And what version of Virtink are you using?

Screen Shot 2022-09-22 at 14 31 02

wavemomo commented 1 year ago

@fengye87 Yes, the VM and the VM pod would stay in the Running state but it would block(but actully, I start the VM first time, the VM pod would quit after login prompt) . And the version of Virtink in my cluster is v0.10.1.

image

By the way, can you share your steps of building image and rootfs if it's different from mine?

fengye87 commented 1 year ago

@wavemomo I used your Dockerfile and your steps to build the image, the only difference is that I was using the http download method of CDI instead of uploading.

wavemomo commented 1 year ago

@fengye87 But my Dockerfile is not different from the official example given?

fengye87 commented 1 year ago

@wavemomo There's a difference. See the highlighted line below. That could be the cause.

Screen Shot 2022-09-22 at 15 22 48

wavemomo commented 1 year ago

@fengye87 I try to use the Dockerfile of official example, the error is : image

fengye87 commented 1 year ago

@wavemomo You should use the /rootfs dir as the image's root when use the official rootfs image.

wavemomo commented 1 year ago

@fengye87 How to use the /rootfs dir as the image's root? Can you give a sample?Thanks very much

fengye87 commented 1 year ago

@wavemomo You can spin up the container, run your steps inside the container (skip the docker part, just copy /rootfs to the image's mount point), and copy the qcow2 image to host. You may need to run apk add qemu-img first to install qemu-img inside the container.