Skip to content

Commit

Permalink
REARv0.0.1 implementation in FLUIDOS Node workflow and data structures (
Browse files Browse the repository at this point in the history
  • Loading branch information
andreacv98 committed Jul 29, 2024
1 parent db5b073 commit e63b910
Show file tree
Hide file tree
Showing 142 changed files with 6,550 additions and 3,353 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ docs: helm-docs
manifests: controller-gen
rm -f deployments/node/crds/*
$(CONTROLLER_GEN) paths="./apis/..." crd:generateEmbeddedObjectMeta=true output:crd:artifacts:config=deployments/node/crds
$(CONTROLLER_GEN) rbac:roleName=manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases

#Generate RBAC for each controller
rbacs: controller-gen
Expand Down
18 changes: 13 additions & 5 deletions PROJECT
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
domain: github.com/fluidos-project/
# Code generated by tool. DO NOT EDIT.
# This file is used to track the info used to scaffold your project
# and allow the plugins properly work.
# More info: https://book.kubebuilder.io/reference/project-config.html
domain: fluidos.eu
layout:
- go.kubebuilder.io/v3
projectName: node
Expand All @@ -8,7 +12,7 @@ resources:
crdVersion: v1
namespaced: true
controller: true
domain: github.com/fluidos-project/
domain: fluidos.eu
group: nodecore
kind: Solver
path: github.com/fluidos-project/node/api/v1alpha1
Expand All @@ -17,16 +21,20 @@ resources:
crdVersion: v1
namespaced: true
controller: true
domain: github.com/fluidos-project/
domain: fluidos.eu
group: nodecore
kind: Flavour
kind: Flavor
path: github.com/fluidos-project/node/api/v1alpha1
version: v1alpha1
webhooks:
defaulting: true
validation: true
webhookVersion: v1
- api:
crdVersion: v1
namespaced: true
controller: true
domain: github.com/fluidos-project/
domain: fluidos.eu
group: nodecore
kind: Allocation
path: github.com/fluidos-project/node/api/v1alpha1
Expand Down
4 changes: 2 additions & 2 deletions apis/advertisement/v1alpha1/discovery_status.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2022-2023 FLUIDOS Project
// Copyright 2022-2024 FLUIDOS Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -19,7 +19,7 @@ import (
"github.com/fluidos-project/node/pkg/utils/tools"
)

// SetPhase sets the phase of the discovery
// SetPhase sets the phase of the discovery.
func (d *Discovery) SetPhase(phase nodecorev1alpha1.Phase, msg string) {
d.Status.Phase.Phase = phase
d.Status.Phase.LastChangeTime = tools.GetTimeNow()
Expand Down
14 changes: 7 additions & 7 deletions apis/advertisement/v1alpha1/discovery_types.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2022-2023 FLUIDOS Project
// Copyright 2022-2024 FLUIDOS Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -23,7 +23,7 @@ import (
// 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.

// DiscoverySpec defines the desired state of Discovery
// DiscoverySpec defines the desired state of Discovery.
type DiscoverySpec struct {

// This is the Solver ID of the solver that creates and so asks for the discovery.
Expand All @@ -32,14 +32,14 @@ type DiscoverySpec struct {

// This is the FlavourSelector that describes the characteristics of the intent that the solver is looking to satisfy
// This pattern corresponds to what has been defined in the REAR Protocol to do a discovery with a selector
Selector *nodecorev1alpha1.FlavourSelector `json:"selector"`
Selector *nodecorev1alpha1.Selector `json:"selector"`

// This flag indicates that needs to be established a subscription to the provider in case a match is found.
// In order to have periodic updates of the status of the matching Flavour
// In order to have periodic updates of the status of the matching Flavor
Subscribe bool `json:"subscribe"`
}

// DiscoveryStatus defines the observed state of Discovery
// DiscoveryStatus defines the observed state of Discovery.
type DiscoveryStatus struct {

// This is the current phase of the discovery
Expand All @@ -52,13 +52,13 @@ type DiscoveryStatus struct {
//+kubebuilder:object:root=true
//+kubebuilder:subresource:status

// Discovery is the Schema for the discoveries API.
// +kubebuilder:printcolumn:name="Solver ID",type=string,JSONPath=`.spec.solverID`
// +kubebuilder:printcolumn:name="Subscribe",type=boolean,JSONPath=`.spec.subscribe`
// +kubebuilder:printcolumn:name="PC Namespace",type=string,JSONPath=`.status.peeringCandidate.namespace`
// +kubebuilder:printcolumn:name="PC Name",type=string,JSONPath=`.status.peeringCandidate.name`
// +kubebuilder:printcolumn:name="Status",type=string,JSONPath=`.status.phase.phase`
// +kubebuilder:printcolumn:name="Message",type=string,JSONPath=`.status.phase.message`
// Discovery is the Schema for the discoveries API
type Discovery struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Expand All @@ -69,7 +69,7 @@ type Discovery struct {

//+kubebuilder:object:root=true

// DiscoveryList contains a list of Discovery
// DiscoveryList contains a list of Discovery.
type DiscoveryList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Expand Down
6 changes: 3 additions & 3 deletions apis/advertisement/v1alpha1/groupversion_info.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2022-2023 FLUIDOS Project
// Copyright 2022-2024 FLUIDOS Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -23,10 +23,10 @@ import (
)

var (
// GroupVersion is group version used to register these objects
// GroupVersion is group version used to register these objects.
GroupVersion = schema.GroupVersion{Group: "advertisement.fluidos.eu", Version: "v1alpha1"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme
// 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.
Expand Down
12 changes: 6 additions & 6 deletions apis/advertisement/v1alpha1/peeringcandidate_types.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2022-2023 FLUIDOS Project
// Copyright 2022-2024 FLUIDOS Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -23,16 +23,16 @@ import (
// 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.

// PeeringCandidateSpec defines the desired state of PeeringCandidate
// PeeringCandidateSpec defines the desired state of PeeringCandidate.
type PeeringCandidateSpec struct {
SolverID string `json:"solverID"`

Flavour nodecorev1alpha1.Flavour `json:"flavour"`
Flavor nodecorev1alpha1.Flavor `json:"flavor"`

Available bool `json:"available"`
}

// PeeringCandidateStatus defines the observed state of PeeringCandidate
// PeeringCandidateStatus defines the observed state of PeeringCandidate.
type PeeringCandidateStatus struct {

// This field represents the creation time of the PeeringCandidate.
Expand All @@ -45,7 +45,7 @@ type PeeringCandidateStatus struct {
//+kubebuilder:object:root=true
//+kubebuilder:subresource:status

// PeeringCandidate is the Schema for the peeringcandidates API
// PeeringCandidate is the Schema for the peeringcandidates API.
type PeeringCandidate struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Expand All @@ -56,7 +56,7 @@ type PeeringCandidate struct {

//+kubebuilder:object:root=true

// PeeringCandidateList contains a list of PeeringCandidate
// PeeringCandidateList contains a list of PeeringCandidate.
type PeeringCandidateList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Expand Down
6 changes: 3 additions & 3 deletions apis/advertisement/v1alpha1/zz_generated.deepcopy.go

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

2 changes: 1 addition & 1 deletion apis/nodecore/v1alpha1/allocation_status.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2022-2023 FLUIDOS Project
// Copyright 2022-2024 FLUIDOS Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
37 changes: 3 additions & 34 deletions apis/nodecore/v1alpha1/allocation_types.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2022-2023 FLUIDOS Project
// Copyright 2022-2024 FLUIDOS Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -18,21 +18,9 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

//nolint:revive // Do not need to repeat the same comment
type NodeType string

//nolint:revive // Do not need to repeat the same comment
type Status string

//nolint:revive // Do not need to repeat the same comment
type Destination string

// NodeType is the type of the node: Node (Physical node of the cluster) or VirtualNode (Remote node owned by a different cluster).
const (
Node NodeType = "Node"
VirtualNode NodeType = "VirtualNode"
)

// Status is the status of the allocation.
const (
Active Status = "Active"
Expand All @@ -42,31 +30,12 @@ const (
Error Status = "Error"
)

// Destination is the destination of the allocation: Local (the allocation will be used locally)
// or Remote (the allocation will be used from a remote cluster).
const (
Remote Destination = "Remote"
Local Destination = "Local"
)

// AllocationSpec defines the desired state of Allocation
// AllocationSpec defines the desired state of Allocation.
type AllocationSpec struct {
// This is the ID of the cluster that owns the allocation.
RemoteClusterID string `json:"remoteClusterID,omitempty"`

// This is the ID of the intent for which the allocation was created.
// It is used by the Node Orchestrator to identify the correct allocation for a given intent
IntentID string `json:"intentID"`

// This is the corresponding Node or VirtualNode local name
NodeName string `json:"nodeName"`

// This specifies the type of the node: Node (Physical node of the cluster) or VirtualNode (Remote node owned by a different cluster)
Type NodeType `json:"type"`

// This specifies if the destination of the allocation is local or remote so if the allocation will be used locally or from a remote cluster
Destination Destination `json:"destination"`

// This flag indicates if the allocation is a forwarding allocation
// if true it represents only a placeholder to undertand that the cluster is just a proxy to another cluster
Forwarding bool `json:"forwarding,omitempty"`
Expand Down Expand Up @@ -102,7 +71,7 @@ type Allocation struct {

//+kubebuilder:object:root=true

// AllocationList contains a list of Allocation
// AllocationList contains a list of Allocation.
type AllocationList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Expand Down
41 changes: 30 additions & 11 deletions apis/nodecore/v1alpha1/common.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2022-2023 FLUIDOS Project
// Copyright 2022-2024 FLUIDOS Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -14,7 +14,12 @@

package v1alpha1

import "k8s.io/apimachinery/pkg/api/resource"
import (
"encoding/json"
"fmt"

"k8s.io/apimachinery/pkg/runtime"
)

// Set of constants for the phases of the FLUIDOS Node modules.
const (
Expand Down Expand Up @@ -45,17 +50,15 @@ type NodeIdentity struct {
Domain string `json:"domain"`
NodeID string `json:"nodeID"`
IP string `json:"ip"`
LiqoID string `json:"liqoID,omitempty"`
}

// Partition is the partition of the flavour.
type Partition struct {
Architecture string `json:"architecture"`
CPU resource.Quantity `json:"cpu"`
Memory resource.Quantity `json:"memory"`
Pods resource.Quantity `json:"pods"`
Gpu resource.Quantity `json:"gpu,omitempty"`
EphemeralStorage resource.Quantity `json:"ephemeral-storage,omitempty"`
Storage resource.Quantity `json:"storage,omitempty"`
// Configuration represents the configuration of a FLUIDOS Node.
type Configuration struct {
// Identifier is the identifier of the configuration.
ConfigurationTypeIdentifier FlavorTypeIdentifier `json:"type"`
// ConfigurationData is the data of the configuration.
ConfigurationData runtime.RawExtension `json:"data"`
}

// LiqoCredentials contains the credentials of a Liqo cluster to enstablish a peering.
Expand All @@ -65,3 +68,19 @@ type LiqoCredentials struct {
Token string `json:"token"`
Endpoint string `json:"endpoint"`
}

// ParseConfiguration parses the configuration data into the correct type.
// Returns the FlavorTypeIdentifier, aka the ConfigurationTypeIdentifier and the configuration data.
func ParseConfiguration(p *Configuration) (FlavorTypeIdentifier, interface{}, error) {
var validationError error

switch p.ConfigurationTypeIdentifier {
case TypeK8Slice:
var partition K8SliceConfiguration
validationError = json.Unmarshal(p.ConfigurationData.Raw, &partition)
return TypeK8Slice, partition, validationError
// TODO: implement other type of partition (if any)
default:
return "", nil, fmt.Errorf("partition type %s not supported", p.ConfigurationTypeIdentifier)
}
}
Loading

0 comments on commit e63b910

Please sign in to comment.