Skip to content

Commit f100709

Browse files
authored
Add interface for custom networkConfig (#1418)
* Add interface for custom networkConfig This provides a way to specify a custom networkConfig for each node in a deployment. The user sets NETWORK_CONFIG_FOLDER to a path that contains YAML files named for each node. The contents of these files are included in the install-config definition for the appropriate node. * Add DNS custom host support To support custom networkConfigs that include static IPs (which require reverse DNS records for each node so a hostname can be assigned), this adds the ability to specify additional DNS hosts that will be added to the regular list of hosts that dev-scripts creates in DNS. This config is only added if NETWORK_CONFIG_FOLDER is set and the file 'hosts.yaml' exists in that location. The file contents should be a list of IPs and hostnames, such as: - ip: 192.168.111.110 hostnames: - "master-0" - ip: 192.168.111.111 hostnames: - "master-1" etc. * Add support for bonding the primary interface In order to test deployment on bonds we need a way to have two interfaces on the baremetal network. This adds a new environment variable, BOND_PRIMARY_INTERFACE, that adds two NICs on the baremetal network to each node. * Document network config and bond parameters Also makes NETWORK_CONFIG_FOLDER able to handle relative paths.
1 parent 1f918c1 commit f100709

File tree

4 files changed

+37
-1
lines changed

4 files changed

+37
-1
lines changed

config_example.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,25 @@ set -x
347347
# (Currently this just expects a non-empty value, the IP is fixed to .9)
348348
# export ENABLE_BOOTSTRAP_STATIC_IP=true
349349

350+
# NETWORK_CONFIG_FOLDER -
351+
# Set this to the location of a folder containing networkConfigs for the nodes
352+
# in the deployment. The filenames correspond to the name of the host. For
353+
# example, to provide a networkConfig for master-0 in a default dev-scripts
354+
# deployment, create a file named `ostest-master-0.yaml` in the specified
355+
# folder that contains the networkConfig (including the key "networkConfig").
356+
#
357+
# This folder may also contain a file named `hosts.yaml` which is a list of
358+
# additional DNS entries to configure in the libvirt DNS. This should be a
359+
# list of entries with the following format:
360+
# - ip: 192.168.111.110
361+
# hostnames:
362+
# - "master-0"
363+
364+
# BOND_PRIMARY_INTERFACE -
365+
# When set to any value this will cause dev-scripts to include duplicate nics
366+
# on the primary network. This is intended for testing bonded network configs
367+
# and may not work without a bond config.
368+
350369
################################################################################
351370
## VM Settings
352371
##

network.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,11 @@ if [[ ! -z "${INSTALLER_PROXY:-}" ]]; then
188188
fi
189189
fi
190190

191+
if [ -n "${NETWORK_CONFIG_FOLDER:-}" ]; then
192+
# We need an absolute path to this location
193+
NETWORK_CONFIG_FOLDER="$(readlink -m $NETWORK_CONFIG_FOLDER)"
194+
fi
195+
191196
function set_api_and_ingress_vip() {
192197
# NOTE: This is equivalent to the external API DNS record pointing the API to the API VIP
193198
if [ "$MANAGE_BR_BRIDGE" == "y" ] ; then

utils.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,12 @@ function node_map_to_install_config_hosts() {
226226
bootMACAddress: ${mac}
227227
bootMode: ${boot_mode}
228228
EOF
229+
if [ -n "${NETWORK_CONFIG_FOLDER:-}" ]; then
230+
node_network_config="${NETWORK_CONFIG_FOLDER}/${name}.yaml"
231+
if [ -e "$node_network_config" ]; then
232+
cat "$node_network_config" | sed "s/\(.*\)/ \1/"
233+
fi
234+
fi
229235

230236
# FIXME(stbenjam) Worker code in installer should accept
231237
# "default" as well -- currently the mapping doesn't work,

vm_setup_vars.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ dns_extrahosts:
4646
hostnames:
4747
- "virthost"
4848

49+
network_config_folder: "{{ lookup('env', 'NETWORK_CONFIG_FOLDER') | default(false) }}"
50+
hosts_config: "{{ lookup('template', network_config_folder + '/hosts.yaml', errors='ignore') | default('[]', true) | from_yaml }}"
51+
dns_customhosts: "{{ [] if not network_config_folder else hosts_config }}"
52+
4953
provisioning_network:
5054
- name: "{{ provisioning_network_name }}"
5155
bridge: "{{ provisioning_network_name }}"
@@ -71,7 +75,9 @@ external_network:
7175
- 65535
7276
domain: "{{ cluster_domain }}"
7377
dns:
74-
hosts: "{{dns_extrahosts | default([])}}"
78+
hosts: "{{dns_extrahosts + dns_customhosts | default([])}}"
7579
forwarders:
7680
- domain: "apps.{{ cluster_domain }}"
7781
addr: "127.0.0.1"
82+
83+
networks: "{{ provisioning_network + external_network + (extra_networks | default([])) if not lookup('env', 'BOND_PRIMARY_INTERFACE') else provisioning_network + external_network + external_network + (extra_networks | default([])) }}"

0 commit comments

Comments
 (0)