Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Internal Network APIs #2155

Merged
Merged
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
94 changes: 94 additions & 0 deletions apis/networking/v1alpha1/internalfabric.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
// Copyright 2019-2023 The Liqo Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package v1alpha1

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

// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.

// InternalFabricResource the name of the internalFabric resources.
var InternalFabricResource = "internalfabrics"

// InternalFabricKind is the kind name used to register the InternalFabric CRD.
var InternalFabricKind = "InternalFabric"

// InternalFabricGroupResource is group resource used to register these objects.
var InternalFabricGroupResource = schema.GroupResource{Group: GroupVersion.Group, Resource: InternalFabricResource}

// InternalFabricGroupVersionResource is groupResourceVersion used to register these objects.
var InternalFabricGroupVersionResource = GroupVersion.WithResource(InternalFabricResource)

// InternalEndpoint defines the endpoint of the internal fabric.
type InternalEndpoint struct {
// IP is the IP address of the endpoint.
IP string `json:"ip,omitempty"`
// Port is the port of the endpoint.
Port int `json:"port,omitempty"`
}

// InternalFabricSpec defines the desired state of InternalFabric.
type InternalFabricSpec struct {
// MTU is the MTU of the internal fabric.
MTU int `json:"mtu,omitempty"`
// GatewayIP is the IP address to assign to the gateway internal interface.
GatewayIP string `json:"gatewayIP,omitempty"`
// RemoteCIDRs is the list of remote CIDRs to be routed through the gateway.
RemoteCIDRs []string `json:"remoteCIDRs,omitempty"`
// NodeName is the name of the node where the gateway is running.
NodeName string `json:"nodeName,omitempty"`
// Endpoint is the endpoint of the gateway.
Endpoint InternalEndpoint `json:"endpoint,omitempty"`
}

// InternalFabricStatus defines the observed state of InternalFabric.
type InternalFabricStatus struct {
// AssignedIPs is the list of IP addresses assigned to interfaces in the nodes.
AssignedIPs []string `json:"assignedIPs,omitempty"`
}

// +kubebuilder:object:root=true
// +kubebuilder:resource:categories=liqo
// +kubebuilder:subresource:status
// +kubebuilder:printcolumn:name="Gateway Node",type=string,JSONPath=`.spec.nodeName`
// +kubebuilder:printcolumn:name="Gateway IP",type=string,JSONPath=`.spec.endpoint.ip`
// +kubebuilder:printcolumn:name="Gateway Port",type=string,JSONPath=`.spec.endpoint.port`
// +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp`

// InternalFabric contains the network internalfabric of a pair of clusters,
// including the local and the remote pod and external CIDRs and how the where remapped.
type InternalFabric struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec InternalFabricSpec `json:"spec,omitempty"`
Status InternalFabricStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true

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

func init() {
SchemeBuilder.Register(&InternalFabric{}, &InternalFabricList{})
}
108 changes: 108 additions & 0 deletions apis/networking/v1alpha1/internalnode.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
// Copyright 2019-2023 The Liqo Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package v1alpha1

import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
)

// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.

// InternalNodeResource the name of the internalNode resources.
var InternalNodeResource = "internalnodes"

// InternalNodeKind is the kind name used to register the InternalNode CRD.
var InternalNodeKind = "InternalNode"

// InternalNodeGroupResource is group resource used to register these objects.
var InternalNodeGroupResource = schema.GroupResource{Group: GroupVersion.Group, Resource: InternalNodeResource}

// InternalNodeGroupVersionResource is groupResourceVersion used to register these objects.
var InternalNodeGroupVersionResource = GroupVersion.WithResource(InternalNodeResource)

// InternalNodeSpec defines the desired state of InternalNode.
type InternalNodeSpec struct {
// FabricRef is the reference to the internal fabric.
FabricRef *corev1.ObjectReference `json:"fabricRef,omitempty"`
// IP is the IP address to assign to the internal interface.
IP string `json:"ip,omitempty"`
// IsGateway is true if the node is the gateway.
IsGateway bool `json:"isGateway,omitempty"`
}

// InternalNodeConditionType is a valid value for InternalNodeCondition.Type.
type InternalNodeConditionType string

const (
// InternalNodeConditionTypeApplied means the route has been applied.
InternalNodeConditionTypeApplied InternalNodeConditionType = "Applied"
)

// InternalNodeCondition contains details for the current condition of this node.
type InternalNodeCondition struct {
// Type is the type of the condition.
// +kubebuilder:validation:Enum=Applied
Type InternalNodeConditionType `json:"type"`
// Status is the status of the condition.
// +kubebuilder:validation:Enum=True;False;Unknown
// +kubebuilder:default=Unknown
Status corev1.ConditionStatus `json:"status"`
// LastTransitionTime is the last time the condition transitioned from one status to another.
LastTransitionTime metav1.Time `json:"lastTransitionTime"`
// Reason is a unique, one-word, CamelCase reason for the condition's last transition.
Reason string `json:"reason,omitempty"`
// Message is a human-readable message indicating details about last transition.
Message string `json:"message,omitempty"`
}

