|
| 1 | +/* |
| 2 | +Copyright 2023 The Nephio Authors. |
| 3 | +
|
| 4 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +you may not use this file except in compliance with the License. |
| 6 | +You may obtain a copy of the License at |
| 7 | +
|
| 8 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +
|
| 10 | +Unless required by applicable law or agreed to in writing, software |
| 11 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +See the License for the specific language governing permissions and |
| 14 | +limitations under the License. |
| 15 | +*/ |
| 16 | +package v1alpha1 |
| 17 | + |
| 18 | +import ( |
| 19 | + nephioreqv1alpha1 "github.com/nephio-project/api/nf_requirements/v1alpha1" |
| 20 | + corev1 "k8s.io/api/core/v1" |
| 21 | + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 22 | +) |
| 23 | + |
| 24 | +// NFDeploymentSpec defines the characteristics of a deployment of a network function |
| 25 | +type NFDeploymentSpec struct { |
| 26 | + // capacity defines the capacity characteristics of the NF deployment |
| 27 | + // +optional |
| 28 | + Capacity *nephioreqv1alpha1.CapacitySpec `json:"capacity,omitempty" yaml:"capacity,omitempty"` |
| 29 | + // Interfaces defines the interfaces associated with the NF deployment |
| 30 | + // +optional |
| 31 | + Interfaces []InterfaceConfig `json:"interfaces,omitempty" yaml:"interfaces,omitempty"` |
| 32 | + // NetworkInstances defines the network instances associated with the NF deployment |
| 33 | + // +optional |
| 34 | + NetworkInstances []NetworkInstance `json:"networkInstances,omitempty" yaml:"networkInstances,omitempty"` |
| 35 | + // configRef defines addiitonal configuration references the nf depends upon |
| 36 | + // +optional |
| 37 | + ConfigRefs []corev1.ObjectReference `json:"configRefs,omitempty" yaml:"configRefs,omitempty"` |
| 38 | +} |
| 39 | + |
| 40 | +// InterfaceConfig defines the configuration of the interface |
| 41 | +type InterfaceConfig struct { |
| 42 | + // Name defines the name of the interface |
| 43 | + // |
| 44 | + // +kubebuilder:validation:MinLength=1 |
| 45 | + // +kubebuilder:validation:MaxLength=253 |
| 46 | + Name string `json:"name" yaml:"name"` |
| 47 | + // IPv4 defines the ipv4 configuration of the interface |
| 48 | + // +optional |
| 49 | + IPv4 *IPv4 `json:"ipv4,omitempty" yaml:"ipv4,omitempty"` |
| 50 | + // IPv6Config defines the ipv6 configuration of the interface |
| 51 | + // +optional |
| 52 | + IPv6 *IPv6 `json:"ipv6,omitempty" yaml:"ipv6,omitempty"` |
| 53 | + // VLANID defines the specific vlan id associated on this interface |
| 54 | + // +optional |
| 55 | + VLANID *uint16 `json:"vlanID,omitempty" yaml:"vlanID,omitempty"` |
| 56 | +} |
| 57 | + |
| 58 | +// IPv4 defines the configuration parameters of an ipv4 interface or peer |
| 59 | +type IPv4 struct { |
| 60 | + // Address defines the IPv4 address and prefix length in CIDR notation |
| 61 | + // [IP prefix, range IPv4 with host bits] |
| 62 | + Address string `json:"address" yaml:"address"` |
| 63 | + // Gateway defines the IPv4 address associated to the interface as a gateway |
| 64 | + // +optional |
| 65 | + Gateway *string `json:"gateway,omitempty" yaml:"gateway,omitempty"` |
| 66 | +} |
| 67 | + |
| 68 | +// IPv6 defines the configuration parameters of an ipv6 interface or peer |
| 69 | +type IPv6 struct { |
| 70 | + // Address defines the IPv6 address and prefix length in CIDR notation |
| 71 | + // [IP prefix, range IPv6 with host bits] |
| 72 | + Address string `json:"address" yaml:"address"` |
| 73 | + // Gateway defines the IPv6 address associated to the interface as a gateway |
| 74 | + // +optional |
| 75 | + Gateway *string `json:"gateway,omitempty" yaml:"gateway,omitempty"` |
| 76 | +} |
| 77 | + |
| 78 | +// A networkInstance is a Layer 3 forwarding construct |
| 79 | +// such as a virtual routing and forwarding (VRF) instance, |
| 80 | +type NetworkInstance struct { |
| 81 | + // Name defines the name of the network instance |
| 82 | + // |
| 83 | + // +kubebuilder:validation:MinLength=1 |
| 84 | + // +kubebuilder:validation:MaxLength=253 |
| 85 | + Name string `json:"name" yaml:"name"` |
| 86 | + // interfaces defines the interfaces associated with the network instance |
| 87 | + // +optional |
| 88 | + Interfaces []string `json:"interfaces,omitempty" yaml:"interfaces,omitempty"` |
| 89 | + // Peers defines the peer configuration associated with the network instance |
| 90 | + // +optional |
| 91 | + Peers []PeerConfig `json:"peers,omitempty" yaml:"peers,omitempty"` |
| 92 | + // DataNetworks defines the data networks assocated with the network instance |
| 93 | + // +optional |
| 94 | + DataNetworks []DataNetwork `json:"dataNetworks,omitempty" yaml:"dataNetworks,omitempty"` |
| 95 | + // BGP defines the BGP configuration associated with the network instance |
| 96 | + // +optional |
| 97 | + BGP *BGPConfig `json:"bgp,omitempty" yaml:"bgp,omitempty"` |
| 98 | +} |
| 99 | + |
| 100 | +// A PeerConfig defines the peer configuration |
| 101 | +type PeerConfig struct { |
| 102 | + // Name defines the name of the data network |
| 103 | + // |
| 104 | + // +kubebuilder:validation:MinLength=1 |
| 105 | + // +kubebuilder:validation:MaxLength=253 |
| 106 | + Name *string `json:"name,omitempty" yaml:"name,omitempty"` |
| 107 | + // IPv4 defines the ipv4 configuration of the peer |
| 108 | + // +optional |
| 109 | + IPv4 *IPv4 `json:"ipv4,omitempty" yaml:"ipv4,omitempty"` |
| 110 | + // IPv6 defines the ipv6 configuration of the peer |
| 111 | + // +optional |
| 112 | + IPv6 *IPv6 `json:"ipv6,omitempty" yaml:"ipv6,omitempty"` |
| 113 | +} |
| 114 | + |
| 115 | +// A DataNetwork defines the Data Network name defined by 3GPP |
| 116 | +type DataNetwork struct { |
| 117 | + // Name defines the name of the data network |
| 118 | + // |
| 119 | + // +kubebuilder:validation:MinLength=1 |
| 120 | + // +kubebuilder:validation:MaxLength=253 |
| 121 | + Name *string `json:"name,omitempty" yaml:"name,omitempty"` |
| 122 | + // Pool defines the list of address pools associated with the data network |
| 123 | + // +optional |
| 124 | + Pool []Pool `json:"pool,omitempty" yaml:"pool,omitempty"` |
| 125 | +} |
| 126 | + |
| 127 | +type Pool struct { |
| 128 | + // Prefix defines the ip cidr in prefix notation. It is defines as a subnet |
| 129 | + // +kubebuilder:validation:Pattern=`(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])/(([0-9])|([1-2][0-9])|(3[0-2]))|((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))(/(([0-9])|([0-9]{2})|(1[0-1][0-9])|(12[0-8])))` |
| 130 | + Prefix string `json:"prefix" yaml:"prefix"` |
| 131 | +} |
| 132 | + |
| 133 | +// BGPConfig specifies parameters for BGP related configuration for UPF and SMF |
| 134 | +type BGPConfig struct { |
| 135 | + // RouterID defines the router ID of the bgp process |
| 136 | + RouterID string `json:"routerID" yaml:"routerID"` |
| 137 | + // AutonomousSystem defines the AS number of the bgp process |
| 138 | + AutonomousSystem int `json:"autonomousSystem" yaml:"autonomousSystem"` |
| 139 | + // BGPNeigbors defines the configuration of the BGP neighbor |
| 140 | + BGPNeigbors []BGPNeighbor `json:"bgpNeighbors" yaml:"bgpNeighbors"` |
| 141 | +} |
| 142 | + |
| 143 | +type BGPNeighbor struct { |
| 144 | + // Address defines the IPv4 or IPv6 address of the BGP neighbor |
| 145 | + Address string `json:"address" yaml:"address"` |
| 146 | + // BGP interface name, MUST match the one use in InterfaceConfig |
| 147 | + Name *string `json:"name,omitempty" yaml:"name,omitempty"` |
| 148 | + // PeerAS defines the AS number of the bgp peer |
| 149 | + PeerAS int `json:"peerAS" yaml:"peerAS"` |
| 150 | +} |
| 151 | + |
| 152 | +// NFDeploymentStatus defines the observed state of nf deployment |
| 153 | +type NFDeploymentStatus struct { |
| 154 | + // The generation observed by the deployment controller. |
| 155 | + ObservedGeneration int32 `json:"observedGeneration" yaml:"observedGeneration"` |
| 156 | + // Conditions define the current state of the NF deployment |
| 157 | + Conditions []metav1.Condition `json:"conditions,omitempty" yaml:"conditions,omitempty"` |
| 158 | +} |
| 159 | + |
| 160 | +type NFDeploymentConditionType string |
| 161 | + |
| 162 | +const ( |
| 163 | + // Reconciling implies that the deployment is progressing. |
| 164 | + // Reconciliation for a deployment is considered when a new version |
| 165 | + // is adopted, when new pods scale up or old pods scale down, or when |
| 166 | + // required peering is in progress. |
| 167 | + // Condition name follows Kpt guidelines. |
| 168 | + Reconciling NFDeploymentConditionType = "Reconciling" |
| 169 | + // Deployment is unable to make progress towards Reconciliation. |
| 170 | + // Reasons could be Pod creation failure, Peering failure etc. |
| 171 | + // Condition name follows Kpt guidelines. |
| 172 | + Stalled NFDeploymentConditionType = "Stalled" |
| 173 | + // The Deployment is considered available when following conditions hold: |
| 174 | + // 1. At-least the minimal set of Pods are up and running for at-least |
| 175 | + //minReadySeconds. |
| 176 | + // 2. The Deployment is ready for required peering. |
| 177 | + Available NFDeploymentConditionType = "Available" |
| 178 | + // The Deployment is making progress towards peering on the required |
| 179 | + // interfaces. A successful peering implies that the NF is reachable by |
| 180 | + // the required peers and is a able to reach them. |
| 181 | + Peering NFDeploymentConditionType = "Peering" |
| 182 | + // The Deployment is available and has peered successfully on required |
| 183 | + // interfaces. |
| 184 | + // At this stage, the deployment is ready to serve requests. |
| 185 | + Ready NFDeploymentConditionType = "Ready" |
| 186 | +) |
0 commit comments