-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: support static routes #49
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work! I added few minor comments
api/v1alpha1/ippool_type.go
Outdated
@@ -45,6 +45,10 @@ type IPPoolSpec struct { | |||
Gateway string `json:"gateway,omitempty"` | |||
// selector for nodes, if empty match all nodes | |||
NodeSelector *corev1.NodeSelector `json:"nodeSelector,omitempty"` | |||
// if true, add gateway as default gateway in the routes list | |||
DefaultGateway *bool `json:"defautGateway,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really want to use a pointer here? It looks like that "false" is a safe default
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with Yury, simple boolean should be enough I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
api/v1alpha1/validate_routes.go
Outdated
|
||
// validateRoutes validate routes: | ||
// - dst is a valid CIDR | ||
func validateRoutes(routes []Route, fldPath *field.Path) field.ErrorList { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should also validate that routes are from the same address family (ipv4, ipv6) as the pool
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
api/v1alpha1/validate_routes.go
Outdated
func validateRoutes(routes []Route, fldPath *field.Path) field.ErrorList { | ||
allErrs := field.ErrorList{} | ||
for i, r := range routes { | ||
_, _, err := net.ParseCIDR(r.Dst) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
net.ParserCIDR parses 0.0.0.0/0 as a valid CIDR. Do we want to filter default GW here to make sure that we will not create duplicate default route entries in case if DefaultGateway
is set to true and 0.0.0.0/0 is explicitly added to the routes list?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Just one comment to address with the bool. The rest are mostly nitpicks.
api/v1alpha1/ippool_type.go
Outdated
@@ -45,6 +45,10 @@ type IPPoolSpec struct { | |||
Gateway string `json:"gateway,omitempty"` | |||
// selector for nodes, if empty match all nodes | |||
NodeSelector *corev1.NodeSelector `json:"nodeSelector,omitempty"` | |||
// if true, add gateway as default gateway in the routes list | |||
DefaultGateway *bool `json:"defautGateway,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with Yury, simple boolean should be enough I think.
9c34adc
to
f614767
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR look good. LGTM. One small comment
pkg/pool/reader.go
Outdated
} | ||
|
||
// RouteSlice is a type alias for a slice of Route | ||
type RouteSlice []Route |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Do we need this type and functions below? It looks like it is not used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Support optional static routes in the CNI CmdAdd result. Signed-off-by: Fred Rolland <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Support optional static routes in the CNI CmdAdd result.