From 72c11dd328fe8aed9b345eea1f3b5148dd99a80c Mon Sep 17 00:00:00 2001 From: Greg May Date: Tue, 24 Dec 2019 12:02:14 -0800 Subject: [PATCH 1/4] target release-0.5 Signed-off-by: Greg May --- api/v1alpha2/types.go | 5 +++ ...ture.cluster.x-k8s.io_vspheremachines.yaml | 5 +++ ...ster.x-k8s.io_vspheremachinetemplates.yaml | 5 +++ docs/troubleshooting.md | 15 +++++++ pkg/util/constants.go | 5 +++ pkg/util/machines_test.go | 40 +++++++++++++++++++ 6 files changed, 75 insertions(+) diff --git a/api/v1alpha2/types.go b/api/v1alpha2/types.go index 283cc10eee..d0106caac1 100644 --- a/api/v1alpha2/types.go +++ b/api/v1alpha2/types.go @@ -94,6 +94,11 @@ type NetworkDeviceSpec struct { // will be connected. NetworkName string `json:"networkName"` + // setName can be used to give the device a more specific/desirable/nicer + // name than the default from udev’s ifnames + // +optional + SetName string `json:"setName,omitempty"` + // DHCP4 is a flag that indicates whether or not to use DHCP for IPv4 // on this device. // If true then IPAddrs should not contain any IPv4 addresses. diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_vspheremachines.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_vspheremachines.yaml index 9966235ec2..74f9317248 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_vspheremachines.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_vspheremachines.yaml @@ -138,6 +138,11 @@ spec: items: type: string type: array + setName: + description: setName can be used to give the device a more + specific/desirable/nicer name than the default from udev’s + ifnames + type: string required: - networkName type: object diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_vspheremachinetemplates.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_vspheremachinetemplates.yaml index 8d189a9760..449f7271e3 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_vspheremachinetemplates.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_vspheremachinetemplates.yaml @@ -255,6 +255,11 @@ spec: items: type: string type: array + setName: + description: setName can be used to give the device + a more specific/desirable/nicer name than the default + from udev’s ifnames + type: string required: - networkName type: object diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md index a490a70bfe..97e538554b 100644 --- a/docs/troubleshooting.md +++ b/docs/troubleshooting.md @@ -328,6 +328,21 @@ network: The above network configuratoin from a machine definition includes two network devices, both using DHCP. This likely causes two default routes to be defined on the guest, meaning it's not possible to determine the default IPv4 address that should be used by Kubernetes. +#### Specifying the ethernet interface device names + +A bug with Cloud-Init Networking Config Version 2 prevents the use of Predicatable Device Names in CentOS and Photon [`583`](https://github.com/kubernetes-sigs/cluster-api-provider-vsphere/issues/583). For this reason CAPV sets devices name to eth*. Should one wish to use alternate interface device names, use the setName parameter. For example: + +```yaml +network: + devices: + - networkName: "sddc-cgw-network-5" + setName: "ens192" + dhcp4: true + - networkName: "sddc-cgw-network-6" + setName: "ens193" + dhcp4: true +``` + ##### Preferring an IP address Another reason a machine with two networks can lead to failure is because the order in which IP addresses are returned externally from a VM is not guaranteed to be the same order as they are when inspected inside the guest. The solution for this is to define a preferred CIDR -- the network segment that contains the IP that the `kubeadm` bootstrap process selected for the API server. For example: diff --git a/pkg/util/constants.go b/pkg/util/constants.go index 173ba9eb12..5f67e31c27 100644 --- a/pkg/util/constants.go +++ b/pkg/util/constants.go @@ -26,6 +26,11 @@ network: id{{ $i }}: match: macaddress: "{{ $net.MACAddr }}" + {{- if $net.SetName }} + set-name: "{{ $net.SetName }}" + {{- else }} + set-name: "eth{{ $i }}" + {{- end }} wakeonlan: true dhcp4: {{ $net.DHCP4 }} dhcp6: {{ $net.DHCP6 }} diff --git a/pkg/util/machines_test.go b/pkg/util/machines_test.go index 340af94488..f859844b83 100644 --- a/pkg/util/machines_test.go +++ b/pkg/util/machines_test.go @@ -245,6 +245,38 @@ network: id0: match: macaddress: "00:00:00:00:00" + set-name: "eth0" + wakeonlan: true + dhcp4: true + dhcp6: false +`, + }, + { + name: "dhcp4+setName", + machine: &v1alpha2.VSphereMachine{ + Spec: v1alpha2.VSphereMachineSpec{ + Network: v1alpha2.NetworkSpec{ + Devices: []v1alpha2.NetworkDeviceSpec{ + { + NetworkName: "network1", + MACAddr: "00:00:00:00:00", + DHCP4: true, + SetName: "ens192", + }, + }, + }, + }, + }, + expected: ` +instance-id: "test-vm" +local-hostname: "test-vm" +network: + version: 2 + ethernets: + id0: + match: + macaddress: "00:00:00:00:00" + set-name: "ens192" wakeonlan: true dhcp4: true dhcp6: false @@ -274,6 +306,7 @@ network: id0: match: macaddress: "00:00:00:00:00" + set-name: "eth0" wakeonlan: true dhcp4: false dhcp6: true @@ -304,6 +337,7 @@ network: id0: match: macaddress: "00:00:00:00:00" + set-name: "eth0" wakeonlan: true dhcp4: true dhcp6: true @@ -335,6 +369,7 @@ network: id0: match: macaddress: "00:00:00:00:00" + set-name: "eth0" wakeonlan: true dhcp4: false dhcp6: true @@ -376,6 +411,7 @@ network: id0: match: macaddress: "00:00:00:00:00" + set-name: "eth0" wakeonlan: true dhcp4: false dhcp6: true @@ -425,6 +461,7 @@ network: id0: match: macaddress: "00:00:00:00:00" + set-name: "eth0" wakeonlan: true dhcp4: true dhcp6: false @@ -435,6 +472,7 @@ network: id1: match: macaddress: "00:00:00:00:01" + set-name: "eth1" wakeonlan: true dhcp4: false dhcp6: true @@ -475,6 +513,7 @@ network: id0: match: macaddress: "00:00:00:00:00" + set-name: "eth0" wakeonlan: true dhcp4: false dhcp6: false @@ -489,6 +528,7 @@ network: id1: match: macaddress: "00:00:00:00:01" + set-name: "eth1" wakeonlan: true dhcp4: false dhcp6: true From f9bb0233f652a3a10fd48dba8b7ab0ae840470d5 Mon Sep 17 00:00:00 2001 From: Greg May Date: Tue, 24 Dec 2019 15:09:41 -0800 Subject: [PATCH 2/4] rename SetName to DeviceName Signed-off-by: Greg May --- api/v1alpha2/types.go | 6 +++--- .../infrastructure.cluster.x-k8s.io_vspheremachines.yaml | 4 ++-- ...astructure.cluster.x-k8s.io_vspheremachinetemplates.yaml | 4 ++-- docs/troubleshooting.md | 6 +++--- pkg/util/constants.go | 4 ++-- pkg/util/machines_test.go | 4 ++-- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/api/v1alpha2/types.go b/api/v1alpha2/types.go index d0106caac1..6de50a7f21 100644 --- a/api/v1alpha2/types.go +++ b/api/v1alpha2/types.go @@ -94,10 +94,10 @@ type NetworkDeviceSpec struct { // will be connected. NetworkName string `json:"networkName"` - // setName can be used to give the device a more specific/desirable/nicer - // name than the default from udev’s ifnames + // DeviceName may be used to explicitly assign a name to the network device + // as it exists in the guest operating system. // +optional - SetName string `json:"setName,omitempty"` + DeviceName string `json:"deviceName,omitempty"` // DHCP4 is a flag that indicates whether or not to use DHCP for IPv4 // on this device. diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_vspheremachines.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_vspheremachines.yaml index 74f9317248..952ac76aec 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_vspheremachines.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_vspheremachines.yaml @@ -138,8 +138,8 @@ spec: items: type: string type: array - setName: - description: setName can be used to give the device a more + deviceName: + description: deviceName can be used to give the device a more specific/desirable/nicer name than the default from udev’s ifnames type: string diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_vspheremachinetemplates.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_vspheremachinetemplates.yaml index 449f7271e3..88d1ce9669 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_vspheremachinetemplates.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_vspheremachinetemplates.yaml @@ -255,8 +255,8 @@ spec: items: type: string type: array - setName: - description: setName can be used to give the device + deviceName: + description: deviceName can be used to give the device a more specific/desirable/nicer name than the default from udev’s ifnames type: string diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md index 97e538554b..18f3de97e6 100644 --- a/docs/troubleshooting.md +++ b/docs/troubleshooting.md @@ -330,16 +330,16 @@ The above network configuratoin from a machine definition includes two network d #### Specifying the ethernet interface device names -A bug with Cloud-Init Networking Config Version 2 prevents the use of Predicatable Device Names in CentOS and Photon [`583`](https://github.com/kubernetes-sigs/cluster-api-provider-vsphere/issues/583). For this reason CAPV sets devices name to eth*. Should one wish to use alternate interface device names, use the setName parameter. For example: +A bug with Cloud-Init Networking Config Version 2 prevents the use of Predicatable Device Names in CentOS and Photon [`583`](https://github.com/kubernetes-sigs/cluster-api-provider-vsphere/issues/583). For this reason CAPV sets devices name to eth*. Should one wish to use alternate interface device names, use the deviceName parameter. For example: ```yaml network: devices: - networkName: "sddc-cgw-network-5" - setName: "ens192" + deviceName: "ens192" dhcp4: true - networkName: "sddc-cgw-network-6" - setName: "ens193" + deviceName: "ens193" dhcp4: true ``` diff --git a/pkg/util/constants.go b/pkg/util/constants.go index 5f67e31c27..06f34cd071 100644 --- a/pkg/util/constants.go +++ b/pkg/util/constants.go @@ -26,8 +26,8 @@ network: id{{ $i }}: match: macaddress: "{{ $net.MACAddr }}" - {{- if $net.SetName }} - set-name: "{{ $net.SetName }}" + {{- if $net.DeviceName }} + set-name: "{{ $net.DeviceName }}" {{- else }} set-name: "eth{{ $i }}" {{- end }} diff --git a/pkg/util/machines_test.go b/pkg/util/machines_test.go index f859844b83..f21c571d16 100644 --- a/pkg/util/machines_test.go +++ b/pkg/util/machines_test.go @@ -252,7 +252,7 @@ network: `, }, { - name: "dhcp4+setName", + name: "dhcp4+deviceName", machine: &v1alpha2.VSphereMachine{ Spec: v1alpha2.VSphereMachineSpec{ Network: v1alpha2.NetworkSpec{ @@ -261,7 +261,7 @@ network: NetworkName: "network1", MACAddr: "00:00:00:00:00", DHCP4: true, - SetName: "ens192", + DeviceName: "ens192", }, }, }, From 7f1f45f260fbd3ce0928cf4759c50dfee749b68c Mon Sep 17 00:00:00 2001 From: Greg May Date: Tue, 24 Dec 2019 15:22:05 -0800 Subject: [PATCH 3/4] fix DeviceName descriptions Signed-off-by: Greg May --- .../infrastructure.cluster.x-k8s.io_vspheremachines.yaml | 5 ++--- ...rastructure.cluster.x-k8s.io_vspheremachinetemplates.yaml | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_vspheremachines.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_vspheremachines.yaml index 952ac76aec..b0d34a4a12 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_vspheremachines.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_vspheremachines.yaml @@ -139,9 +139,8 @@ spec: type: string type: array deviceName: - description: deviceName can be used to give the device a more - specific/desirable/nicer name than the default from udev’s - ifnames + description: DeviceName may be used to explicitly assign a name + to the network device as it exists in the guest operating system. type: string required: - networkName diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_vspheremachinetemplates.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_vspheremachinetemplates.yaml index 88d1ce9669..743a873474 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_vspheremachinetemplates.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_vspheremachinetemplates.yaml @@ -256,9 +256,8 @@ spec: type: string type: array deviceName: - description: deviceName can be used to give the device - a more specific/desirable/nicer name than the default - from udev’s ifnames + description: DeviceName may be used to explicitly assign a name + to the network device as it exists in the guest operating system. type: string required: - networkName From 1ba72c4f1e102cc2b56d78cfe8a73a85ae66e0da Mon Sep 17 00:00:00 2001 From: Greg May Date: Tue, 24 Dec 2019 15:25:14 -0800 Subject: [PATCH 4/4] fix DeviceName again Signed-off-by: Greg May --- .../infrastructure.cluster.x-k8s.io_vspheremachines.yaml | 9 +++++---- ...ructure.cluster.x-k8s.io_vspheremachinetemplates.yaml | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_vspheremachines.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_vspheremachines.yaml index b0d34a4a12..54e3c8a5e9 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_vspheremachines.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_vspheremachines.yaml @@ -62,6 +62,11 @@ spec: description: NetworkDeviceSpec defines the network configuration for a virtual machine's network device. properties: + deviceName: + description: DeviceName may be used to explicitly assign a + name to the network device as it exists in the guest operating + system. + type: string dhcp4: description: DHCP4 is a flag that indicates whether or not to use DHCP for IPv4 on this device. If true then IPAddrs @@ -138,10 +143,6 @@ spec: items: type: string type: array - deviceName: - description: DeviceName may be used to explicitly assign a name - to the network device as it exists in the guest operating system. - type: string required: - networkName type: object diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_vspheremachinetemplates.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_vspheremachinetemplates.yaml index 743a873474..a6b2a69d19 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_vspheremachinetemplates.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_vspheremachinetemplates.yaml @@ -177,6 +177,11 @@ spec: description: NetworkDeviceSpec defines the network configuration for a virtual machine's network device. properties: + deviceName: + description: DeviceName may be used to explicitly + assign a name to the network device as it exists + in the guest operating system. + type: string dhcp4: description: DHCP4 is a flag that indicates whether or not to use DHCP for IPv4 on this device. If true @@ -255,10 +260,6 @@ spec: items: type: string type: array - deviceName: - description: DeviceName may be used to explicitly assign a name - to the network device as it exists in the guest operating system. - type: string required: - networkName type: object