Skip to content

Commit

Permalink
daemon: add flag to control patch podIP annotations
Browse files Browse the repository at this point in the history
Signed-off-by: l1b0k <[email protected]>
  • Loading branch information
l1b0k committed Jan 21, 2025
1 parent ab6bb9f commit 88d5174
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
12 changes: 9 additions & 3 deletions daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ type networkService struct {
gcRulesOnce sync.Once

rpc.UnimplementedTerwayBackendServer

EnablePatchPodIPs bool
}

var serviceLog = logf.Log.WithName("server")
Expand Down Expand Up @@ -277,9 +279,11 @@ func (n *networkService) AllocIP(ctx context.Context, r *rpc.AllocIPRequest) (*r
}
}

ips := getPodIPs(netConf)
if len(ips) > 0 {
_ = n.k8s.PatchPodIPInfo(pod, strings.Join(ips, ","))
if n.EnablePatchPodIPs {
ips := getPodIPs(netConf)
if len(ips) > 0 {
_ = n.k8s.PatchPodIPInfo(pod, strings.Join(ips, ","))
}
}

// 4. Record resource info
Expand Down Expand Up @@ -859,6 +863,8 @@ func newNetworkService(ctx context.Context, configFilePath, daemonMode string) (
return nil, err
}

netSrv.EnablePatchPodIPs = *config.EnablePatchPodIPs

serviceLog.Info("got config", "config", fmt.Sprintf("%+v", config))

backoff.OverrideBackoff(config.BackoffOverride)
Expand Down
6 changes: 6 additions & 0 deletions types/daemon/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ type Config struct {
KubeClientQPS float32 `json:"kube_client_qps"`
KubeClientBurst int `json:"kube_client_burst"`
ResourceGroupID string `json:"resource_group_id"`
EnablePatchPodIPs *bool `json:"enable_patch_pod_ips,omitempty" mod:"default=true"`
}

func (c *Config) GetSecurityGroups() []string {
Expand Down Expand Up @@ -102,6 +103,11 @@ func (c *Config) Populate() {
if c.IPStack == "" {
c.IPStack = string(types.IPStackIPv4)
}

if c.EnablePatchPodIPs == nil {
enable := true
c.EnablePatchPodIPs = &enable
}
}

func (c *Config) Validate() error {
Expand Down

0 comments on commit 88d5174

Please sign in to comment.