From b91c9dd896935bcc2a84e7d34eb5bd1ccca7aad0 Mon Sep 17 00:00:00 2001 From: cyclinder Date: Fri, 14 Jun 2024 18:51:04 +0800 Subject: [PATCH] coordinator: add ipAddress for pod's veth0 Signed-off-by: cyclinder --- cmd/coordinator/cmd/utils.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/cmd/coordinator/cmd/utils.go b/cmd/coordinator/cmd/utils.go index 2e98c34998..67e7aa9472 100644 --- a/cmd/coordinator/cmd/utils.go +++ b/cmd/coordinator/cmd/utils.go @@ -170,6 +170,21 @@ func (c *coordinator) setupVeth(logger *zap.Logger, containerID string) error { if err := netlink.LinkSetUp(link); err != nil { return fmt.Errorf("failed to set %q UP: %v", containerInterface.Name, err) } + + if c.ipFamily == netlink.FAMILY_V6 { + // set an address to veth to fix work with istio + // set only when not ipv6 only + return nil + } + + if err = netlink.AddrAdd(link, &netlink.Addr{ + IPNet: &net.IPNet{ + IP: net.ParseIP("169.254.200.1"), + Mask: net.CIDRMask(32, 32), + }, + }); err != nil { + return fmt.Errorf("failed to add ip address to veth0: %v", err) + } return nil })