Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 63 additions & 1 deletion api/core/v1alpha1/routingpolicy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/util/intstr"
)

// RoutingPolicySpec defines the desired state of RoutingPolicy
Expand Down Expand Up @@ -96,7 +97,7 @@ const (
)

// BgpActions defines BGP-specific actions for a policy statement.
// +kubebuilder:validation:XValidation:rule="has(self.setCommunity) || has(self.setExtCommunity)",message="at least one BGP action must be specified"
// +kubebuilder:validation:XValidation:rule="has(self.setCommunity) || has(self.setExtCommunity) || has(self.setASPath)",message="at least one BGP action must be specified"
type BgpActions struct {
// SetCommunity configures BGP standard community attributes.
// +optional
Expand All @@ -105,6 +106,67 @@ type BgpActions struct {
// SetExtCommunity configures BGP extended community attributes.
// +optional
SetExtCommunity *SetExtCommunityAction `json:"setExtCommunity,omitempty"`

// SetASPath configures modifications to the BGP AS path attribute.
// Not all providers may support this action.
// +optional
SetASPath *SetASPathAction `json:"setASPath,omitempty"`
}

// SetASPathAction defines actions to modify the BGP AS path attribute.
// +kubebuilder:validation:XValidation:rule="has(self.prepend) || has(self.replace) || has(self.asNumber)",message="at least one AS path action must be specified"
type SetASPathAction struct {
// Prepend configures prepending to the AS path.
// +optional
Prepend *SetASPathPrepend `json:"prepend,omitempty"`

// Replace configures replacement of AS numbers in the AS path.
// +optional
Replace *SetASPathReplace `json:"replace,omitempty"`

// ASNumber sets the AS path to the specified AS number.
// Supports both plain format (1-4294967295) and dotted notation (1-65535.0-65535) as per RFC 5396.
// +optional
ASNumber *intstr.IntOrString `json:"asNumber,omitempty"`
}

// SetASPathPrepend configures prepending to the BGP AS path.
// Either asNumber or useLastAS must be specified, but not both.
// +kubebuilder:validation:XValidation:rule="has(self.asNumber) != has(self.useLastAS)",message="exactly one of asNumber or useLastAS must be specified"
type SetASPathPrepend struct {
// ASNumber is the autonomous system number to prepend to the AS path.
// Supports both plain format (1-4294967295) and dotted notation (1-65535.0-65535) as per RFC 5396.
// Mutually exclusive with useLastAS.
// +optional
ASNumber *intstr.IntOrString `json:"asNumber,omitempty"`

// UseLastAS prepends the last AS number in the existing AS path the specified number of times.
// Mutually exclusive with asNumber.
// +optional
// +kubebuilder:validation:Minimum=1
// +kubebuilder:validation:Maximum=10
UseLastAS *int32 `json:"useLastAS,omitempty"`
}

// SetASPathReplace configures replacement of AS numbers in the BGP AS path.
// Either privateAS or asNumber must be specified, but not both.
// +kubebuilder:validation:XValidation:rule="has(self.privateAS) != has(self.asNumber)",message="exactly one of privateAS or asNumber must be specified"
type SetASPathReplace struct {
// PrivateAS, when set to true, targets all private AS numbers in the path for replacement.
// Mutually exclusive with asNumber.
// +optional
PrivateAS bool `json:"privateAS,omitempty"`

// ASNumber targets a specific AS number in the path for replacement.
// Supports both plain format (1-4294967295) and dotted notation (1-65535.0-65535) as per RFC 5396.
// Mutually exclusive with privateAS.
// +optional
ASNumber *intstr.IntOrString `json:"asNumber,omitempty"`

// Replacement is the AS number to substitute in place of matched AS numbers.
// Supports both plain format (1-4294967295) and dotted notation (1-65535.0-65535) as per RFC 5396.
// +required
Replacement intstr.IntOrString `json:"replacement"`
}

// SetCommunityAction defines the action to set BGP standard communities.
Expand Down
82 changes: 82 additions & 0 deletions api/core/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,82 @@ spec:
BgpActions specifies BGP-specific actions to apply when the route is accepted.
Only applicable when RouteDisposition is AcceptRoute.
properties:
setASPath:
description: |-
SetASPath configures modifications to the BGP AS path attribute.
Not all providers may support this action.
properties:
asNumber:
anyOf:
- type: integer
- type: string
description: |-
ASNumber sets the AS path to the specified AS number.
Supports both plain format (1-4294967295) and dotted notation (1-65535.0-65535) as per RFC 5396.
x-kubernetes-int-or-string: true
prepend:
description: Prepend configures prepending to the
AS path.
properties:
asNumber:
anyOf:
- type: integer
- type: string
description: |-
ASNumber is the autonomous system number to prepend to the AS path.
Supports both plain format (1-4294967295) and dotted notation (1-65535.0-65535) as per RFC 5396.
Mutually exclusive with useLastAS.
x-kubernetes-int-or-string: true
useLastAS:
description: |-
UseLastAS prepends the last AS number in the existing AS path the specified number of times.
Mutually exclusive with asNumber.
format: int32
maximum: 10
minimum: 1
type: integer
type: object
x-kubernetes-validations:
- message: exactly one of asNumber or useLastAS
must be specified
rule: has(self.asNumber) != has(self.useLastAS)
replace:
description: Replace configures replacement of AS
numbers in the AS path.
properties:
asNumber:
anyOf:
- type: integer
- type: string
description: |-
ASNumber targets a specific AS number in the path for replacement.
Supports both plain format (1-4294967295) and dotted notation (1-65535.0-65535) as per RFC 5396.
Mutually exclusive with privateAS.
x-kubernetes-int-or-string: true
privateAS:
description: |-
PrivateAS, when set to true, targets all private AS numbers in the path for replacement.
Mutually exclusive with asNumber.
type: boolean
replacement:
anyOf:
- type: integer
- type: string
description: |-
Replacement is the AS number to substitute in place of matched AS numbers.
Supports both plain format (1-4294967295) and dotted notation (1-65535.0-65535) as per RFC 5396.
x-kubernetes-int-or-string: true
required:
- replacement
type: object
x-kubernetes-validations:
- message: exactly one of privateAS or asNumber
must be specified
rule: has(self.privateAS) != has(self.asNumber)
type: object
x-kubernetes-validations:
- message: at least one AS path action must be specified
rule: has(self.prepend) || has(self.replace) || has(self.asNumber)
setCommunity:
description: SetCommunity configures BGP standard community
attributes.
Expand Down Expand Up @@ -174,6 +250,7 @@ spec:
x-kubernetes-validations:
- message: at least one BGP action must be specified
rule: has(self.setCommunity) || has(self.setExtCommunity)
|| has(self.setASPath)
routeDisposition:
description: RouteDisposition specifies whether to accept
or reject the route.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,82 @@ spec:
BgpActions specifies BGP-specific actions to apply when the route is accepted.
Only applicable when RouteDisposition is AcceptRoute.
properties:
setASPath:
description: |-
SetASPath configures modifications to the BGP AS path attribute.
Not all providers may support this action.
properties:
asNumber:
anyOf:
- type: integer
- type: string
description: |-
ASNumber sets the AS path to the specified AS number.
Supports both plain format (1-4294967295) and dotted notation (1-65535.0-65535) as per RFC 5396.
x-kubernetes-int-or-string: true
prepend:
description: Prepend configures prepending to the
AS path.
properties:
asNumber:
anyOf:
- type: integer
- type: string
description: |-
ASNumber is the autonomous system number to prepend to the AS path.
Supports both plain format (1-4294967295) and dotted notation (1-65535.0-65535) as per RFC 5396.
Mutually exclusive with useLastAS.
x-kubernetes-int-or-string: true
useLastAS:
description: |-
UseLastAS prepends the last AS number in the existing AS path the specified number of times.
Mutually exclusive with asNumber.
format: int32
maximum: 10
minimum: 1
type: integer
type: object
x-kubernetes-validations:
- message: exactly one of asNumber or useLastAS
must be specified
rule: has(self.asNumber) != has(self.useLastAS)
replace:
description: Replace configures replacement of AS
numbers in the AS path.
properties:
asNumber:
anyOf:
- type: integer
- type: string
description: |-
ASNumber targets a specific AS number in the path for replacement.
Supports both plain format (1-4294967295) and dotted notation (1-65535.0-65535) as per RFC 5396.
Mutually exclusive with privateAS.
x-kubernetes-int-or-string: true
privateAS:
description: |-
PrivateAS, when set to true, targets all private AS numbers in the path for replacement.
Mutually exclusive with asNumber.
type: boolean
replacement:
anyOf:
- type: integer
- type: string
description: |-
Replacement is the AS number to substitute in place of matched AS numbers.
Supports both plain format (1-4294967295) and dotted notation (1-65535.0-65535) as per RFC 5396.
x-kubernetes-int-or-string: true
required:
- replacement
type: object
x-kubernetes-validations:
- message: exactly one of privateAS or asNumber
must be specified
rule: has(self.privateAS) != has(self.asNumber)
type: object
x-kubernetes-validations:
- message: at least one AS path action must be specified
rule: has(self.prepend) || has(self.replace) || has(self.asNumber)
setCommunity:
description: SetCommunity configures BGP standard community
attributes.
Expand Down Expand Up @@ -171,6 +247,7 @@ spec:
x-kubernetes-validations:
- message: at least one BGP action must be specified
rule: has(self.setCommunity) || has(self.setExtCommunity)
|| has(self.setASPath)
routeDisposition:
description: RouteDisposition specifies whether to accept
or reject the route.
Expand Down
Loading
Loading