github.com/tigera/api@v0.0.0-20240320170621-278e89a8c5fb/pkg/apis/projectcalico/v3/externalnetwork.go (about)

     1  // Copyright (c) 2022 Tigera, Inc. All rights reserved.
     2  
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package v3
    16  
    17  import (
    18  	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    19  )
    20  
    21  const (
    22  	KindExternalNetwork     = "ExternalNetwork"
    23  	KindExternalNetworkList = "ExternalNetworkList"
    24  )
    25  
    26  // +genclient:nonNamespaced
    27  // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
    28  
    29  // ExternalNetworkList is a list of ExternalNetwork resources.
    30  type ExternalNetworkList struct {
    31  	metav1.TypeMeta `json:",inline"`
    32  	metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
    33  
    34  	Items []ExternalNetwork `json:"items" protobuf:"bytes,2,rep,name=items"`
    35  }
    36  
    37  // +genclient
    38  // +genclient:nonNamespaced
    39  // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
    40  
    41  type ExternalNetwork struct {
    42  	metav1.TypeMeta   `json:",inline"`
    43  	metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
    44  
    45  	Spec ExternalNetworkSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"`
    46  }
    47  
    48  // ExternalNetworkSpec contains the specification for a external network resource.
    49  type ExternalNetworkSpec struct {
    50  	// The index of a linux kernel routing table that should be used for the routes associated with the external network.
    51  	// The value should be unique for each external network.
    52  	// The value should not be in the range of `RouteTableRanges` field in FelixConfiguration.
    53  	// The kernel routing table index should not be used by other processes on the node.
    54  	RouteTableIndex *uint32 `json:"routeTableIndex" validate:"required"`
    55  }
    56  
    57  // New ExternalNetwork creates a new (zeroed) ExternalNetwork struct with the TypeMetadata
    58  // initialized to the current version.
    59  func NewExternalNetwork() *ExternalNetwork {
    60  	return &ExternalNetwork{
    61  		TypeMeta: metav1.TypeMeta{
    62  			Kind:       KindExternalNetwork,
    63  			APIVersion: GroupVersionCurrent,
    64  		},
    65  	}
    66  }