Skip to content

Commit

Permalink
integrate external network with peering
Browse files Browse the repository at this point in the history
  • Loading branch information
aleoli committed Oct 17, 2023
1 parent 6861dad commit 8926871
Show file tree
Hide file tree
Showing 4 changed files with 304 additions and 0 deletions.
74 changes: 74 additions & 0 deletions apis/networking/v1alpha1/externalnetwork_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
// 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.

// ExternalNetworkResource the name of the external network resources.
var ExternalNetworkResource = "externalnetworks"

// ExternalNetworkKind is the kind name used to register the ExternalNetwork CRD.
var ExternalNetworkKind = "ExternalNetwork"

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

// ExternalNetworkGroupVersionResource is groupResourceVersion used to register these objects.
var ExternalNetworkGroupVersionResource = GroupVersion.WithResource(ExternalNetworkResource)

// ExternalNetworkSpec defines the desired state of ExternalNetworks.
type ExternalNetworkSpec struct {
// Configuration contains the configuration for the originating cluster.
Configuration *ConfigurationSpec `json:"configuration,omitempty"`
}

// ExternalNetworkStatus defines the observed state of ExternalNetworks.
type ExternalNetworkStatus struct {
// Configuration contains the configuration for the target cluster.
Configuration *ConfigurationSpec `json:"configuration,omitempty"`
}

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

// ExternalNetwork is used to share information about the network configuration of a
// peer of clusters. It is replicated by the CRD replicator.
type ExternalNetwork struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec ExternalNetworkSpec `json:"spec,omitempty"`
Status ExternalNetworkStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true

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

func init() {
SchemeBuilder.Register(&ExternalNetwork{}, &ExternalNetworkList{})
}
99 changes: 99 additions & 0 deletions apis/networking/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.13.0
name: externalnetworks.networking.liqo.io
spec:
group: networking.liqo.io
names:
categories:
- liqo
kind: ExternalNetwork
listKind: ExternalNetworkList
plural: externalnetworks
singular: externalnetwork
scope: Namespaced
versions:
- name: v1alpha1
schema:
openAPIV3Schema:
description: ExternalNetwork is used to share information about the network
configuration of a peer of clusters. It is replicated by the CRD replicator.
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: ExternalNetworkSpec defines the desired state of ExternalNetworks.
properties:
configuration:
description: Configuration contains the configuration for the originating
cluster.
properties:
local:
description: Local network configuration (the cluster where the
resource is created).
properties:
cidr:
description: CIDR of the cluster.
properties:
external:
description: External CIDR of the cluster.
pattern: ^(([1-9]{0,1}[0-9]{0,2}|2[0-4][0-9]|25[0-5])\.){3}([1-9]{0,1}[0-9]{0,2}|2[0-4][0-9]|25[0-5])\/([0-9]|[1-2][0-9]|3[0-2])$
type: string
pod:
description: Pod CIDR of the cluster.
pattern: ^(([1-9]{0,1}[0-9]{0,2}|2[0-4][0-9]|25[0-5])\.){3}([1-9]{0,1}[0-9]{0,2}|2[0-4][0-9]|25[0-5])\/([0-9]|[1-2][0-9]|3[0-2])$
type: string
type: object
type: object
remote:
description: Remote network configuration (the other cluster).
properties:
cidr:
description: CIDR of the cluster.
properties:
external:
description: External CIDR of the cluster.
pattern: ^(([1-9]{0,1}[0-9]{0,2}|2[0-4][0-9]|25[0-5])\.){3}([1-9]{0,1}[0-9]{0,2}|2[0-4][0-9]|25[0-5])\/([0-9]|[1-2][0-9]|3[0-2])$
type: string
pod:
description: Pod CIDR of the cluster.
pattern: ^(([1-9]{0,1}[0-9]{0,2}|2[0-4][0-9]|25[0-5])\.){3}([1-9]{0,1}[0-9]{0,2}|2[0-4][0-9]|25[0-5])\/([0-9]|[1-2][0-9]|3[0-2])$
type: string
type: object
type: object
type: object
type: object
status:
description: ExternalNetworkStatus defines the observed state of ExternalNetworks.
properties:
configuration:
description: Configuration contains the configuration for the target
cluster.
properties:
local:
description: Local network configuration (the cluster where the
resource is created).
properties:
cidr:
description: CIDR of the cluster.
properties:
external:
description: External CIDR of the cluster.
pattern: ^(([1-9]{0,1}[0-9]{0,2}|2[0-4][0-9]|25[0-5])\.){3}([1-9]{0,1}[0-9]{0,2}|2[0-4][0-9]|25[0-5])\/([0-9]|[1-2][0-9]|3[0-2])$
type: string
pod:
description: Pod CIDR of the cluster.
pattern: ^(([1-9]{0,1}[0-9]{0,2}|2[0-4][0-9]|25[0-5])\.){3}([1-9]{0,1}[0-9]{0,2}|2[0-4][0-9]|25[0-5])\/([0-9]|[1-2][0-9]|3[0-2])$
type: string
type: object
type: object
remote:
description: Remote network configuration (the other cluster).
properties:
cidr:
description: CIDR of the cluster.
properties:
external:
description: External CIDR of the cluster.
pattern: ^(([1-9]{0,1}[0-9]{0,2}|2[0-4][0-9]|25[0-5])\.){3}([1-9]{0,1}[0-9]{0,2}|2[0-4][0-9]|25[0-5])\/([0-9]|[1-2][0-9]|3[0-2])$
type: string
pod:
description: Pod CIDR of the cluster.
pattern: ^(([1-9]{0,1}[0-9]{0,2}|2[0-4][0-9]|25[0-5])\.){3}([1-9]{0,1}[0-9]{0,2}|2[0-4][0-9]|25[0-5])\/([0-9]|[1-2][0-9]|3[0-2])$
type: string
type: object
type: object
type: object
type: object
type: object
served: true
storage: true
subresources:
status: {}
6 changes: 6 additions & 0 deletions internal/crdReplicator/resources/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (

discoveryv1alpha1 "github.com/liqotech/liqo/apis/discovery/v1alpha1"
netv1alpha1 "github.com/liqotech/liqo/apis/net/v1alpha1"
networkingv1alpha1 "github.com/liqotech/liqo/apis/networking/v1alpha1"
sharingv1alpha1 "github.com/liqotech/liqo/apis/sharing/v1alpha1"
vkv1alpha1 "github.com/liqotech/liqo/apis/virtualkubelet/v1alpha1"
"github.com/liqotech/liqo/pkg/consts"
Expand Down Expand Up @@ -58,5 +59,10 @@ func GetResourcesToReplicate() []Resource {
PeeringPhase: consts.PeeringPhaseOutgoing,
Ownership: consts.OwnershipShared,
},
{
GroupVersionResource: networkingv1alpha1.ExternalNetworkGroupVersionResource,
PeeringPhase: consts.PeeringPhaseEstablished,
Ownership: consts.OwnershipShared,
},
}
}

0 comments on commit 8926871

Please sign in to comment.