Skip to content

Commit

Permalink
Add flannel-external-ip when there is a k3s node-external-ip
Browse files Browse the repository at this point in the history
Signed-off-by: Manuel Buil <[email protected]>
  • Loading branch information
manuelbuil committed Sep 26, 2022
1 parent 53c268d commit 98ac5c7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pkg/agent/flannel/flannel.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,19 @@ const (
subnetFile = "/run/flannel/subnet.env"
)

var (
FlannelBaseAnnotation = "flannel.alpha.coreos.com"
FlannelExternalIPv4Annotation = FlannelBaseAnnotation + "/public-ip-overwrite"
FlannelExternalIPv6Annotation = FlannelBaseAnnotation + "/public-ipv6-overwrite"
)

func flannel(ctx context.Context, flannelIface *net.Interface, flannelConf, kubeConfigFile string, flannelIPv6Masq bool, netMode int) error {
extIface, err := LookupExtInterface(flannelIface, netMode)
if err != nil {
return err
}

sm, err := kube.NewSubnetManager(ctx, "", kubeConfigFile, "flannel.alpha.coreos.com", flannelConf, false)
sm, err := kube.NewSubnetManager(ctx, "", kubeConfigFile, FlannelBaseAnnotation, flannelConf, false)
if err != nil {
return err
}
Expand Down
8 changes: 8 additions & 0 deletions pkg/agent/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,14 @@ func updateAddressAnnotations(agentConfig *daemonconfig.Agent, nodeAnnotations m

if agentConfig.NodeExternalIP != "" {
result[cp.ExternalIPKey] = util.JoinIPs(agentConfig.NodeExternalIPs)
for _, ipAddress := range agentConfig.NodeExternalIPs {
if utilsnet.IsIPv4(ipAddress) {
result[flannel.FlannelExternalIPv4Annotation] = ipAddress.String()
}
if utilsnet.IsIPv6(ipAddress) {
result[flannel.FlannelExternalIPv6Annotation] = ipAddress.String()
}
}
}

result = labels.Merge(nodeAnnotations, result)
Expand Down

0 comments on commit 98ac5c7

Please sign in to comment.