Skip to content

Commit

Permalink
Remove the need to set primary nic for libvirt
Browse files Browse the repository at this point in the history
If there is no primary nic specified, the first non-loopback device is
selected as the primary interface.

Signed-off-by: Roman Mohr <[email protected]>
  • Loading branch information
rmohr committed Dec 4, 2017
1 parent ceebc67 commit 5113f58
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 14 deletions.
4 changes: 1 addition & 3 deletions docs/dev-env-local.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,11 @@ step using
## Building kubevirt

First configure kubevirt with site specific parameters. As above
we need the hostname and IP address. We also, however, want to
set the primary NIC name associated with the public IP addr.
we need the hostname and IP address.

```bash
cat > hack/config-local.sh <<EOF
master_ip=192.168.122.13
primary_nic=ens3
primary_node_name=kubdev
docker_tag=latest
EOF
Expand Down
1 change: 0 additions & 1 deletion hack/build-manifests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ rm -f "manifests/*.yaml"
# Render kubernetes manifests
for arg in $args; do
sed -e "s/{{ master_ip }}/$master_ip/g" \
-e "s/{{ primary_nic }}/$primary_nic/g" \
-e "s/{{ primary_node_name }}/$primary_node_name/g" \
-e "s/{{ docker_tag }}/$docker_tag/g" \
-e "s/{{ docker_prefix }}/$docker_prefix/g" \
Expand Down
3 changes: 1 addition & 2 deletions hack/config-default.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@ manifest_templates="`ls ${KUBEVIRT_PATH}manifests/*.in`"
master_ip=192.168.200.2
master_port=8184
network_provider=weave
primary_nic=${primary_nic:-eth1}
primary_node_name=${primary_node_name:-master}
primary_node_name=${primary_node_name:-master}
4 changes: 2 additions & 2 deletions hack/config.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
unset binaries docker_images docker_prefix docker_tag manifest_templates \
master_ip master_port network_provider primary_nic primary_node_name
master_ip master_port network_provider primary_node_name

source ${KUBEVIRT_PATH}hack/config-default.sh

Expand All @@ -8,4 +8,4 @@ source ${KUBEVIRT_PATH}hack/config-default.sh
test -f "hack/config-local.sh" && source hack/config-local.sh

export binaries docker_images docker_prefix docker_tag manifest_templates \
master_ip master_port network_provider primary_nic primary_node_name
master_ip master_port network_provider primary_node_name
7 changes: 7 additions & 0 deletions images/libvirt-kubevirt/libvirtd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,16 @@ mkdir -p /var/log/kubevirt
touch /var/log/kubevirt/qemu-kube.log
chown qemu:qemu /var/log/kubevirt/qemu-kube.log

# If no main interface is specified, take the first non-loopback device
if [[ -z "$LIBVIRTD_DEFAULT_NETWORK_DEVICE" ]]; then
LIBVIRTD_DEFAULT_NETWORK_DEVICE=$(ip -o -4 a | tr -s ' ' | cut -d' ' -f 2 | grep -v -e '^lo[0-9:]*$' | head -1)
echo "Selected \"$LIBVIRTD_DEFAULT_NETWORK_DEVICE\" as primary interface"
fi

# We create the network on a file basis to not
# have to wait for libvirtd to come up
if [[ -n "$LIBVIRTD_DEFAULT_NETWORK_DEVICE" ]]; then
echo "Setting libvirt default network to \"$LIBVIRTD_DEFAULT_NETWORK_DEVICE\""
mkdir -p /etc/libvirt/qemu/networks/autostart
cat > /etc/libvirt/qemu/networks/default.xml <<EOX
<!-- Generated by libvirtd.sh container script -->
Expand Down
3 changes: 0 additions & 3 deletions manifests/libvirt.yaml.in
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ spec:
securityContext:
privileged: true
runAsUser: 0
env:
- name: LIBVIRTD_DEFAULT_NETWORK_DEVICE
value: {{ primary_nic }}
volumeMounts:
- mountPath: /host-dev
name: host-dev
Expand Down
3 changes: 0 additions & 3 deletions manifests/virt-manifest.yaml.in
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,6 @@ spec:
securityContext:
privileged: true
runAsUser: 0
env:
- name: LIBVIRTD_DEFAULT_NETWORK_DEVICE
value: {{ primary_nic }}
volumeMounts:
- name: libvirt-runtime
mountPath: /var/run/libvirt
Expand Down

0 comments on commit 5113f58

Please sign in to comment.