rancher / os

Tiny Linux distro that runs the entire OS as Docker containers
https://rancher.com/docs/os/v1.x/en/
Apache License 2.0
6.45k stars 656 forks source link

Not picking up network config from configdrive2 #2575

Closed arnarg closed 5 years ago

arnarg commented 5 years ago

RancherOS Version: (ros os version) v1.4.2

Where are you running RancherOS? (docker-machine, AWS, GCE, baremetal, etc.) Proxmox/KVM

Proxmox supports cloud-init as of version 5.2. By default it uses NoCloud which doesn't seem to be supported by RancherOS but can be set to configdrive2. When I change my VM to configdrive2 RancherOS picks up everything from cloud-init except networking, it uses dhcp instead.

When I mount the configdrive it has the following.

openstack
  |-- content
  |   `-- 0000
  `-- latest
      |-- meta_data.json
      `-- user_data

openstack/latest/user_data:

#cloud-config
hostname: hostname_set_in_proxmox
manage_etc_hosts: true
fqdn: hostname_set_in_proxmox_with_fqdn
user: rancher
ssh_authorized_keys:
  - ssh-rsa key_set_in_proxmox
chpasswd:
  expire: False
users:
  - default
package_upgrade: true

openstack/latest/meta_data.json:

{
     "uuid": "c7e51b981c9df5019a45ccbf66c3b5e2c2ef71bb",
     "network_config": { "content_path": "/content/0000" }
}

openstack/content/0000:

auto lo
iface lo inet loopback

        dns_nameservers x.x.x.2
        dns_search domain.com
auto eth0
iface eth0 inet static
        address x.x.x.10
        netmask 255.255.255.0
        gateway x.x.x.1

/var/lib/rancher/conf/cloud-config.yml only includes:

rancher:
  console: fedora
niusmallnan commented 5 years ago

You should use the rancheros style configurations. https://rancher.com/docs/os/v1.x/en/installation/networking/interfaces/

arnarg commented 5 years ago

I see. Unfortunately the format of the data isn't configurable, just the values. Is there any cloud-init data source that uses the rancher style?

niusmallnan commented 5 years ago

If you use AWS or DO, you can do this: image

arnarg commented 5 years ago

Fair enough. I really don't mean to argue I'm just curious here :) On ec2 there's also http://169.254.169.254/latest/meta-data/network/interfaces/ where cloud-init usually pulls networking information from.

discordier commented 5 years ago

I ran into the same problem and solved it for me by doing the following.

Create VM (id 1001 in this example)

vi /mnt/pve/cephfs/snippets/user-1001.yml (swap mnt/pve/cephfs with the desired snippets storage). Put in the following:

#cloud-config
hostname: rancheros
manage_etc_hosts: true
ssh_authorized_keys:
  - ssh-rsa YOUR-PUBLIC-KEY
  - ssh-rsa ANOTHER-PUBLIC-KEY
chpasswd:
  expire: False
users:
  - default
package_upgrade: true
rancher:
  network:
    interfaces:
      eth0:
        address: 192.168.100.222/24
        mtu: 9000
        dhcp: false

Register the config in the machine: qm set 1001 --cicustom user=cephfs:snippets/user-1001.yml

mizbanpaytakht commented 5 years ago

Hi,

I tried to autoinstall RancherOS inside a VM in Proxmox but I have problem. Can you help me on this issue ?

I create a VM and mount rancheros-proxmox-ve iso in CDRom and via Cloud-init I create this file:

#cloud-config
rancher:
 network:
  interfaces:
   eth0:
    address: 10.10.10.5/24
    gateway: 10.10.10.1
    mtu: 1500
    dhcp: false
  dns:
   nameservers:
   - 178.22.122.100
   - 185.51.200.2
write_files:
  - path: /opt/rancher/bin/install.yml
    permissions: "0700"
    content: |
      #cloud-config
      rancher:
       network:
        interfaces:
         eth0:
          address: 10.10.10.5/24
          gateway: 10.10.10.1
          mtu: 1500
          dhcp: false
        dns:
         nameservers:
         - 8.8.8.8
      ssh_authorized_keys:
       - ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAQEAu+cJj5HKIb7P9tTM9KE+9Zj5L+jWBh4KcCovonJvv9NwUPykEp4iSzATwrPr/8QtQEnsSuoZiQldt+XuAs7gOhMksrhPFNmS7C3efxwWLJvPqbXrSIBGkDFNss64bL+lhyDZvZ6jkihS+QuI9D4gKhKfcdjrgyWSe7OwAgrfsw5thZ9l2i/tG6yTjqhrPIsyUzPYtfn5QUcLuCd1+vO5J0TX0a8JZtob0bzHX4kJcCh44LWO7aA0wL7ti6BPNOEGISRk2VhyFuhCTCNZTznMplPcpqdTDEd1T0YAvS2nQNXcFGVgb0m04Abj61FRKUBBHXFZS6X5wEC98B5e5CtTvDlw== rsa-key-20190921
  - path: /opt/rancher/bin/start.sh
    permissions: "0700"
    content: |
      #!/bin/bash
      echo Y | sudo ros install -f -c /opt/rancher/bin/install.yml -d /dev/sda

qm set 1001 --cicustom user=cephfs:snippets/config-1001.yml

When I boot the machine its not used the config file.

discordier commented 5 years ago

@mizbanpaytakht Try clicking on "Rebuild ISO" on the cloud-init drive in proxmox web ui. Maybe this will resolve your problem (the config might not have been absorbed into the iso fs used for cloud-init)

mizbanpaytakht commented 5 years ago

@mizbanpaytakht Try clicking on "Rebuild ISO" on the cloud-init drive in proxmox web ui. Maybe this will resolve your problem (the config might not have been absorbed into the iso fs used for cloud-init)

@discordier No this not fixed my problem, Maybe since I mount rancheros.iso file in CDRom cause this problem ! How can I get rancheros .img file to import it into server disk.

discordier commented 5 years ago

Don't know, I boot from the iso (first CD-ROM drive) and have my config as mentioned above in the cloud-init drive (second CD-ROM) in my VM and it boots correctly.

Did you follow above steps correctly? Did you double check paths and settings?

mizbanpaytakht commented 5 years ago

@discordier Which ISO did you used ? Are you working on Proxmox VE 6 ? Cloudinit create metadata and userdata from YML file and I import it but Rancher didnt use it

discordier commented 5 years ago

I use rancheros-proxmoxve-autoformat.iso and yes, I have 3 V6 proxmox nodes running one rancher VM each