Skip to content

kubevirt: Support nocloud user-data#2134

Merged
prestist merged 1 commit into
coreos:mainfrom
qinqon:kubevirt-nocloud
Oct 7, 2025
Merged

kubevirt: Support nocloud user-data#2134
prestist merged 1 commit into
coreos:mainfrom
qinqon:kubevirt-nocloud

Conversation

@qinqon

@qinqon qinqon commented Oct 1, 2025

Copy link
Copy Markdown
Contributor

At kubevirt one can configure the cloud init as config drive or nocloud, with config drive is the current approch, this change add the nocloud that spect a device mount with "cidata" label and tue user data file at /user-data there, also the main different if that on those cases the network data follows the netplan v1 or v2 that's is better format than the openstack meta data network service one.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds support for nocloud user-data in Kubevirt, falling back to the existing config-drive method. The changes are well-structured, particularly the parameterization of the device and path fetching logic. I've identified a potential logic issue in the new fallback mechanism: if the nocloud source provides no user data, the fallback to config-drive is not triggered. I have included a specific comment with a suggested fix for this behavior.

Comment thread internal/providers/kubevirt/kubevirt.go

@jlebon jlebon left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems sane to me. Needs release note.

Comment thread internal/providers/kubevirt/kubevirt.go
@qinqon

qinqon commented Oct 1, 2025

Copy link
Copy Markdown
Contributor Author

Seems sane to me. Needs release note.

@jlebon thanks on it!

Comment thread docs/release-notes.md Outdated
@qinqon qinqon requested a review from prestist October 2, 2025 11:36
@qinqon

qinqon commented Oct 2, 2025

Copy link
Copy Markdown
Contributor Author

Humm something is not ready yet it's failing to find cidata with this VM

apiVersion: kubevirt.io/v1
kind: VirtualMachine
metadata:
  namespace: clusters-test1
  name: fedora-coreos-vm
spec:
  runStrategy: Always
  template:
    metadata:
      labels:
        app: fedora-coreos-vm
    spec:
      domain:
        devices:
          disks:
            - name: rootdisk
              disk:
                bus: virtio
            - name: cloudinitdisk
              disk:
                bus: virtio
          interfaces:
            - name: default
              bridge: {}
        resources:
          requests:
            memory: 2Gi
            cpu: "1"
          limits:
            memory: 4Gi
            cpu: "2"
      networks:
        - name: default
          multus:
            networkName: localnet-clusters-test1
      volumes:
        - name: rootdisk
          containerDisk:
            image: quay.io/ellorent/fcos-kubevirt@sha256:410995a0d71a0ff73809fb5872a66da396e6ea51321bb6f790885610605473d8
        - name: cloudinitdisk
          cloudInitNoCloud:
            userData: '{"ignition":{"version":"3.5.0"},"passwd":{"users":[{"name":"core","passwordHash":"$y$j9T$b7RFf2LW7MUOiF4RyLHKA0$T.Ap/uzmg8zrTcUNXyXvBvT26UgkC6zZUVg3UKXeEp5"}]}}'

I am building it with https://github.com/qinqon/coreos-initrd-builder

And I can confirm that the ignition inside the VM is the custom one.

[   12.595697] ignition[776]: Ignition 2.21.0
[   12.595811] ignition[776]: Stage: fetch-offline
[   12.595869] ignition[776]: reading system config file "/usr/lib/ignition/base.d/00-core.ign"
[   12.599678] ignition[776]: reading system config file "/usr/lib/ignition/base.d/30-afterburn-sshkeys-core.ign"
[   12.602698] ignition[776]: no config dir at "/usr/lib/ignition/base.platform.d/kubevirt"
[   12.602851] ignition[776]: no config URL provided
[   12.602925] ignition[776]: reading system config file "/usr/lib/ignition/user.ign"
[   12.602997] ignition[776]: no config at "/usr/lib/ignition/user.ign"
[   12.804951] systemd[1]: Finished systemd-vconsole-setup.service - Virtual Console Setup.

