Skip to content

Commit

Permalink
add external network apis
Browse files Browse the repository at this point in the history
  • Loading branch information
aleoli authored and cheina97 committed Sep 26, 2023
1 parent f8ed240 commit be49d79
Show file tree
Hide file tree
Showing 22 changed files with 20,555 additions and 0 deletions.
90 changes: 90 additions & 0 deletions apis/networking/v1alpha1/configuration_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
// 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.

// ConfigurationResource the name of the configuration resources.
var ConfigurationResource = "configurations"

// ConfigurationKind is the kind name used to register the Configuration CRD.
var ConfigurationKind = "Configuration"

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

// ConfigurationGroupVersionResource is groupResourceVersion used to register these objects.
var ConfigurationGroupVersionResource = GroupVersion.WithResource(ConfigurationResource)

// CIDR defines the CIDR of the cluster.
type CIDR struct {
// Pod CIDR of the cluster.
Pod string `json:"pod,omitempty"`
// External CIDR of the cluster.
External string `json:"external,omitempty"`
}

// ClusterConfig defines the configuration of a cluster.
type ClusterConfig struct {
// CIDR of the cluster.
CIDR CIDR `json:"cidr,omitempty"`
}

// ConfigurationSpec defines the desired state of Configuration.
type ConfigurationSpec struct {
// Local network configuration (the cluster where the resource is created).
Local ClusterConfig `json:"local,omitempty"`
// Remote network configuration (the other cluster).
Remote ClusterConfig `json:"remote,omitempty"`
}

// ConfigurationStatus defines the observed state of Configuration.
type ConfigurationStatus struct {
// Remote remapped configuration, it defines how the local cluster sees the remote cluster.
Remote *ClusterConfig `json:"remote,omitempty"`
}

// +kubebuilder:object:root=true
// +kubebuilder:resource:categories=liqo
// +kubebuilder:subresource:status

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

Spec ConfigurationSpec `json:"spec,omitempty"`
Status ConfigurationStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true

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

func init() {
SchemeBuilder.Register(&Configuration{}, &ConfigurationList{})
}
141 changes: 141 additions & 0 deletions apis/networking/v1alpha1/connection_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
// 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.

// ConnectionResource the name of the connection resources.
var ConnectionResource = "connections"

// ConnectionKind specifies the kind of the connection.
var ConnectionKind = "Connection"

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

// ConnectionGroupVersionResource is groupResourceVersion used to register these objects.
var ConnectionGroupVersionResource = GroupVersion.WithResource(ConnectionResource)

// ConnectionType represents the type of a connection.
type ConnectionType string

const (
// ConnectionTypeServer represents a server connection.
ConnectionTypeServer ConnectionType = "Server"
// ConnectionTypeClient represents a client connection.
ConnectionTypeClient ConnectionType = "Client"
)

// PingSpec defines the desired state of Ping.
type PingSpec struct {
// Enabled specifies whether the ping is enabled or not.
// +kubebuilder:default=true
Enabled *bool `json:"enabled,omitempty"`
// Endpoint specifies the endpoint to ping.
Endpoint EndpointStatus `json:"endpoint,omitempty"`
}

// ConnectionSpec defines the desired state of Connection.
type ConnectionSpec struct {
// Type of the connection.
// +kubebuilder:validation:Enum=Server;Client
Type ConnectionType `json:"type"`
// GatewayRef specifies the reference to the gateway.
GatewayRef corev1.ObjectReference `json:"gatewayRef"`
// Ping specifies the ping configuration.
Ping PingSpec `json:"ping,omitempty"`
}

// ConnectionConditionType represents different conditions that a connection could assume.
type ConnectionConditionType string

const (
// ConnectionConditionEstablished represents a connection that is established.
ConnectionConditionEstablished ConnectionConditionType = "Established"
// ConnectionConditionPending represents a connection that is pending.
ConnectionConditionPending ConnectionConditionType = "Pending"
// ConnectionConditionDenied represents a connection that is denied.
ConnectionConditionDenied ConnectionConditionType = "Denied"
// ConnectionConditionError represents a connection that is in error.
ConnectionConditionError ConnectionConditionType = "Error"
)

// ConnectionConditionStatusType represents the status of a connection condition.
type ConnectionConditionStatusType string

const (
// ConnectionConditionStatusTrue represents a connection condition that is true.
ConnectionConditionStatusTrue ConnectionConditionStatusType = "True"
// ConnectionConditionStatusFalse represents a connection condition that is false.
ConnectionConditionStatusFalse ConnectionConditionStatusType = "False"
// ConnectionConditionStatusUnknown represents a connection condition that is unknown.
ConnectionConditionStatusUnknown ConnectionConditionStatusType = "Unknown"
)

// ConnectionCondition contains details about state of the connection.
type ConnectionCondition struct {
// Type of the connection condition.
// +kubebuilder:validation:Enum="Established"
Type ConnectionConditionType `json:"type"`
// Status of the condition.
// +kubebuilder:validation:Enum="True";"False";"Unknown"
// +kubebuilder:default="Unknown"
Status ConnectionConditionStatusType `json:"status"`
// LastTransitionTime -> timestamp for when the condition last transitioned from one status to another.
LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty"`
// Reason -> Machine-readable, UpperCamelCase text indicating the reason for the condition's last transition.
Reason string `json:"reason,omitempty"`
// Message -> Human-readable message indicating details about the last status transition.
Message string `json:"message,omitempty"`
}

// ConnectionStatus defines the observed state of Connection.
type ConnectionStatus struct {
// Conditions contains the conditions of the connection.
Conditions []ConnectionCondition `json:"conditions,omitempty"`
}

// +kubebuilder:object:root=true
// +kubebuilder:resource:categories=liqo
// +kubebuilder:subresource:status

// Connection contains the status of a connection between two clusters (a client and a server).
type Connection struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec ConnectionSpec `json:"spec,omitempty"`
Status ConnectionStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true

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

func init() {
SchemeBuilder.Register(&Connection{}, &ConnectionList{})
}
126 changes: 126 additions & 0 deletions apis/networking/v1alpha1/firewallconfiguration_types.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 (
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.

// FirewallConfigurationResource the name of the firewallconfiguration resources.
var FirewallConfigurationResource = "firewallconfigurations"

// FirewallConfigurationKind is the kind name used to register the FirewallConfiguration CRD.
var FirewallConfigurationKind = "FirewallConfiguration"

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

// FirewallConfigurationGroupVersionResource is groupResourceVersion used to register these objects.
var FirewallConfigurationGroupVersionResource = GroupVersion.WithResource(FirewallConfigurationResource)

// AddRemove contains the commands to add or remove rules.
type AddRemove struct {
// Add contains the commands to add rules.
Add []string `json:"add,omitempty"`
// Remove contains the commands to remove rules.
Remove []string `json:"remove,omitempty"`
}

// FirewallConfigurationSpec defines the desired state of FirewallConfiguration.
type FirewallConfigurationSpec struct {
// Command to add or remove rules.
Command AddRemove `json:"command,omitempty"`
// ExpectedRule contains the expected rule.
ExpectedRule string `json:"expectedRule,omitempty"`
// Table contains the table where the rule is applied.
Table string `json:"table,omitempty"`
}

// FirewallConfigurationConditionType represents different conditions that a firewallconfiguration could assume.
type FirewallConfigurationConditionType string

const (
// FirewallConfigurationConditionApplied represents the condition applied.
FirewallConfigurationConditionApplied FirewallConfigurationConditionType = "Applied"
// FirewallConfigurationConditionError represents the condition error.
FirewallConfigurationConditionError FirewallConfigurationConditionType = "Error"
// FirewallConfigurationConditionPending represents the condition pending.
FirewallConfigurationConditionPending FirewallConfigurationConditionType = "Pending"
)

// FirewallConfigurationConditionStatusType represents the status of a firewallconfiguration condition.
type FirewallConfigurationConditionStatusType string

const (
// FirewallConfigurationConditionStatusTrue represents the condition status true.
FirewallConfigurationConditionStatusTrue FirewallConfigurationConditionStatusType = "True"
// FirewallConfigurationConditionStatusFalse represents the condition status false.
FirewallConfigurationConditionStatusFalse FirewallConfigurationConditionStatusType = "False"
// FirewallConfigurationConditionStatusUnknown represents the condition status unknown.
FirewallConfigurationConditionStatusUnknown FirewallConfigurationConditionStatusType = "Unknown"
)

// FirewallConfigurationCondition contains details about state of the firewallconfiguration.
type FirewallConfigurationCondition struct {
// Type of the firewallconfiguration condition.
// +kubebuilder:validation:Enum="Applied"
Type FirewallConfigurationConditionType `json:"type"`
// Status of the condition.
// +kubebuilder:validation:Enum="True";"False";"Unknown"
// +kubebuilder:default="Unknown"
Status FirewallConfigurationConditionStatusType `json:"status"`
// LastTransitionTime -> timestamp for when the condition last transitioned from one status to another.
LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty"`
// Reason -> Machine-readable, UpperCamelCase text indicating the reason for the condition's last transition.
Reason string `json:"reason,omitempty"`
// Message -> Human-readable message indicating details about the last status transition.
Message string `json:"message,omitempty"`
}

// FirewallConfigurationStatus defines the observed state of FirewallConfiguration.
type FirewallConfigurationStatus struct {
// Conditions contains the conditions of the firewallconfiguration.
Conditions []FirewallConfigurationCondition `json:"conditions,omitempty"`
}

// +kubebuilder:object:root=true
// +kubebuilder:resource:categories=liqo
// +kubebuilder:subresource:status

// FirewallConfiguration contains a rule to be applied to the firewall in the gateway.
type FirewallConfiguration struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec FirewallConfigurationSpec `json:"spec,omitempty"`
Status FirewallConfigurationStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true

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

func init() {
SchemeBuilder.Register(&FirewallConfiguration{}, &FirewallConfigurationList{})
}
Loading

0 comments on commit be49d79

Please sign in to comment.