-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from datum-cloud/feature/bootstrap-networking-apis
Initial commit of Datum Networking APIs.
- Loading branch information
Showing
41 changed files
with
2,789 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// SPDX-License-Identifier: AGPL-3.0-only | ||
|
||
// Package v1alpha contains API Schema definitions for the networking v1alpha API group. | ||
// +kubebuilder:object:generate=true | ||
// +groupName=networking.datumapis.com | ||
package v1alpha | ||
|
||
import ( | ||
"k8s.io/apimachinery/pkg/runtime/schema" | ||
"sigs.k8s.io/controller-runtime/pkg/scheme" | ||
) | ||
|
||
var ( | ||
// GroupVersion is group version used to register these objects. | ||
GroupVersion = schema.GroupVersion{Group: "networking.datumapis.com", Version: "v1alpha"} | ||
|
||
// SchemeBuilder is used to add go types to the GroupVersionKind scheme. | ||
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} | ||
|
||
// AddToScheme adds the types in this group-version to the given scheme. | ||
AddToScheme = SchemeBuilder.AddToScheme | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
// SPDX-License-Identifier: AGPL-3.0-only | ||
|
||
package v1alpha | ||
|
||
import ( | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
// +kubebuilder:validation:Enum=IPv4;IPv6 | ||
type IPFamily string | ||
|
||
const ( | ||
IPv4Protocol IPFamily = "IPv4" | ||
IPv6Protocol IPFamily = "IPv6" | ||
) | ||
|
||
// NetworkSpec defines the desired state of a Network | ||
type NetworkSpec struct { | ||
|
||
// IPAM settings for the network. | ||
// | ||
// +kubebuilder:validation:Required | ||
IPAM NetworkIPAM `json:"ipam,omitempty"` | ||
|
||
// IP Families to permit on a network. Defaults to IPv4. | ||
// | ||
// +kubebuilder:validation:Optional | ||
// +kubebuilder:default={IPv4} | ||
IPFamilies []IPFamily `json:"ipFamilies,omitempty"` | ||
|
||
// Network MTU. May be between 1300 and 8856. | ||
// | ||
// +kubebuilder:validation:Minimum=1300 | ||
// +kubebuilder:validation:Maximum=8856 | ||
// +kubebuilder:validation:Optional | ||
// +kubebuilder:default=1460 | ||
MTU int32 `json:"mtu,omitempty"` | ||
} | ||
|
||
type NetworkIPAMMode string | ||
|
||
const ( | ||
// Automatically allocate subnets in the network | ||
NetworkIPAMModeAuto NetworkIPAMMode = "Auto" | ||
|
||
// Leverage allocation policies or manually created subnets | ||
NetworkIPAMModePolicy NetworkIPAMMode = "Policy" | ||
) | ||
|
||
type NetworkIPAM struct { | ||
// IPAM mode | ||
// | ||
// +kubebuilder:validation:Required | ||
// +kubebuilder:validation:Enum=Auto;Policy | ||
Mode NetworkIPAMMode `json:"mode"` | ||
|
||
// IPv4 range to use in auto mode networks. Defaults to 10.128.0.0/9. | ||
// | ||
// +kubebuilder:validation:Optional | ||
IPV4Range *string `json:"ipv4Range,omitempty"` | ||
|
||
// IPv6 range to use in auto mode networks. Defaults to a /48 allocated from `fd20::/20`. | ||
// | ||
// +kubebuilder:validation:Optional | ||
IPV6Range *string `json:"ipv6Range,omitempty"` | ||
} | ||
|
||
// NetworkStatus defines the observed state of Network | ||
type NetworkStatus struct { | ||
// Represents the observations of a network's current state. | ||
Conditions []metav1.Condition `json:"conditions,omitempty"` | ||
} | ||
|
||
// +kubebuilder:object:root=true | ||
// +kubebuilder:subresource:status | ||
|
||
// Network is the Schema for the networks API | ||
type Network struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
// +kubebuilder:validation:Required | ||
Spec NetworkSpec `json:"spec,omitempty"` | ||
Status NetworkStatus `json:"status,omitempty"` | ||
} | ||
|
||
// +kubebuilder:object:root=true | ||
|
||
// NetworkList contains a list of Network | ||
type NetworkList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata,omitempty"` | ||
Items []Network `json:"items"` | ||
} | ||
|
||
type NetworkRef struct { | ||
// The network namespace. | ||
// | ||
// Defaults to the namespace for the type the reference is embedded in. | ||
// | ||
// +kubebuilder:validation:Optional | ||
Namespace string `json:"namespace,omitempty"` | ||
|
||
// The network name | ||
// | ||
// +kubebuilder:validation:Required | ||
Name string `json:"name,omitempty"` | ||
} | ||
|
||
type LocalNetworkRef struct { | ||
// The network name | ||
// | ||
// +kubebuilder:validation:Required | ||
Name string `json:"name,omitempty"` | ||
} | ||
|
||
func init() { | ||
SchemeBuilder.Register(&Network{}, &NetworkList{}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
// SPDX-License-Identifier: AGPL-3.0-only | ||
|
||
package v1alpha | ||
|
||
import ( | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
// NetworkBindingSpec defines the desired state of NetworkBinding | ||
type NetworkBindingSpec struct { | ||
// The network that the binding is for. | ||
// | ||
// +kubebuilder:validation:Required | ||
Network NetworkRef `json:"network,omitempty"` | ||
|
||
// The topology of where this binding exists | ||
// | ||
// This may contain arbitrary topology keys. Some keys may be well known, such | ||
// as: | ||
// - topology.datum.net/city-code | ||
// - topology.datum.net/cluster-name | ||
// - topology.datum.net/cluster-namespace | ||
// | ||
// Each unique value of this field across bindings in the namespace will result | ||
// in a NetworkAttachment to be created. | ||
// | ||
// +kubebuilder:validation:Required | ||
Topology map[string]string `json:"topology"` | ||
} | ||
|
||
// NetworkBindingObjectReference contains sufficient information for | ||
// controllers to leverage unstructured or structured clients to interact with | ||
// the bound resources. | ||
type NetworkBindingObjectReference struct { | ||
// API version of the referent. | ||
// | ||
// +kubebuilder:validation:Required | ||
APIVersion string `json:"apiVersion"` | ||
|
||
// Kind of the referent. | ||
// | ||
// +kubebuilder:validation:Required | ||
Kind string `json:"kind,omitempty"` | ||
|
||
// Namespace of the referent. | ||
// | ||
// +kubebuilder:validation:Required | ||
Namespace string `json:"namespace,omitempty"` | ||
|
||
// Name of the referent. | ||
// | ||
// +kubebuilder:validation:Required | ||
Name string `json:"name,omitempty"` | ||
} | ||
|
||
// NetworkBindingStatus defines the observed state of NetworkBinding | ||
type NetworkBindingStatus struct { | ||
NetworkContextRef *NetworkContextRef `json:"networkContextRef,omitempty"` | ||
|
||
// Represents the observations of a network binding's current state. | ||
Conditions []metav1.Condition `json:"conditions,omitempty"` | ||
} | ||
|
||
const ( | ||
// NetworkBindingReady indicates that the network binding has been associated | ||
// with a NetworkContext and the owning resource should expect functional | ||
// network features. | ||
NetworkBindingReady = "Ready" | ||
) | ||
|
||
// +kubebuilder:object:root=true | ||
// +kubebuilder:subresource:status | ||
|
||
// NetworkBinding is the Schema for the networkbindings API | ||
type NetworkBinding struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
// +kubebuilder:validation:Required | ||
Spec NetworkBindingSpec `json:"spec,omitempty"` | ||
Status NetworkBindingStatus `json:"status,omitempty"` | ||
} | ||
|
||
// +kubebuilder:object:root=true | ||
|
||
// NetworkBindingList contains a list of NetworkBinding | ||
type NetworkBindingList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata,omitempty"` | ||
Items []NetworkBinding `json:"items"` | ||
} | ||
|
||
func init() { | ||
SchemeBuilder.Register(&NetworkBinding{}, &NetworkBindingList{}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
// SPDX-License-Identifier: AGPL-3.0-only | ||
|
||
package v1alpha | ||
|
||
import ( | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
// NetworkContextSpec defines the desired state of NetworkContext | ||
type NetworkContextSpec struct { | ||
// The attached network | ||
// | ||
// +kubebuilder:validation:Required | ||
Network LocalNetworkRef `json:"network"` | ||
|
||
// The topology of where this context exists | ||
// | ||
// This may contain arbitrary topology keys. Some keys may be well known, such | ||
// as: | ||
// - topology.datum.net/city-code | ||
// - topology.datum.net/cluster-name | ||
// - topology.datum.net/cluster-namespace | ||
// | ||
// The combined keys and values MUST be unique for contexts in the same | ||
// network. | ||
// | ||
// +kubebuilder:validation:Required | ||
Topology map[string]string `json:"topology"` | ||
} | ||
|
||
// NetworkContextStatus defines the observed state of NetworkContext | ||
type NetworkContextStatus struct { | ||
// Represents the observations of a network context's current state. | ||
Conditions []metav1.Condition `json:"conditions,omitempty"` | ||
} | ||
|
||
const ( | ||
// NetworkContextReady indicates that the network context is ready for use. | ||
NetworkContextReady = "Ready" | ||
) | ||
|
||
// +kubebuilder:object:root=true | ||
// +kubebuilder:subresource:status | ||
|
||
// NetworkContext is the Schema for the networkcontexts API | ||
type NetworkContext struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
Spec NetworkContextSpec `json:"spec,omitempty"` | ||
Status NetworkContextStatus `json:"status,omitempty"` | ||
} | ||
|
||
// +kubebuilder:object:root=true | ||
|
||
// NetworkContextList contains a list of NetworkContext | ||
type NetworkContextList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata,omitempty"` | ||
Items []NetworkContext `json:"items"` | ||
} | ||
|
||
type NetworkContextRef struct { | ||
// The network context namespace | ||
// | ||
// +kubebuilder:validation:Required | ||
Namespace string `json:"namespace"` | ||
|
||
// The network context name | ||
// | ||
// +kubebuilder:validation:Required | ||
Name string `json:"name"` | ||
} | ||
|
||
type LocalNetworkContextRef struct { | ||
// The network context name | ||
// | ||
// +kubebuilder:validation:Required | ||
Name string `json:"name"` | ||
} | ||
|
||
func init() { | ||
SchemeBuilder.Register(&NetworkContext{}, &NetworkContextList{}) | ||
} |
Oops, something went wrong.