@qinqon qinqon force-pushed the kubevirt-nocloud branch 3 times, most recently from fefeed2 to f3608ca Compare October 3, 2025 10:24
@qinqon

qinqon commented Oct 3, 2025

Copy link
Copy Markdown
Contributor Author

@jlebon @prestist managed to test it and it's working fine, kubevirt fecos with ConfigDrive and NoCloud is working as expected.

Tested it with images builded with https://github.com/qinqon/coreos-initrd-builder
These are the kubevirt VMs

With NoCloud

apiVersion: kubevirt.io/v1
kind: VirtualMachine
metadata:
  namespace: clusters-test1
  name: fedora-coreos-vm
spec:
  runStrategy: Always
  template:
    metadata:
      labels:
        app: fedora-coreos-vm
    spec:
      domain:
        devices:
          disks:
            - name: rootdisk
              disk:
                bus: virtio
            - name: cloudinitdisk
              disk:
                bus: virtio
          interfaces:
            - name: default
              bridge: {}
        resources:
          requests:
            memory: 2Gi
            cpu: "1"
          limits:
            memory: 4Gi
            cpu: "2"
      networks:
        - name: default
          multus:
            networkName: localnet-clusters-test1
      volumes:
        - name: rootdisk
          containerDisk:
            image: quay.io/ellorent/fcos-kubevirt@sha256:a773c47ecff9f580a80510d0e4c652c5648b1cb102ec16832b68ba925a810114
        - name: cloudinitdisk
          cloudInitNoCloud:
            userData: '{"ignition":{"version":"3.5.0"},"passwd":{"users":[{"name":"core","passwordHash":"$y$j9T$b7RFf2LW7MUOiF4RyLHKA0$T.Ap/uzmg8zrTcUNXyXvBvT26UgkC6zZUVg3UKXeEp5"}]}}'

And with ConfigDrive

apiVersion: kubevirt.io/v1
kind: VirtualMachine
metadata:
  namespace: clusters-test1
  name: fedora-coreos-vm
spec:
  runStrategy: Always
  template:
    metadata:
      labels:
        app: fedora-coreos-vm
    spec:
      domain:
        devices:
          disks:
            - name: rootdisk
              disk:
                bus: virtio
            - name: cloudinitdisk
              disk:
                bus: virtio
          interfaces:
            - name: default
              bridge: {}
        resources:
          requests:
            memory: 2Gi
            cpu: "1"
          limits:
            memory: 4Gi
            cpu: "2"
      networks:
        - name: default
          multus:
            networkName: localnet-clusters-test1
      volumes:
        - name: rootdisk
          containerDisk:
            image: quay.io/ellorent/fcos-kubevirt@sha256:a773c47ecff9f580a80510d0e4c652c5648b1cb102ec16832b68ba925a810114
        - name: cloudinitdisk
          cloudInitConfigDrive:
            userData: '{"ignition":{"version":"3.5.0"},"passwd":{"users":[{"name":"core","passwordHash":"$y$j9T$b7RFf2LW7MUOiF4RyLHKA0$T.Ap/uzmg8zrTcUNXyXvBvT26UgkC6zZUVg3UKXeEp5"}]}}'

@prestist prestist left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM just that one nit.

Comment thread docs/release-notes.md Outdated
At kubevirt one can configure the cloud init as config drive or nocloud,
with config drive is the current approch, this change add the nocloud
that spect a device mount with "cidata" label and tue user data file at
/user-data there, also the main different if that on those cases the
network data follows the netplan v1 or v2 that's is better format than
the openstack meta data network service one.

Signed-off-by: Enrique Llorente <ellorent@redhat.com>

@prestist prestist left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for working on this, and being so quick to respond to feedback LGTM!

@prestist prestist merged commit cc16ece into coreos:main Oct 7, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants