This message was deleted.
# elemental
a
This message was deleted.
f
In the upcoming 1.7 version of the elemental-operator we added declarative networking. You will be able to set IPs driven by an IPAM provider, or statically (based on MAC matching) using the nm-configurator tool (note this has to be installed on OS images, with custom derivative image). Note that the static config with nm-configurator can be achieved also on the current (1.6) version, if you'd like to give it an early try.
q
Yes, thanks I have already checked this out especially https://elemental.docs.rancher.com/next/networking-static as we want to use static IPs. This part makes it hard for us: "Since the configuration is static, be aware that any change (for example to add new nodes) will require you to rebuild and republish your custom images, and rebuild the
SeedImage
too to create a fresh installation media." Our flow for a new cluster is like this: • ask network dep. for 6 static IPs • create terraform code for vmware using the static IPs • deploy • done This works perfectly with vanilla rancher as the vms are all started with the "same" vm template and vmware just changes the IPs for new created VMs. In elemental you can not use vm templates because vm templates are kind of cloned VMs which means the registration process (uuid, TPM, etc.) is done and elemental will not accept another vm created by this template. Elemental make some stuff more complex. I found a workaround to use the same image for workers and controllers = good. But I also want to use the same image to set a static IP and we want to set the IP when we create the VM via terraform. So the idea is to use a field of "advanced configuration parameters" which is available on first boot time make elemental read it and use it to configure network interfaces.
f
The problem with having something available on first boot is where to get it. In this case if your network config is 100% static, it would be problematic to fetch the remote MachineRegistration for example, assuming we can add a "first boot cloud-config" there. You do have the option to include a cloud-config in the SeedImage, that will be evaluated at boot, however as the documentation states this requires you to bake a new image any time you change the config. This can be automated. I do think this scenario works better with the IPAM provider. A DHCP server would still be needed in this case for the initial registration and reset, however you can keep a very short lease.
q
Yes, right now it boots with dhcp, gets the MachineRegistration where i added nmcli commands to update the config but the problem now (i think) is that /etc is ephermal and nmcli saves the network config in /etc/NetworkManager/system-connections/. I will now try to add this dir to the persistent list https://github.com/rancher/elemental/blob/main/framework/files/system/oem/01_elemental-rootfs.yaml#L52 and create a custom image. Is this a way it could work?
I also found this https://github.com/rancher/elemental-operator/blob/cf1a2d6400cbc0828f21c33c4817191668429b57/pkg/network/network.go#L124 but not sure when this is executed and if it would delete the new generated config anyway
f
The reset network (deleting all
/etc/NetworkManager/system-connections/*.nmconnections
files) always happens on machine reset. I'm grateful you pointed this out because now I think it would be best to happen during reset, only if a network config template has been defined on the MachineRegistration. Otherwise as you hinted, this will break any other custom setup.
for the first part, you could create a yip config file that populates
/etc/NetworkManager/system-connections/
at initramfs stage. you can include the yip config in your custom image, this is how the sample in the static configuration achieves it, so the connections are re-created at every boot
q
regarding "first part" i wonder how https://elemental.docs.rancher.com/networking#elemental-cloud-config works as it writes to /etc/NetworkManager/system-connections/fixed-ip.nmconnection which is ephermal (?)
f
it re-applies the cloud-config it at every boot
under the hood this is translated to a yip config with boot stage: https://elemental.docs.rancher.com/cloud-config-reference
we also support writing yip syntax configs directly, so you can execute different commands at different stages
q
hmm then my runcmd nmcli con mod eth0 ipv4.addresses ..... should work as well
f
if you are injecting a cloud-config using the MachineRegistration, you should see the config being written in
/oem
directory after installation
yes nmcli should work and generate some nmconnections
I think you can try
elemental --debug run-stage boot
on the machine to re-execute the config arbitrarily
q
jep will test this
elemental --debug run-stage boot runs fine and configures the iface with a static IP but after reboot the interface is gone and back in dhcp mode
is there a logfile which i can check for the output of the run after the reboot?
ok got it
error: networkmanager is not running
so nmcli commands fail
seems i need to go the yip way and use network.after or something
f
right, I think however that there will be a brief moment where dhcp will be used, before nmcli applies the new config
I think the simplest approach is to use nmcli to generate the nmconnection files on a test machine, and then just use the cloud-config to apply those
q
then i can not add different ips to the nodes?
f
good point, then not without a registration (and installation media) per node
q
the goal is to read a var which contains a static ip using vmtoolsd and this will be applied to eth2 using nmcli via yip
will try this tomorrow. thanks for your help 👍
f
thank you for the input!
I also forgot to mention, that after your feedback we made some changes to how declarative networking is working. By default (when not using Elemental to manage the machine network), the
/etc/NetworkManager/system-connections/*.nmconnection
files will not be deleted. This is the
none
network configurator. Any custom config will be respected. Still beware that if you make
/etc/NetworkManager/system-connections/
persistent, it will still be deleted during machine reset (can be toggled)
q
Having problems with the format (it seems) of yip in MachineRegistration.
Copy code
apiVersion: <http://elemental.cattle.io/v1beta1|elemental.cattle.io/v1beta1>
kind: MachineRegistration
metadata:
  name: elemental1
  namespace: fleet-default
spec:
  machineName: "${System Data/Runtime/Hostname}"
  config:
    cloud-config:
      name: "A registration driven config"
      stages:
        initramfs:
        - name: "Setup users"
          ensure_entities:
          - path: /etc/shadow
            entity: |
                kind: "shadow"
                username: "root"
                password: "root"
    elemental:
      install:
        reboot: true
        device: /dev/sda
        debug: true
      registration:
        emulate-tpm: true
        emulated-tpm-seed: -1
  machineInventoryLabels:
    nodeType: "${Chassis Information/Asset Tag}"
    hostname: "${System Data/Runtime/Hostname}"
which is taken from https://elemental.docs.rancher.com/cloud-config-reference#configuration-syntax gives me "unable to parse config file..../etc/rancher/elemental/agent/config.yaml stat no such file or directory during the registration process
upated the iso to latest elemental and it works now