From c451faa15e5033cc9b0461bf01643c13b5397c80 Mon Sep 17 00:00:00 2001 From: Richard Draycott Date: Thu, 9 May 2024 17:37:02 +0200 Subject: [PATCH 1/5] feat: Add support for controlplane rollout if ServerConfig has changed, mirroring the approach used by kubeadm Signed-off-by: Richard Draycott --- pkg/machinefilters/machine_filters.go | 51 +++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/pkg/machinefilters/machine_filters.go b/pkg/machinefilters/machine_filters.go index 3f9affad..46b6f693 100644 --- a/pkg/machinefilters/machine_filters.go +++ b/pkg/machinefilters/machine_filters.go @@ -17,6 +17,9 @@ limitations under the License. package machinefilters import ( + "encoding/json" + "reflect" + "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" "sigs.k8s.io/cluster-api/util/collections" @@ -83,6 +86,54 @@ func MatchesKubernetesVersion(kubernetesVersion string) Func { // MatchesKThreesBootstrapConfig checks if machine's KThreesConfigSpec is equivalent with KCP's KThreesConfigSpec. func MatchesKThreesBootstrapConfig(machineConfigs map[string]*bootstrapv1.KThreesConfig, kcp *controlplanev1.KThreesControlPlane) Func { return func(machine *clusterv1.Machine) bool { + if machine == nil { + return false + } + + // Check if KCP and machine KThreesServerConfig matches, if not return + if !matchKThreesServerConfig(kcp, machine) { + return false + } + + bootstrapRef := machine.Spec.Bootstrap.ConfigRef + if bootstrapRef == nil { + // Missing bootstrap reference should not be considered as unmatching. + // This is a safety precaution to avoid selecting machines that are broken, which in the future should be remediated separately. + return true + } + return true } } + +// matchKThreesServerConfig verifies if KCP and machine ClusterConfiguration matches. +// NOTE: Machines that have KThreesServerConfigurationAnnotation will have to match with KCP KThreesServerConfig. +// If the annotation is not present (machine is either old or adopted), we won't roll out on any possible changes +// made in KCP's KThreesServerConfig given that we don't have enough information to make a decision. +// Users should use KCP.Spec.RolloutAfter field to force a rollout in this case. +func matchKThreesServerConfig(kcp *controlplanev1.KThreesControlPlane, machine *clusterv1.Machine) bool { + kThreesServerConfigStr, ok := machine.GetAnnotations()[controlplanev1.KThreesServerConfigurationAnnotation] + if !ok { + // We don't have enough information to make a decision; don't' trigger a roll out. + return true + } + + kThreesServerConfig := &bootstrapv1.KThreesServerConfig{} + + // ClusterConfiguration annotation is not correct, only solution is to rollout. + // The call to json.Unmarshal has to take a pointer to the pointer struct defined above, + // otherwise we won't be able to handle a nil ClusterConfiguration (that is serialized into "null"). + if err := json.Unmarshal([]byte(kThreesServerConfigStr), &kThreesServerConfig); err != nil { + return false + } + + // If any of the compared values are nil, treat them the same as an empty KThreesServerConfig. + if kThreesServerConfig == nil { + kThreesServerConfig = &bootstrapv1.KThreesServerConfig{} + } + + kcpLocalKThreesServerConfig := kcp.Spec.KThreesConfigSpec.ServerConfig + + // Compare and return. + return reflect.DeepEqual(kThreesServerConfig, kcpLocalKThreesServerConfig) +} From 9b1f81bb5e839c046df24169010341d14c9c7f5b Mon Sep 17 00:00:00 2001 From: Richard Draycott Date: Tue, 14 May 2024 13:51:16 +0200 Subject: [PATCH 2/5] feat: Add unit tests and add matching logic for the rest of kthreescontrolplanespec Signed-off-by: Richard Draycott --- pkg/machinefilters/machine_filters.go | 17 +- pkg/machinefilters/machine_filters_test.go | 198 +++++++++++++++++++++ 2 files changed, 213 insertions(+), 2 deletions(-) create mode 100644 pkg/machinefilters/machine_filters_test.go diff --git a/pkg/machinefilters/machine_filters.go b/pkg/machinefilters/machine_filters.go index 46b6f693..9bc8f263 100644 --- a/pkg/machinefilters/machine_filters.go +++ b/pkg/machinefilters/machine_filters.go @@ -102,7 +102,20 @@ func MatchesKThreesBootstrapConfig(machineConfigs map[string]*bootstrapv1.KThree return true } - return true + machineConfig, found := machineConfigs[machine.Name] + if !found { + // Return true here because failing to get KThreesConfig should not be considered as unmatching. + // This is a safety precaution to avoid rolling out machines if the client or the api-server is misbehaving. + return true + } + + kcpConfig := kcp.Spec.KThreesConfigSpec.DeepCopy() + // KCP bootstrapv1.KThreesServerConfig will only be compared with a machine's ServerConfig annotation, so + // we are cleaning up from the reflect.DeepEqual comparison. + kcpConfig.ServerConfig = bootstrapv1.KThreesServerConfig{} + machineConfig.Spec.ServerConfig = bootstrapv1.KThreesServerConfig{} + + return reflect.DeepEqual(&machineConfig.Spec, kcpConfig) } } @@ -132,7 +145,7 @@ func matchKThreesServerConfig(kcp *controlplanev1.KThreesControlPlane, machine * kThreesServerConfig = &bootstrapv1.KThreesServerConfig{} } - kcpLocalKThreesServerConfig := kcp.Spec.KThreesConfigSpec.ServerConfig + kcpLocalKThreesServerConfig := &kcp.Spec.KThreesConfigSpec.ServerConfig // Compare and return. return reflect.DeepEqual(kThreesServerConfig, kcpLocalKThreesServerConfig) diff --git a/pkg/machinefilters/machine_filters_test.go b/pkg/machinefilters/machine_filters_test.go new file mode 100644 index 00000000..df5b8741 --- /dev/null +++ b/pkg/machinefilters/machine_filters_test.go @@ -0,0 +1,198 @@ +package machinefilters + +import ( + "testing" + + . "github.com/onsi/gomega" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" + + bootstrapv1 "github.com/k3s-io/cluster-api-k3s/bootstrap/api/v1beta2" + controlplanev1 "github.com/k3s-io/cluster-api-k3s/controlplane/api/v1beta2" +) + +func TestMatchesKubeadmBootstrapConfig(t *testing.T) { + t.Run("returns true if ClusterConfiguration is equal", func(t *testing.T) { + g := NewWithT(t) + kcp := &controlplanev1.KThreesControlPlane{ + Spec: controlplanev1.KThreesControlPlaneSpec{ + KThreesConfigSpec: bootstrapv1.KThreesConfigSpec{ + ServerConfig: bootstrapv1.KThreesServerConfig{ + ClusterDomain: "foo", + }, + }, + }, + } + m := &clusterv1.Machine{ + ObjectMeta: metav1.ObjectMeta{ + Annotations: map[string]string{ + controlplanev1.KThreesServerConfigurationAnnotation: "{\n \"clusterDomain\": \"foo\"\n}", + }, + }, + } + machineConfigs := map[string]*bootstrapv1.KThreesConfig{ + m.Name: {}, + } + match := MatchesKThreesBootstrapConfig(machineConfigs, kcp)(m) + g.Expect(match).To(BeTrue()) + }) + t.Run("returns false if ClusterConfiguration is NOT equal", func(t *testing.T) { + g := NewWithT(t) + kcp := &controlplanev1.KThreesControlPlane{ + Spec: controlplanev1.KThreesControlPlaneSpec{ + KThreesConfigSpec: bootstrapv1.KThreesConfigSpec{ + ServerConfig: bootstrapv1.KThreesServerConfig{ + ClusterDomain: "foo", + }, + }, + }, + } + m := &clusterv1.Machine{ + ObjectMeta: metav1.ObjectMeta{ + Annotations: map[string]string{ + controlplanev1.KThreesServerConfigurationAnnotation: "{\n \"clusterDomain\": \"bar\"\n}", + }, + }, + } + machineConfigs := map[string]*bootstrapv1.KThreesConfig{ + m.Name: {}, + } + match := MatchesKThreesBootstrapConfig(machineConfigs, kcp)(m) + g.Expect(match).To(BeFalse()) + }) + + t.Run("returns false if some other configurations are not equal", func(t *testing.T) { + g := NewWithT(t) + kcp := &controlplanev1.KThreesControlPlane{ + Spec: controlplanev1.KThreesControlPlaneSpec{ + KThreesConfigSpec: bootstrapv1.KThreesConfigSpec{ + Files: []bootstrapv1.File{}, // This is a change + }, + }, + } + + m := &clusterv1.Machine{ + TypeMeta: metav1.TypeMeta{ + Kind: "KThreesConfig", + APIVersion: clusterv1.GroupVersion.String(), + }, + ObjectMeta: metav1.ObjectMeta{ + Namespace: "default", + Name: "test", + }, + Spec: clusterv1.MachineSpec{ + Bootstrap: clusterv1.Bootstrap{ + ConfigRef: &corev1.ObjectReference{ + Kind: "KThreesConfig", + Namespace: "default", + Name: "test", + APIVersion: bootstrapv1.GroupVersion.String(), + }, + }, + }, + } + machineConfigs := map[string]*bootstrapv1.KThreesConfig{ + m.Name: { + TypeMeta: metav1.TypeMeta{ + Kind: "KThreesConfig", + APIVersion: bootstrapv1.GroupVersion.String(), + }, + ObjectMeta: metav1.ObjectMeta{ + Namespace: "default", + Name: "test", + }, + Spec: bootstrapv1.KThreesConfigSpec{}, + }, + } + match := MatchesKThreesBootstrapConfig(machineConfigs, kcp)(m) + g.Expect(match).To(BeFalse()) + }) + + t.Run("should match on labels and annotations", func(t *testing.T) { + kcp := &controlplanev1.KThreesControlPlane{ + Spec: controlplanev1.KThreesControlPlaneSpec{ + MachineTemplate: controlplanev1.KThreesControlPlaneMachineTemplate{ + ObjectMeta: clusterv1.ObjectMeta{ + Annotations: map[string]string{ + "test": "annotation", + }, + Labels: map[string]string{ + "test": "labels", + }, + }, + }, + KThreesConfigSpec: bootstrapv1.KThreesConfigSpec{ + ServerConfig: bootstrapv1.KThreesServerConfig{}, + }, + }, + } + m := &clusterv1.Machine{ + TypeMeta: metav1.TypeMeta{ + Kind: "KThreesConfig", + APIVersion: clusterv1.GroupVersion.String(), + }, + ObjectMeta: metav1.ObjectMeta{ + Namespace: "default", + Name: "test", + }, + Spec: clusterv1.MachineSpec{ + Bootstrap: clusterv1.Bootstrap{ + ConfigRef: &corev1.ObjectReference{ + Kind: "KThreesConfig", + Namespace: "default", + Name: "test", + APIVersion: bootstrapv1.GroupVersion.String(), + }, + }, + }, + } + machineConfigs := map[string]*bootstrapv1.KThreesConfig{ + m.Name: { + TypeMeta: metav1.TypeMeta{ + Kind: "KThreesConfig", + APIVersion: bootstrapv1.GroupVersion.String(), + }, + ObjectMeta: metav1.ObjectMeta{ + Namespace: "default", + Name: "test", + }, + Spec: bootstrapv1.KThreesConfigSpec{ + ServerConfig: bootstrapv1.KThreesServerConfig{}, + }, + }, + } + + t.Run("by returning true if neither labels or annotations match", func(t *testing.T) { + g := NewWithT(t) + machineConfigs[m.Name].Annotations = nil + machineConfigs[m.Name].Labels = nil + match := MatchesKThreesBootstrapConfig(machineConfigs, kcp)(m) + g.Expect(match).To(BeTrue()) + }) + + t.Run("by returning true if only labels don't match", func(t *testing.T) { + g := NewWithT(t) + machineConfigs[m.Name].Annotations = kcp.Spec.MachineTemplate.ObjectMeta.Annotations + machineConfigs[m.Name].Labels = nil + match := MatchesKThreesBootstrapConfig(machineConfigs, kcp)(m) + g.Expect(match).To(BeTrue()) + }) + + t.Run("by returning true if only annotations don't match", func(t *testing.T) { + g := NewWithT(t) + machineConfigs[m.Name].Annotations = nil + machineConfigs[m.Name].Labels = kcp.Spec.MachineTemplate.ObjectMeta.Labels + match := MatchesKThreesBootstrapConfig(machineConfigs, kcp)(m) + g.Expect(match).To(BeTrue()) + }) + + t.Run("by returning true if both labels and annotations match", func(t *testing.T) { + g := NewWithT(t) + machineConfigs[m.Name].Labels = kcp.Spec.MachineTemplate.ObjectMeta.Labels + machineConfigs[m.Name].Annotations = kcp.Spec.MachineTemplate.ObjectMeta.Annotations + match := MatchesKThreesBootstrapConfig(machineConfigs, kcp)(m) + g.Expect(match).To(BeTrue()) + }) + }) +} From 81d483944a68f7b084f41453cb99c04468691ecb Mon Sep 17 00:00:00 2001 From: Richard Draycott Date: Tue, 14 May 2024 15:22:37 +0200 Subject: [PATCH 3/5] feat: Add more machinefilter test cases and exclude version from check Signed-off-by: Richard Draycott --- pkg/machinefilters/machine_filters.go | 3 + pkg/machinefilters/machine_filters_test.go | 85 ++++++++++++++++++++++ 2 files changed, 88 insertions(+) diff --git a/pkg/machinefilters/machine_filters.go b/pkg/machinefilters/machine_filters.go index 9bc8f263..bc7a2aa8 100644 --- a/pkg/machinefilters/machine_filters.go +++ b/pkg/machinefilters/machine_filters.go @@ -114,6 +114,9 @@ func MatchesKThreesBootstrapConfig(machineConfigs map[string]*bootstrapv1.KThree // we are cleaning up from the reflect.DeepEqual comparison. kcpConfig.ServerConfig = bootstrapv1.KThreesServerConfig{} machineConfig.Spec.ServerConfig = bootstrapv1.KThreesServerConfig{} + // KCP version check is handled elsewhere + kcpConfig.Version = "" + machineConfig.Spec.Version = "" return reflect.DeepEqual(&machineConfig.Spec, kcpConfig) } diff --git a/pkg/machinefilters/machine_filters_test.go b/pkg/machinefilters/machine_filters_test.go index df5b8741..e52e4cf4 100644 --- a/pkg/machinefilters/machine_filters_test.go +++ b/pkg/machinefilters/machine_filters_test.go @@ -4,6 +4,7 @@ import ( "testing" . "github.com/onsi/gomega" + "google.golang.org/protobuf/proto" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" @@ -109,6 +110,90 @@ func TestMatchesKubeadmBootstrapConfig(t *testing.T) { g.Expect(match).To(BeFalse()) }) + t.Run("Should match on other configurations", func(t *testing.T) { + kThreesConfigSpec := bootstrapv1.KThreesConfigSpec{ + Files: []bootstrapv1.File{}, + PreK3sCommands: []string{"test"}, + PostK3sCommands: []string{"test"}, + AgentConfig: bootstrapv1.KThreesAgentConfig{ + NodeName: "test-node", + NodeTaints: []string{"node-role.kubernetes.io/control-plane:NoSchedule"}, + KubeProxyArgs: []string{"metrics-bind-address=0.0.0.0"}, + }, + ServerConfig: bootstrapv1.KThreesServerConfig{ + DisableComponents: []string{"traefik"}, + KubeControllerManagerArgs: []string{"bind-address=0.0.0.0"}, + KubeSchedulerArgs: []string{"bind-address=0.0.0.0"}, + }, + } + kcp := &controlplanev1.KThreesControlPlane{ + Spec: controlplanev1.KThreesControlPlaneSpec{ + Replicas: proto.Int32(3), + Version: "v1.13.14+k3s1", + MachineTemplate: controlplanev1.KThreesControlPlaneMachineTemplate{ + ObjectMeta: clusterv1.ObjectMeta{ + Labels: map[string]string{"test-label": "test-value"}, + }, + }, + KThreesConfigSpec: kThreesConfigSpec, + }, + } + + m := &clusterv1.Machine{ + TypeMeta: metav1.TypeMeta{ + Kind: "KThreesConfig", + APIVersion: clusterv1.GroupVersion.String(), + }, + ObjectMeta: metav1.ObjectMeta{ + Namespace: "default", + Name: "test", + }, + Spec: clusterv1.MachineSpec{ + Bootstrap: clusterv1.Bootstrap{ + ConfigRef: &corev1.ObjectReference{ + Kind: "KThreesConfig", + Namespace: "default", + Name: "test", + APIVersion: bootstrapv1.GroupVersion.String(), + }, + }, + }, + } + machineConfigs := map[string]*bootstrapv1.KThreesConfig{ + m.Name: { + TypeMeta: metav1.TypeMeta{ + Kind: "KThreesConfig", + APIVersion: bootstrapv1.GroupVersion.String(), + }, + ObjectMeta: metav1.ObjectMeta{ + Namespace: "default", + Name: "test", + }, + Spec: kThreesConfigSpec, + }, + } + + t.Run("by returning true if all configs match", func(t *testing.T) { + g := NewWithT(t) + match := MatchesKThreesBootstrapConfig(machineConfigs, kcp)(m) + g.Expect(match).To(BeTrue()) + }) + + t.Run("by returning false if post commands don't match", func(t *testing.T) { + g := NewWithT(t) + machineConfigs[m.Name].Spec.PostK3sCommands = []string{"new-test"} + match := MatchesKThreesBootstrapConfig(machineConfigs, kcp)(m) + g.Expect(match).To(BeFalse()) + }) + + t.Run("by returning false if agent configs don't match", func(t *testing.T) { + g := NewWithT(t) + machineConfigs[m.Name].Spec.AgentConfig.KubeletArgs = []string{"test-arg"} + match := MatchesKThreesBootstrapConfig(machineConfigs, kcp)(m) + g.Expect(match).To(BeFalse()) + }) + }) + t.Run("should match on labels and annotations", func(t *testing.T) { kcp := &controlplanev1.KThreesControlPlane{ Spec: controlplanev1.KThreesControlPlaneSpec{ From 0550197720df0787ced9b09effda0aae3cfcf462 Mon Sep 17 00:00:00 2001 From: Richard Draycott Date: Wed, 15 May 2024 13:34:53 +0200 Subject: [PATCH 4/5] feat: Fix test name Signed-off-by: Richard Draycott --- pkg/machinefilters/machine_filters_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/machinefilters/machine_filters_test.go b/pkg/machinefilters/machine_filters_test.go index e52e4cf4..90dcb697 100644 --- a/pkg/machinefilters/machine_filters_test.go +++ b/pkg/machinefilters/machine_filters_test.go @@ -13,7 +13,7 @@ import ( controlplanev1 "github.com/k3s-io/cluster-api-k3s/controlplane/api/v1beta2" ) -func TestMatchesKubeadmBootstrapConfig(t *testing.T) { +func TestMatchesKThreesBootstrapConfig(t *testing.T) { t.Run("returns true if ClusterConfiguration is equal", func(t *testing.T) { g := NewWithT(t) kcp := &controlplanev1.KThreesControlPlane{ From 9caad96c2d6849e64bbffcfd9bd2e3e9523c9d00 Mon Sep 17 00:00:00 2001 From: Richard Draycott Date: Thu, 16 May 2024 13:53:03 +0200 Subject: [PATCH 5/5] feat: Simply code by removing redundant serverConfig check via annotation Signed-off-by: Richard Draycott --- pkg/machinefilters/machine_filters.go | 43 +--------------------- pkg/machinefilters/machine_filters_test.go | 33 +++++++++++++++-- 2 files changed, 31 insertions(+), 45 deletions(-) diff --git a/pkg/machinefilters/machine_filters.go b/pkg/machinefilters/machine_filters.go index bc7a2aa8..2e069a30 100644 --- a/pkg/machinefilters/machine_filters.go +++ b/pkg/machinefilters/machine_filters.go @@ -17,7 +17,6 @@ limitations under the License. package machinefilters import ( - "encoding/json" "reflect" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" @@ -90,11 +89,6 @@ func MatchesKThreesBootstrapConfig(machineConfigs map[string]*bootstrapv1.KThree return false } - // Check if KCP and machine KThreesServerConfig matches, if not return - if !matchKThreesServerConfig(kcp, machine) { - return false - } - bootstrapRef := machine.Spec.Bootstrap.ConfigRef if bootstrapRef == nil { // Missing bootstrap reference should not be considered as unmatching. @@ -110,10 +104,7 @@ func MatchesKThreesBootstrapConfig(machineConfigs map[string]*bootstrapv1.KThree } kcpConfig := kcp.Spec.KThreesConfigSpec.DeepCopy() - // KCP bootstrapv1.KThreesServerConfig will only be compared with a machine's ServerConfig annotation, so - // we are cleaning up from the reflect.DeepEqual comparison. - kcpConfig.ServerConfig = bootstrapv1.KThreesServerConfig{} - machineConfig.Spec.ServerConfig = bootstrapv1.KThreesServerConfig{} + // KCP version check is handled elsewhere kcpConfig.Version = "" machineConfig.Spec.Version = "" @@ -121,35 +112,3 @@ func MatchesKThreesBootstrapConfig(machineConfigs map[string]*bootstrapv1.KThree return reflect.DeepEqual(&machineConfig.Spec, kcpConfig) } } - -// matchKThreesServerConfig verifies if KCP and machine ClusterConfiguration matches. -// NOTE: Machines that have KThreesServerConfigurationAnnotation will have to match with KCP KThreesServerConfig. -// If the annotation is not present (machine is either old or adopted), we won't roll out on any possible changes -// made in KCP's KThreesServerConfig given that we don't have enough information to make a decision. -// Users should use KCP.Spec.RolloutAfter field to force a rollout in this case. -func matchKThreesServerConfig(kcp *controlplanev1.KThreesControlPlane, machine *clusterv1.Machine) bool { - kThreesServerConfigStr, ok := machine.GetAnnotations()[controlplanev1.KThreesServerConfigurationAnnotation] - if !ok { - // We don't have enough information to make a decision; don't' trigger a roll out. - return true - } - - kThreesServerConfig := &bootstrapv1.KThreesServerConfig{} - - // ClusterConfiguration annotation is not correct, only solution is to rollout. - // The call to json.Unmarshal has to take a pointer to the pointer struct defined above, - // otherwise we won't be able to handle a nil ClusterConfiguration (that is serialized into "null"). - if err := json.Unmarshal([]byte(kThreesServerConfigStr), &kThreesServerConfig); err != nil { - return false - } - - // If any of the compared values are nil, treat them the same as an empty KThreesServerConfig. - if kThreesServerConfig == nil { - kThreesServerConfig = &bootstrapv1.KThreesServerConfig{} - } - - kcpLocalKThreesServerConfig := &kcp.Spec.KThreesConfigSpec.ServerConfig - - // Compare and return. - return reflect.DeepEqual(kThreesServerConfig, kcpLocalKThreesServerConfig) -} diff --git a/pkg/machinefilters/machine_filters_test.go b/pkg/machinefilters/machine_filters_test.go index 90dcb697..74c14414 100644 --- a/pkg/machinefilters/machine_filters_test.go +++ b/pkg/machinefilters/machine_filters_test.go @@ -50,14 +50,41 @@ func TestMatchesKThreesBootstrapConfig(t *testing.T) { }, } m := &clusterv1.Machine{ + TypeMeta: metav1.TypeMeta{ + Kind: "KThreesConfig", + APIVersion: clusterv1.GroupVersion.String(), + }, ObjectMeta: metav1.ObjectMeta{ - Annotations: map[string]string{ - controlplanev1.KThreesServerConfigurationAnnotation: "{\n \"clusterDomain\": \"bar\"\n}", + Namespace: "default", + Name: "test", + }, + Spec: clusterv1.MachineSpec{ + Bootstrap: clusterv1.Bootstrap{ + ConfigRef: &corev1.ObjectReference{ + Kind: "KThreesConfig", + Namespace: "default", + Name: "test", + APIVersion: bootstrapv1.GroupVersion.String(), + }, }, }, } machineConfigs := map[string]*bootstrapv1.KThreesConfig{ - m.Name: {}, + m.Name: { + TypeMeta: metav1.TypeMeta{ + Kind: "KThreesConfig", + APIVersion: bootstrapv1.GroupVersion.String(), + }, + ObjectMeta: metav1.ObjectMeta{ + Namespace: "default", + Name: "test", + }, + Spec: bootstrapv1.KThreesConfigSpec{ + ServerConfig: bootstrapv1.KThreesServerConfig{ + ClusterDomain: "bar", + }, + }, + }, } match := MatchesKThreesBootstrapConfig(machineConfigs, kcp)(m) g.Expect(match).To(BeFalse())