Uploaded image for project: 'OpenShift Virtualization'
  1. OpenShift Virtualization
  2. CNV-29802

[2213449] cloud-init fails when configuring both network and SSH key from the OpenShift console

XMLWordPrintable

    • None

      1. Description of problem:
        When creating a virtual machine from the console, adding both network information and an SSH key via cloud-init does not work.
      1. How reproducible:
        100%
      1. Steps to Reproduce:
        1: From the console, create a RHEL9 VM using the template, customize virtual machine
        2: Add a secondary Network interface
        3: Go to scripts => Edit cloudinit => "Add network data" => use
        Ethernet name: eth1
        IP addresses: 10.10.21.32/24
        4: Authorized SSH Key => Edit and add a public key
        5: Go to yaml and make changes to work around https://bugzilla.redhat.com/show_bug.cgi?id=2213073
        6: Create virtual machine

      A code snippet of the VirtualMachine I created:
      ```
      spec:
      accessCredentials:

      • sshPublicKey:
        propagationMethod:
        configDrive: {}
        source:
        secret:
        secretName: rhel9-6hwr6fv1xm7axnm6-ssh-key-hsby3p
        ....
      • cloudInitConfigDrive:
        networkData: |
        network:
        version: 1
        config:
      • type: physical
        name: eth1
        subnets:
      • type: static
        address: 10.10.21.32.24
        userData: |
        #cloud-config
        user: cloud-user
        password: cloud-user
        chpasswd:
        expire: false
        ```
      1. Actual results:
        Neither the cloud-user password, the SSH key or the networking was configured on the VM. (login does not work, and ping does not work)
      1. Expected results:
        The static IP to be configured, and the password and SSH key for the cloud user to be set.
        Note that when leaving out the network configuration, the SSH key and cloud user password is set correctly.
      1. Additional info:
        OpenShift virt by default uses cloudInitNoCloud, but this get's changed to cloudInitConfigDrive when configuring the SSH keys. When looking at the documentation of using Config drive, I could not find any information related to network configuration (https://cloudinit.readthedocs.io/en/latest/reference/datasources/configdrive.html ). Maybe the issue is related to that.

      Using cloudInitNoCloud rather than cloudInitConfigDrive and pasting the SSH key directly in the userData works for me. However, in this case the (public) SSH key is stored as clear text in the custom resource, rather than stored in a Kubernetes secret .

      ```

      • cloudInitNoCloud:
        networkData: |
        network:
        version: 1
        config:
      • type: physical
        name: eth0
        subnets:
      • type: static
        address: {{ host'] }}/24
        gateway: {{ gateway }}
        dns_nameservers: {{ dns }}
        userData: |
        #cloud-config
        user: cloud-user
        password: cloud-user
        chpasswd:
        expire: false
        hostname: {{ hostname }}
        ssh_authorized_keys:
      • {{ ssh_key }}
        ```

              aturgema Aviv Turgeman
              ddemoiti Dieter De Moitie
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved: