You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
1.2 KiB

  1. auto mac0
  2. iface mac0 inet static
  3. address {{ node_pod_cidr|ipaddr('net')|ipaddr(1)|ipaddr('address') }}
  4. network {{ node_pod_cidr|ipaddr('network') }}
  5. netmask {{ node_pod_cidr|ipaddr('netmask') }}
  6. broadcast {{ node_pod_cidr|ipaddr('broadcast') }}
  7. pre-up ip link add link {{ macvlan_interface }} mac0 type macvlan mode bridge
  8. {% for host in groups['kube_node'] %}
  9. {% if hostvars[host]['access_ip'] is defined %}
  10. {% if hostvars[host]['node_pod_cidr'] != node_pod_cidr %}
  11. post-up ip route add {{ hostvars[host]['node_pod_cidr'] }} via {{ hostvars[host]['access_ip'] }}
  12. {% endif %}
  13. {% endif %}
  14. {% endfor %}
  15. {% if enable_nat_default_gateway %}
  16. post-up iptables -t nat -I POSTROUTING -s {{ node_pod_cidr|ipaddr('net') }} -o {{ node_default_gateway_interface }} -j MASQUERADE
  17. {% endif %}
  18. {% for host in groups['kube_node'] %}
  19. {% if hostvars[host]['access_ip'] is defined %}
  20. {% if hostvars[host]['node_pod_cidr'] != node_pod_cidr %}
  21. post-down ip route del {{ hostvars[host]['node_pod_cidr'] }} via {{ hostvars[host]['access_ip'] }}
  22. {% endif %}
  23. {% endif %}
  24. {% endfor %}
  25. post-down iptables -t nat -D POSTROUTING -s {{ node_pod_cidr|ipaddr('net') }} -o {{ node_default_gateway_interface }} -j MASQUERADE
  26. post-down ip link delete mac0