Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions pkg/controller/installation/core_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,12 @@ func fillDefaults(instance *operatorv1.Installation, currentPools *v3.IPPoolList
}
if instance.Spec.CNI.InstallMode == nil {
mode := operatorv1.CNIInstallModeAll
if instance.Spec.KubernetesProvider == operatorv1.ProviderKind {
// kind node images already ship the upstream CNI plugins, so skip
// the cni-plugins init container. Other providers default to All
// for backward compatibility.
mode = operatorv1.CNIInstallModeCalicoOnly
}
instance.Spec.CNI.InstallMode = &mode
}

Expand Down
25 changes: 25 additions & 0 deletions pkg/controller/installation/defaults_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ var _ = Describe("Defaulting logic tests", func() {
Expect(instance.Spec.Variant).To(Equal(operator.Calico))
Expect(instance.Spec.Registry).To(BeEmpty())
Expect(instance.Spec.CNI.Type).To(Equal(operator.PluginCalico))
Expect(*instance.Spec.CNI.InstallMode).To(Equal(operator.CNIInstallModeAll))
Expect(instance.Spec.CalicoNetwork).NotTo(BeNil())
Expect(instance.Spec.CalicoNetwork.LinuxDataplane).ToNot(BeNil())
Expect(*instance.Spec.CalicoNetwork.LinuxDataplane).To(Equal(operator.LinuxDataplaneIptables))
Expand Down Expand Up @@ -456,6 +457,30 @@ var _ = Describe("Defaulting logic tests", func() {
Expect(validateCustomResource(instance)).NotTo(HaveOccurred())
})

It("should default CNI InstallMode to CalicoOnly on the Kind provider", func() {
instance := &operator.Installation{
Spec: operator.InstallationSpec{
KubernetesProvider: operator.ProviderKind,
CNI: &operator.CNISpec{},
},
}
Expect(fillDefaults(instance, nil)).NotTo(HaveOccurred())
Expect(*instance.Spec.CNI.InstallMode).To(Equal(operator.CNIInstallModeCalicoOnly))
Expect(validateCustomResource(instance)).NotTo(HaveOccurred())
})

It("should not override an explicit CNI InstallMode on the Kind provider", func() {
all := operator.CNIInstallModeAll
instance := &operator.Installation{
Spec: operator.InstallationSpec{
KubernetesProvider: operator.ProviderKind,
CNI: &operator.CNISpec{InstallMode: &all},
},
}
Expect(fillDefaults(instance, nil)).NotTo(HaveOccurred())
Expect(*instance.Spec.CNI.InstallMode).To(Equal(operator.CNIInstallModeAll))
})

It("should set default values for CNILogging if CNI is set to Calico", func() {
instance := &operator.Installation{
Spec: operator.InstallationSpec{
Expand Down
Loading