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
5 changes: 5 additions & 0 deletions Tiltfile
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ k8s_resource(new_name='bgp', objects=['bgp:bgp'], trigger_mode=TRIGGER_MODE_MANU
k8s_resource(new_name='bgp-vrf-cc-admin', objects=['bgp-vrf-cc-admin:bgp'], resource_deps=['vrf-admin'], trigger_mode=TRIGGER_MODE_MANUAL, auto_init=False, labels=['samples'])
k8s_resource(new_name='bgp-rdst', objects=['bgp-rdst:bgp'], resource_deps=['bgp-import-policy'], trigger_mode=TRIGGER_MODE_MANUAL, auto_init=False, labels=['samples'])

k8s_yaml('./config/samples/v1alpha1_communityset.yaml')
k8s_resource(new_name='communityset', objects=['communityset:communityset'], trigger_mode=TRIGGER_MODE_MANUAL, auto_init=False, labels=['samples'])
k8s_yaml('./config/samples/v1alpha1_extcommunityset.yaml')
k8s_resource(new_name='extcommunityset', objects=['extcommunityset:extcommunityset'], trigger_mode=TRIGGER_MODE_MANUAL, auto_init=False, labels=['samples'])

k8s_yaml('./config/samples/cisco/nx/v1alpha1_bgpconfig.yaml')
k8s_resource(new_name='bgpconfig-adv-pip', objects=['bgpconfig-adv-pip:bgpconfig'], trigger_mode=TRIGGER_MODE_MANUAL, auto_init=False, labels=['samples'])
k8s_resource(new_name='bgpconfig-export-gw', objects=['bgpconfig-export-gw:bgpconfig'], trigger_mode=TRIGGER_MODE_MANUAL, auto_init=False, labels=['samples'])
Expand Down
109 changes: 109 additions & 0 deletions api/core/v1alpha1/communityset_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
// SPDX-FileCopyrightText: 2025 SAP SE or an SAP affiliate company and IronCore contributors
// SPDX-License-Identifier: Apache-2.0

package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
)

// CommunityMember defines one ordered entry in a community-list with a regex pattern.
type CommunityMember struct {
// Sequence is the order of this entry in the community-list.
// +required
// +kubebuilder:validation:Minimum=1
Sequence int32 `json:"sequence"`

// Regex is a POSIX extended regular expression matching BGP community values.
// +required
// +kubebuilder:validation:MinLength=1
Regex string `json:"regex"`
}

// CommunitySetSpec defines the desired state of CommunitySet.
type CommunitySetSpec struct {
// DeviceRef is a reference to the Device this object belongs to. The Device object must exist in the same namespace.
// Immutable.
// +required
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="DeviceRef is immutable"
DeviceRef LocalObjectReference `json:"deviceRef"`

// ProviderConfigRef is a reference to a resource holding the provider-specific configuration.
// +optional
ProviderConfigRef *TypedLocalObjectReference `json:"providerConfigRef,omitempty"`

// Name is the name of the CommunitySet on the device.
// Immutable.
// +required
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=32
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Name is immutable"
Name string `json:"name"`

// Members is the ordered list of community-list entries.
// +required
// +listType=map
// +listMapKey=sequence
// +kubebuilder:validation:MinItems=1
// +kubebuilder:validation:MaxItems=100
Members []CommunityMember `json:"members"`
}

// CommunitySetStatus defines the observed state of CommunitySet.
type CommunitySetStatus struct {
// Conditions is a list of status conditions describing the state of the CommunitySet.
// +listType=map
// +listMapKey=type
// +patchStrategy=merge
// +patchMergeKey=type
// +optional
Conditions []metav1.Condition `json:"conditions,omitempty"`
}

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:resource:path=communitysets
// +kubebuilder:resource:singular=communityset
// +kubebuilder:printcolumn:name="Community Set",type=string,JSONPath=`.spec.name`
// +kubebuilder:printcolumn:name="Device",type=string,JSONPath=`.spec.deviceRef.name`
// +kubebuilder:printcolumn:name="Ready",type=string,JSONPath=`.status.conditions[?(@.type=="Ready")].status`
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"

