mirror of https://github.com/kubernetes/kops.git
Merge pull request #17438 from mostafahussein/systemd-foreign-routes
add systemd network config for Cilium and Amazon VPC CNI on Ubuntu 22.04+ and AL2023 to prevent route removal
This commit is contained in:
commit
b601ff3a66
|
@ -48,7 +48,10 @@ func (b *AmazonVPCRoutedENIBuilder) Build(c *fi.NodeupModelBuilderContext) error
|
||||||
{"udevadm", "trigger"},
|
{"udevadm", "trigger"},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
if (b.Distribution.IsUbuntu() && b.Distribution.Version() >= 22.04) ||
|
||||||
|
b.Distribution == distributions.DistributionAmazonLinux2023 {
|
||||||
// Make systemd-networkd ignore foreign settings, else it may
|
// Make systemd-networkd ignore foreign settings, else it may
|
||||||
// unexpectedly delete IP rules and routes added by CNI
|
// unexpectedly delete IP rules and routes added by CNI
|
||||||
contents := `
|
contents := `
|
||||||
|
|
|
@ -27,6 +27,7 @@ import (
|
||||||
"k8s.io/kops/nodeup/pkg/model"
|
"k8s.io/kops/nodeup/pkg/model"
|
||||||
"k8s.io/kops/upup/pkg/fi"
|
"k8s.io/kops/upup/pkg/fi"
|
||||||
"k8s.io/kops/upup/pkg/fi/nodeup/nodetasks"
|
"k8s.io/kops/upup/pkg/fi/nodeup/nodetasks"
|
||||||
|
"k8s.io/kops/util/pkg/distributions"
|
||||||
)
|
)
|
||||||
|
|
||||||
// CiliumBuilder writes Cilium's assets
|
// CiliumBuilder writes Cilium's assets
|
||||||
|
@ -57,6 +58,24 @@ func (b *CiliumBuilder) Build(c *fi.NodeupModelBuilderContext) error {
|
||||||
return fmt.Errorf("failed to create cgroupv2 mount unit: %w", err)
|
return fmt.Errorf("failed to create cgroupv2 mount unit: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (b.Distribution.IsUbuntu() && b.Distribution.Version() >= 22.04) ||
|
||||||
|
b.Distribution == distributions.DistributionAmazonLinux2023 {
|
||||||
|
// Make systemd-networkd ignore foreign settings, else it may
|
||||||
|
// unexpectedly delete IP rules and routes added by CNI
|
||||||
|
contents := `
|
||||||
|
# Do not clobber any routes or rules added by CNI.
|
||||||
|
[Network]
|
||||||
|
ManageForeignRoutes=no
|
||||||
|
ManageForeignRoutingPolicyRules=no
|
||||||
|
`
|
||||||
|
c.AddTask(&nodetasks.File{
|
||||||
|
Path: "/usr/lib/systemd/networkd.conf.d/40-disable-manage-foreign-routes.conf",
|
||||||
|
Contents: fi.NewStringResource(contents),
|
||||||
|
Type: nodetasks.FileType_File,
|
||||||
|
OnChangeExecute: [][]string{{"systemctl", "restart", "systemd-networkd"}},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue