Giter Site home page Giter Site logo

Comments (2)

ccamacho avatar ccamacho commented on June 28, 2024

Hi @Bilal-io PRs are always welcomed, mostly because PRs that solve users' issues are always good examples of how to improve the code. In the specific case of the external interface mac +1 from my side, to do this you should add these steps:

1- An additional dict variable like:

mac: 52:54:00:10:57:05 (note that 52:54:00: is always required in libvirt)

In https://github.com/Kubeinit/kubeinit/blob/master/kubeinit/roles/kubeinit_libvirt/defaults/main.yml#L148

2- Add the mac variable to the eth1 interface in all the supported distros like:

--network bridge={{ kubeinit_libvirt_external_service_interface.attached }},mac={{ kubeinit_libvirt_external_service_interface.mac }},model=virtio \

In:

https://github.com/Kubeinit/kubeinit/blob/master/kubeinit/roles/kubeinit_libvirt/tasks/10_rke_deploy_nodes.yml#L131
https://github.com/Kubeinit/kubeinit/blob/master/kubeinit/roles/kubeinit_libvirt/tasks/10_k8s_deploy_nodes.yml#L133
https://github.com/Kubeinit/kubeinit/blob/master/kubeinit/roles/kubeinit_libvirt/tasks/10_okd_deploy_service_nodes.yml#L128

3- The last step should be updating the interface template with an extra parameter like:

MACADDR={{ kubeinit_libvirt_external_service_interface.mac }}

In: https://github.com/Kubeinit/kubeinit/blob/master/kubeinit/roles/kubeinit_libvirt/templates/ifcfg-eth1.j2#L18

With these steps you should be able to add a fixed mac address to this external interface.

Once you have this, a nice improvement can be to extract the IP's information from the libvirt role and put it in each env inventory, if you notice the variables here:

https://github.com/Kubeinit/kubeinit/blob/master/kubeinit/roles/kubeinit_libvirt/defaults/main.yml#L144-L147

attached: "{{ kubeinit_inventory_network_bridge_external }}"
dev: eth1
ip: 10.19.41.157
gateway: 10.19.41.254
netmask: 255.255.255.0

Should be something like:

attached: "{{ kubeinit_inventory_network_bridge_external }}"
dev: "{{ kubeinit_inventory_network_bridge_external_dev }}"
ip: "{{ kubeinit_inventory_network_bridge_external_ip }}"
gateway: "{{ kubeinit_inventory_network_bridge_external_gateway }}"
netmask: "{{ kubeinit_inventory_network_bridge_external_netmask }}"
mac: "{{ kubeinit_inventory_network_bridge_external_mac }}"

And they should be defined in:

https://github.com/Kubeinit/kubeinit/blob/master/kubeinit/hosts/cdk/inventory#L16
https://github.com/Kubeinit/kubeinit/blob/master/kubeinit/hosts/k8s/inventory#L16
https://github.com/Kubeinit/kubeinit/blob/master/kubeinit/hosts/okd/inventory#L16
https://github.com/Kubeinit/kubeinit/blob/master/kubeinit/hosts/rke/inventory#L16

Like:

kubeinit_inventory_network_bridge_external_dev=eth1
kubeinit_inventory_network_bridge_external_ip=10.19.41.157
kubeinit_inventory_network_bridge_external_gateway=10.19.41.254
kubeinit_inventory_network_bridge_external_netmask=255.255.255.0
kubeinit_inventory_network_bridge_external_mac=52:54:00:10:57:05

The reasoning for this refactor is to have all the network details specified in the same place (the inventory for each distro).

I hope this is enough info :) and thanks for raising this issue.

Also, take into account the commit syntax check, you can add a single commit like:


feat: add fixed mac address to the external interface

This patch adds support for adding a fixed mac
address to the external interface in the service node.


Feel free to push a PR whenever you have some time and I'll review it for sure. Thanks!

from kubeinit.

Bilal-io avatar Bilal-io commented on June 28, 2024

You pretty much did all the work in that comment, so thank you!

from kubeinit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.