Skip to content

feat(kg): add --internal-cidr flag to filter IP auto-detection#403

Merged
squat merged 2 commits intosquat:mainfrom
cozystack:feature/internal-cidr-flag
Feb 23, 2026
Merged

feat(kg): add --internal-cidr flag to filter IP auto-detection#403
squat merged 2 commits intosquat:mainfrom
cozystack:feature/internal-cidr-flag

Conversation

@kvaps
Copy link
Copy Markdown
Contributor

@kvaps kvaps commented Jan 19, 2026

Summary

Add a new --internal-cidr flag that filters internal IP auto-detection by specified CIDRs. This flag can be specified multiple times.

Motivation

When running Kilo with CNI plugins like Cilium, the auto-detected internal IP may incorrectly select overlay network IPs (e.g., 10.244.x.x) instead of actual node IPs (e.g., 192.168.x.x) due to lexicographic sorting in IP selection. This causes routing issues as privIface gets set to the wrong interface.

Usage

# Filter auto-detection to specific CIDRs
kg --internal-cidr=192.168.0.0/16

# With Kubernetes Downward API
kg --internal-cidr=$(NODE_IP)/32

Changes

  • Add --internal-cidr flag to cmd/kg/main.go
  • Update mesh.New() to accept allowedInternalCIDRs parameter
  • Update getIP() in discoverips.go to filter IPs by allowed CIDRs
  • Update manifests for cilium and flannel deployments to use this flag with NODE_IP from Downward API

Test plan

  • Build passes
  • Tested with --internal-cidr flag in environment with Cilium

@kvaps kvaps marked this pull request as ready for review January 19, 2026 16:57
@kvaps kvaps force-pushed the feature/internal-cidr-flag branch from 2a04879 to 0ada870 Compare January 19, 2026 18:35
Add a new --internal-cidr flag that allows users to specify which CIDRs
should be considered during internal IP auto-detection. This flag can
be specified multiple times to allow multiple CIDRs.

When set, only IPs within these CIDRs will be selected as the internal
IP, preventing incorrect IP selection (e.g., when CiliumInternalIP is
chosen over the real node IP due to lexicographic sorting).

Example usage:
  --internal-cidr=192.168.0.0/16
  --internal-cidr=$(NODE_IP)/32

Also update manifests for cilium and flannel deployments to use this
flag with NODE_IP from Kubernetes Downward API.

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
@kvaps kvaps force-pushed the feature/internal-cidr-flag branch from 0ada870 to 802bfb8 Compare February 23, 2026 16:47
squat
squat previously approved these changes Feb 23, 2026
Copy link
Copy Markdown
Owner

@squat squat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is awesome 👍

@squat squat enabled auto-merge February 23, 2026 16:55
Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
auto-merge was automatically disabled February 23, 2026 17:07

Head branch was pushed to by a user without write access

@squat squat merged commit 840176b into squat:main Feb 23, 2026
23 of 26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants