Skip to content
This repository has been archived by the owner on Mar 31, 2023. It is now read-only.

Commit

Permalink
allow specification of initial kubelet version in machines file (#122)
Browse files Browse the repository at this point in the history
* allow specification of initial kubelet version in machines file

* Add test for allowing specification of kubelet version without controlPlane version

Co-authored-by: weave-e2e-quickstart <58864910+weave-e2e-quickstart@users.noreply.github.com>
  • Loading branch information
jrryjcksn and weave-e2e-quickstart committed Jan 23, 2020
1 parent aae487e commit 3af6ff3
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pkg/cluster/machine/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,8 @@ func validateVersions(machines []*clusterv1.Machine) field.ErrorList {
fmt.Sprintf("inconsistent kubelet version, expected \"%s\"", reference)))
}

if IsMaster(m) && m.Spec.Versions.ControlPlane != reference {
controlPlaneVersion := m.Spec.Versions.ControlPlane
if IsMaster(m) && controlPlaneVersion != "" && controlPlaneVersion != reference {
errors = append(errors, field.Invalid(
machinePath(i, "spec", "versions", "controlPlane"),
m.Spec.Versions.ControlPlane,
Expand Down
36 changes: 36 additions & 0 deletions pkg/cluster/machine/machine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,41 @@ const machinesValid = `items:
kubelet: "1.10.12"
`

const machinesValidWithOnlyKubeletVersion = `items:
- apiVersion: "cluster.k8s.io/v1alpha1"
kind: Machine
metadata:
generateName: master-
labels:
set: master
spec:
providerSpec:
value:
apiVersion: "baremetalproviderspec/v1alpha1"
kind: "BareMetalMachineProviderSpec"
address: "172.17.8.101"
versions:
kubelet: "1.10.12"
- apiVersion: "cluster.k8s.io/v1alpha1"
kind: Machine
metadata:
generateName: node-
labels:
set: node
spec:
providerSpec:
value:
apiVersion: "baremetalproviderspec/v1alpha1"
kind: "BareMetalMachineProviderSpec"
address: "172.17.8.102"
authenticationWebhook:
cacheTTL: 2m0s
server:
url: http://127.0.0.1:5000/authenticate
versions:
kubelet: "1.10.12"
`

// A machine doesn't have a matching Kubelet version.
const machinesInconsistentKubeletVersion = `items:
- apiVersion: "cluster.k8s.io/v1alpha1"
Expand Down Expand Up @@ -234,6 +269,7 @@ func TestValidateMachines(t *testing.T) {
errors []string
}{
{machinesValid, []string{}},
{machinesValidWithOnlyKubeletVersion, []string{}},
{machinesInconsistentKubeletVersion, []string{
"machines[1].spec.versions.kubelet",
}},
Expand Down

0 comments on commit 3af6ff3

Please sign in to comment.