smartxworks / virtink

Lightweight Virtualization Add-on for Kubernetes
Apache License 2.0
492 stars 41 forks source link

How to set the size of root disk vm when using container root fs #104

Open sharadregoti opened 3 months ago

sharadregoti commented 3 months ago

This is my virtlink yaml. Even though I have set the size as 10Gi it does not have any effect.

apiVersion: virt.virtink.smartx.com/v1alpha1
kind: VirtualMachine
metadata:
  labels:
    virtlink.io/os: linux
    virtlink.io/vm: "{{ .Values.virtualMachine.name }}"
  name: "{{ .Values.virtualMachine.name }}"
spec:
  instance:
    # TODO: Set up cpu
    # https://github.com/smartxworks/virtink/blob/main/docs/dedicated_cpu_placement.md
    memory:
      size: "{{ .Values.memory }}"
    interfaces:
      - name: pod
    disks:
      - name: image
      - name: cloud-init
  volumes:
    - name: image
      containerRootfs:
        image: "{{ .Values.image }}"
        size: 10Gi
    - name: cloud-init
      cloudInit:
        userData: |-
          #cloud-config
          system_info:
            default_user:
              name: ubuntu
              home: /home/ubuntu

          password: ubuntu
          chpasswd: { expire: False }
          hostname: ubuntu

          runcmd:
            - chown ubuntu:ubuntu /home/ubuntu -R

          # configure sshd to allow users logging in using password
          # rather than just keys
          ssh_pwauth: True
          ssh_authorized_keys:
            - {{ .Values.virtualMachine.sshKey }}
  networks:
    - name: pod
      pod: {}

I am running a ubuntu cloud disk image. (The default size that I get is 2GB)

ubuntu@ubuntu:~$ df -h Filesystem Size Used Avail Use% Mounted on /dev/root 2.0G 1.9G 85M 96% / tmpfs 996M 0 996M 0% /dev/shm tmpfs 399M 508K 398M 1% /run tmpfs 5.0M 0 5.0M 0% /run/lock /dev/vda15 105M 6.1M 99M 6% /boot/efi tmpfs 200M 4.0K 200M 1% /run/user/1000

fengye87 commented 3 months ago

It should work. See code here.