// CommunitySet is the Schema for the communitysets API.
type CommunitySet struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

// +required
Spec CommunitySetSpec `json:"spec,omitempty"`

// +optional
Status CommunitySetStatus `json:"status,omitzero"`
}

// GetConditions implements conditions.Getter.
func (c *CommunitySet) GetConditions() []metav1.Condition {
return c.Status.Conditions
}

// SetConditions implements conditions.Setter.
func (c *CommunitySet) SetConditions(conditions []metav1.Condition) {
c.Status.Conditions = conditions
}

// +kubebuilder:object:root=true

// CommunitySetList contains a list of CommunitySet.
type CommunitySetList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitzero"`
Items []CommunitySet `json:"items"`
}

func init() {
SchemeBuilder.Register(func(s *runtime.Scheme) error {
s.AddKnownTypes(GroupVersion, &CommunitySet{}, &CommunitySetList{})
return nil
})
}
96 changes: 96 additions & 0 deletions api/core/v1alpha1/extcommunityset_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
// SPDX-FileCopyrightText: 2025 SAP SE or an SAP affiliate company and IronCore contributors
// SPDX-License-Identifier: Apache-2.0

package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
)

// ExtCommunitySetSpec defines the desired state of ExtCommunitySet.
type ExtCommunitySetSpec struct {
// DeviceRef is a reference to the Device this object belongs to. The Device object must exist in the same namespace.
// Immutable.
// +required
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="DeviceRef is immutable"
DeviceRef LocalObjectReference `json:"deviceRef"`

// ProviderConfigRef is a reference to a resource holding the provider-specific configuration.
// +optional
ProviderConfigRef *TypedLocalObjectReference `json:"providerConfigRef,omitempty"`

// Name is the name of the ExtCommunitySet on the device.
// Immutable.
// +required
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=32
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Name is immutable"
Name string `json:"name"`

// Members is the ordered list of extended community-list entries.
// +required
// +listType=map
// +listMapKey=sequence
// +kubebuilder:validation:MinItems=1
// +kubebuilder:validation:MaxItems=100
Members []CommunityMember `json:"members"`
}

// ExtCommunitySetStatus defines the observed state of ExtCommunitySet.
type ExtCommunitySetStatus struct {
// Conditions is a list of status conditions describing the state of the ExtCommunitySet.
// +listType=map
// +listMapKey=type
// +patchStrategy=merge
// +patchMergeKey=type
// +optional
Conditions []metav1.Condition `json:"conditions,omitempty"`
}

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:resource:path=extcommunitysets
// +kubebuilder:resource:singular=extcommunityset
// +kubebuilder:printcolumn:name="Ext Community Set",type=string,JSONPath=`.spec.name`
// +kubebuilder:printcolumn:name="Device",type=string,JSONPath=`.spec.deviceRef.name`
// +kubebuilder:printcolumn:name="Ready",type=string,JSONPath=`.status.conditions[?(@.type=="Ready")].status`
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"

// ExtCommunitySet is the Schema for the extcommunitysets API.
type ExtCommunitySet struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

// +required
Spec ExtCommunitySetSpec `json:"spec,omitempty"`

// +optional
Status ExtCommunitySetStatus `json:"status,omitzero"`
}

// GetConditions implements conditions.Getter.
func (e *ExtCommunitySet) GetConditions() []metav1.Condition {
return e.Status.Conditions
}

// SetConditions implements conditions.Setter.
func (e *ExtCommunitySet) SetConditions(conditions []metav1.Condition) {
e.Status.Conditions = conditions
}

// +kubebuilder:object:root=true

// ExtCommunitySetList contains a list of ExtCommunitySet.
type ExtCommunitySetList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitzero"`
Items []ExtCommunitySet `json:"items"`
}

func init() {
SchemeBuilder.Register(func(s *runtime.Scheme) error {
s.AddKnownTypes(GroupVersion, &ExtCommunitySet{}, &ExtCommunitySetList{})
return nil
})
}
Loading
Loading