// InternalNodeStatus defines the observed state of InternalNode.
type InternalNodeStatus struct {
// Conditions contains information about the current status of the node.
Conditions []InternalNodeCondition `json:"conditions,omitempty"`
}

// +kubebuilder:object:root=true
// +kubebuilder:resource:categories=liqo
// +kubebuilder:subresource:status
// +kubebuilder:printcolumn:name="Fabric",type=string,JSONPath=`.spec.fabricRef.name`
// +kubebuilder:printcolumn:name="Fabric Namespace",type=string,JSONPath=`.spec.fabricRef.namespace`, priority=1
// +kubebuilder:printcolumn:name="Status",type=string,JSONPath=`.status.conditions[?(@.type == 'Applied')].status`
// +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp`

// InternalNode contains the network internalnode of a pair of clusters,
// including the local and the remote pod and external CIDRs and how the where remapped.
type InternalNode struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec InternalNodeSpec `json:"spec,omitempty"`
Status InternalNodeStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true

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

func init() {
SchemeBuilder.Register(&InternalNode{}, &InternalNodeList{})
}
126 changes: 126 additions & 0 deletions apis/networking/v1alpha1/route.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
// Copyright 2019-2023 The Liqo Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package v1alpha1

import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
)

// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.

// RouteResource the name of the route resources.
var RouteResource = "routes"

// RouteKind is the kind name used to register the Route CRD.
var RouteKind = "Route"

// RouteGroupResource is group resource used to register these objects.
var RouteGroupResource = schema.GroupResource{Group: GroupVersion.Group, Resource: RouteResource}

// RouteGroupVersionResource is groupResourceVersion used to register these objects.
var RouteGroupVersionResource = GroupVersion.WithResource(RouteResource)

// RouteDestination defines the destination of the route.
type RouteDestination struct {
// IP is the IP address of the destination. It is mutually exclusive with CIDR.
IP *string `json:"ip,omitempty"`
// CIDR is the CIDR of the destination. It is mutually exclusive with IP.
CIDR *string `json:"cidr,omitempty"`
}

// RouteNextHop defines the next hop of the route.
type RouteNextHop struct {
// IP is the IP address of the next hop. It is mutually exclusive with Dev.
IP *string `json:"ip,omitempty"`
// Dev is the name of the device of the next hop. It is mutually exclusive with IP.
Dev *string `json:"dev,omitempty"`
}

// RouteSpec defines the desired state of Route.
type RouteSpec struct {
// Dest is the destination of the route.
Dest *RouteDestination `json:"dest,omitempty"`
// NextHop is the next hop of the route.
NextHop *RouteNextHop `json:"nextHop,omitempty"`
// Table is the table of the route.
Table string `json:"table,omitempty"`
}

// RouteConditionType is a valid value for RouteCondition.Type.
type RouteConditionType string

const (
// RouteConditionTypeApplied means the route has been applied.
RouteConditionTypeApplied RouteConditionType = "Applied"
)

// RouteCondition contains details for the current condition of this route.
type RouteCondition struct {
// Type is the type of the condition.
// +kubebuilder:validation:Enum=Applied
Type RouteConditionType `json:"type"`
// Status is the status of the condition.
// +kubebuilder:validation:Enum=True;False;Unknown
// +kubebuilder:default=Unknown
Status corev1.ConditionStatus `json:"status"`
// LastTransitionTime is the last time the condition transitioned from one status to another.
LastTransitionTime metav1.Time `json:"lastTransitionTime"`
// Reason is a unique, one-word, CamelCase reason for the condition's last transition.
Reason string `json:"reason,omitempty"`
// Message is a human-readable message indicating details about last transition.
Message string `json:"message,omitempty"`
}

// RouteStatus defines the observed state of Route.
type RouteStatus struct {
// Conditions contains information about the current status of the route.
Conditions []RouteCondition `json:"conditions,omitempty"`
}

// +kubebuilder:object:root=true
// +kubebuilder:resource:categories=liqo
// +kubebuilder:subresource:status
// +kubebuilder:printcolumn:name="Destination IP",type=string,JSONPath=`.spec.dest.ip`
// +kubebuilder:printcolumn:name="Destination CIDR",type=string,JSONPath=`.spec.dest.cidr`
// +kubebuilder:printcolumn:name="Next Hop IP",type=string,JSONPath=`.spec.nextHop.ip`, priority=1
// +kubebuilder:printcolumn:name="Next Hop Dev",type=string,JSONPath=`.spec.nextHop.dev`, priority=1
// +kubebuilder:printcolumn:name="Status",type=string,JSONPath=`.status.conditions[?(@.type == 'Applied')].status`
// +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp`

// Route contains the network route of a pair of clusters,
// including the local and the remote pod and external CIDRs and how the where remapped.
type Route struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec RouteSpec `json:"spec,omitempty"`
Status RouteStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true

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

func init() {
SchemeBuilder.Register(&Route{}, &RouteList{})
}
Loading