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
7 changes: 7 additions & 0 deletions pkg/render/applicationlayer/applicationlayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,12 @@ func (c *component) containers() []corev1.Container {
commandArgs = append(commandArgs, "--per-host-alp-enabled")
}

// Determine dataplane mode for dikastes
dataplane := "iptables"
if c.config.Installation.IsNftables() {
dataplane = "nftables"
}

dikastes := corev1.Container{
Name: DikastesContainerName,
Image: c.config.dikastesImage,
Expand All @@ -355,6 +361,7 @@ func (c *component) containers() []corev1.Container {
Env: []corev1.EnvVar{
{Name: "LOG_LEVEL", Value: "Info"},
{Name: "DIKASTES_SUBSCRIPTION_TYPE", Value: "per-host-policies"},
{Name: "DATAPLANE", Value: dataplane},
},
VolumeMounts: volMounts,
SecurityContext: securitycontext.NewRootContext(true),
Expand Down
36 changes: 36 additions & 0 deletions pkg/render/applicationlayer/applicationlayer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,7 @@ var _ = Describe("Tigera Secure Application Layer rendering tests", func() {
expectedDikastesEnvs := []corev1.EnvVar{
{Name: "LOG_LEVEL", Value: "Info"},
{Name: "DIKASTES_SUBSCRIPTION_TYPE", Value: "per-host-policies"},
{Name: "DATAPLANE", Value: "iptables"},
}
Expect(len(dikastesEnvs)).To(Equal(len(expectedDikastesEnvs)))

Expand Down Expand Up @@ -671,6 +672,7 @@ var _ = Describe("Tigera Secure Application Layer rendering tests", func() {
expectedDikastesEnvs := []corev1.EnvVar{
{Name: "LOG_LEVEL", Value: "Info"},
{Name: "DIKASTES_SUBSCRIPTION_TYPE", Value: "per-host-policies"},
{Name: "DATAPLANE", Value: "iptables"},
}
Expect(len(dikastesEnvs)).To(Equal(len(expectedDikastesEnvs)))
for _, element := range expectedDikastesEnvs {
Expand Down Expand Up @@ -700,4 +702,38 @@ var _ = Describe("Tigera Secure Application Layer rendering tests", func() {
Expect(dikastesVolMounts).To(ContainElement(expected))
}
})

It("should render dikastes with nftables DATAPLANE when nftables mode is enabled", func() {
// Enable nftables mode in the installation
nftablesMode := operatorv1.LinuxDataplaneNftables
installation.CalicoNetwork = &operatorv1.CalicoNetworkSpec{
LinuxDataplane: &nftablesMode,
}

cfg := &applicationlayer.Config{
PullSecrets: nil,
Installation: installation,
OsType: rmeta.OSTypeLinux,
PerHostALPEnabled: true,
}

component := applicationlayer.ApplicationLayer(cfg)
resources, _ := component.Objects()

ds := rtest.GetResource(resources, applicationlayer.ApplicationLayerDaemonsetName, common.CalicoNamespace, "apps", "v1", "DaemonSet").(*appsv1.DaemonSet)

dikastesContainer := test.GetContainer(ds.Spec.Template.Spec.Containers, "dikastes")
Expect(dikastesContainer).NotTo(BeNil())

// Verify DATAPLANE is set to nftables
expectedDikastesEnvs := []corev1.EnvVar{
{Name: "LOG_LEVEL", Value: "Info"},
{Name: "DIKASTES_SUBSCRIPTION_TYPE", Value: "per-host-policies"},
{Name: "DATAPLANE", Value: "nftables"},
}
Expect(len(dikastesContainer.Env)).To(Equal(len(expectedDikastesEnvs)))
for _, element := range expectedDikastesEnvs {
Expect(dikastesContainer.Env).To(ContainElement(element))
}
})
})
Loading