-
Bug
-
Resolution: Done-Errata
-
None
- 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.
- How reproducible:
100%
- 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
```
- 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)
- 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.
- 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 }}
```
- is related to
-
CNV-36242 [enterprise-4.12] Issue in file virt/virtual_machines/vm_networking/virt-configuring-ip-for-vms.adoc
- ASSIGNED
-
CNV-28438 [2190439] cloudInitConfigDrive yaml contains cloudInitNoCloud content
- Closed
-
CNV-29457 [2213073] OpenShift console does not generate correct cloud-init config
- Closed
-
CNV-28700 Attempting to set Static IP on a VM via OCP Console UI does not work
- Closed
- relates to
-
CNV-33537 Change cloudinit to NoCloud - UI
- Closed
- external trackers
- links to
-
RHEA-2023:116760 OpenShift Virtualization 4.15.0 Images
- mentioned on