Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP Disable DHCP on cilium pod ENIs on Flatcar #16807

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
35 changes: 35 additions & 0 deletions nodeup/pkg/model/networking/cilium.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ import (
"fmt"
"os"
"path/filepath"
"slices"

"golang.org/x/sys/unix"

"k8s.io/kops/nodeup/pkg/model"
"k8s.io/kops/upup/pkg/fi"
"k8s.io/kops/upup/pkg/fi/nodeup/nodetasks"
"k8s.io/kops/util/pkg/distributions"
)

// CiliumBuilder writes Cilium's assets
Expand All @@ -49,6 +51,13 @@ func (b *CiliumBuilder) Build(c *fi.NodeupModelBuilderContext) error {
return nil
}

if b.NodeupConfig.Networking.Cilium.IPAM == "eni" && slices.Contains([]distributions.Distribution{
distributions.DistributionFlatcar,
distributions.DistributionAmazonLinux2023,
}, b.Distribution) {
b.eniDisableDHCP(c)
}

if err := b.buildBPFMount(c); err != nil {
return fmt.Errorf("failed to create bpf mount unit: %w", err)
}
Expand Down Expand Up @@ -192,3 +201,29 @@ func (b *CiliumBuilder) buildCiliumEtcdSecrets(c *fi.NodeupModelBuilderContext)
return nil
}
}

// Certain distros are known to manipulate network interfaces created and managed by Cilium
// To avoid this, disable DHCP on the ENI interfaces and mark them as unmanaged
// https://github.com/cilium/cilium/blob/04f033e39c15fcfdae664caef3b0cbc17f2cec0b/Documentation/operations/system_requirements.rst#flatcar-on-aws-eks-in-eni-mode
func (b *CiliumBuilder) eniDisableDHCP(c *fi.NodeupModelBuilderContext) {
contents := `
[Match]
Name=eth[1-9]* ens[6-9]*
[Network]
DHCP=no
[Link]
Unmanaged=yes
`

c.AddTask(&nodetasks.File{
Path: "/etc/systemd/network/01-no-dhcp.network",
Contents: fi.NewStringResource(contents),
Type: nodetasks.FileType_File,
OnChangeExecute: [][]string{
{"systemctl", "daemon-reload"},
{"systemctl", "restart", "systemd-networkd"},
},
})
}
Loading