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

[2217541] IP address not set by cloud-init when using secondary NIC via NetworkAttachmentDefinition

XMLWordPrintable

    • High
    • No

      Description of problem:
      When using the Red Hat documentation to configure cloud-init to assign an IP address to an interface [1], the IP address is not assigned to the secondary NIC. If the IP Address information is added to the cloud-init via the OCP Console's "Add network data" option, the IP address is not set, nor is the customized cloud-user password set. As a result, I am unable to login to the VM to validate anything, but the OCP console does not show the specified IP address, nor does the VM ping, so I presume the IP is not being added.

      If the IP address information is added directly to the YAML when creating a VM via the OCP Console (i.e. configure the VM as desired, then click on the "YAML" tab and paste the networkData directly into the YAML before clicking on Create VirtualMachine), then the networkData section is removed completely, so the IP address is obviously not set then, either.

      [1] https://docs.openshift.com/container-platform/4.13/virt/virtual_machines/vm_networking/virt-configuring-ip-for-vms.html

      Version-Release number of selected component (if applicable):
      Customer has this issue with OCP-Virt 4.13, but I can also recreate the issue in my lab, where I am running 4.12.3.

      How reproducible:
      Scenario #1: Use the console to configure a VM based on the Red Hat-provided RHEL8 or RHEL9 template and add a secondary NIC via a NetworkAttachmentDefinition. Use the "Edit" link to configure the Cloud-init, select the check box "Add Network Data" and complete the form appropriately. Click "Create VirtualMachine" and observe that the IP address is not set, and likely you will not be able to login to the VM with as password passed in the Cloud-init section.

      Scenario #2: Use the console to configure a VM based on the Red Hat-provided RHEL8 or RHEL9 template and add a secondary NIC via a NetworkAttachmentDefinition. Configure the VM as desired, then view the raw YAML for the VM. Replace the default "- cloudInitConfigDrive" section [2] with the format provided in the documentation [3]. Click the "Create VirtualMachine" button. Once the VM is up, the IP address is not set on the secondary NIC and in the VM YAML, you can see that the networkData section is no longer present [4]. Also, the "- cloudInitNoCloud" is replaced with "- cloudInitConfigDrive".

      [2]

      • cloudInitConfigDrive:
        userData: |-
        #cloud-config
        user: cloud-user
        password: o53s-igku-yexg
        chpasswd: { expire: False }

        name: cloudinitdisk

      [3]

      • cloudInitNoCloud:
        networkData: |
        version: 2
        ethernets:
        eth1:
        addresses:
      • 172.16.0.185/24
        userData: |
        #cloud-config
        user: cloud-user
        password: redhat
        chpasswd:
        expire: false
        name: cloudinitdisk

      [4]

      • cloudInitConfigDrive:
        userData: |-
        #cloud-config
        user: cloud-user
        password: o53s-igku-yexg
        chpasswd: { expire: False }

        name: cloudinitdisk

      Steps to Reproduce:
      See Scenario #1 and #2 above.

      Actual results:
      Scenario #1: The IP address is not set and neither is the cloud-user password.
      Scenario #2: The IP address is not set because it has been removed from the YAML once the VM is created.

      Expected results:
      In either scenario, the IP address defined in the networkData should be applied to the secondary NIC.

      Additional info:
      The same situation occurs if the default (pod) network interface is removed, so that the only interface on the VM is the NetworkAttachmentDefinition.
      I am attaching four test cases I did in my lab with additional information.

            phoracek@redhat.com Petr Horacek
            msecaur@redhat.com Matthew Secaur (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: