Skip to content

Commit ec3d82f

Browse files
authored
REARv0.0.1 implementation in FLUIDOS Node workflow and data structures (#98) (#103)
1 parent db5b073 commit ec3d82f

File tree

142 files changed

+6551
-3353
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

142 files changed

+6551
-3353
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ docs: helm-docs
2222
manifests: controller-gen
2323
rm -f deployments/node/crds/*
2424
$(CONTROLLER_GEN) paths="./apis/..." crd:generateEmbeddedObjectMeta=true output:crd:artifacts:config=deployments/node/crds
25+
$(CONTROLLER_GEN) rbac:roleName=manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases
2526

2627
#Generate RBAC for each controller
2728
rbacs: controller-gen

PROJECT

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
domain: github.com/fluidos-project/
1+
# Code generated by tool. DO NOT EDIT.
2+
# This file is used to track the info used to scaffold your project
3+
# and allow the plugins properly work.
4+
# More info: https://book.kubebuilder.io/reference/project-config.html
5+
domain: fluidos.eu
26
layout:
37
- go.kubebuilder.io/v3
48
projectName: node
@@ -8,7 +12,7 @@ resources:
812
crdVersion: v1
913
namespaced: true
1014
controller: true
11-
domain: github.com/fluidos-project/
15+
domain: fluidos.eu
1216
group: nodecore
1317
kind: Solver
1418
path: github.com/fluidos-project/node/api/v1alpha1
@@ -17,16 +21,20 @@ resources:
1721
crdVersion: v1
1822
namespaced: true
1923
controller: true
20-
domain: github.com/fluidos-project/
24+
domain: fluidos.eu
2125
group: nodecore
22-
kind: Flavour
26+
kind: Flavor
2327
path: github.com/fluidos-project/node/api/v1alpha1
2428
version: v1alpha1
29+
webhooks:
30+
defaulting: true
31+
validation: true
32+
webhookVersion: v1
2533
- api:
2634
crdVersion: v1
2735
namespaced: true
2836
controller: true
29-
domain: github.com/fluidos-project/
37+
domain: fluidos.eu
3038
group: nodecore
3139
kind: Allocation
3240
path: github.com/fluidos-project/node/api/v1alpha1

apis/advertisement/v1alpha1/discovery_status.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2022-2023 FLUIDOS Project
1+
// Copyright 2022-2024 FLUIDOS Project
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -19,7 +19,7 @@ import (
1919
"github.com/fluidos-project/node/pkg/utils/tools"
2020
)
2121

22-
// SetPhase sets the phase of the discovery
22+
// SetPhase sets the phase of the discovery.
2323
func (d *Discovery) SetPhase(phase nodecorev1alpha1.Phase, msg string) {
2424
d.Status.Phase.Phase = phase
2525
d.Status.Phase.LastChangeTime = tools.GetTimeNow()

apis/advertisement/v1alpha1/discovery_types.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2022-2023 FLUIDOS Project
1+
// Copyright 2022-2024 FLUIDOS Project
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -23,7 +23,7 @@ import (
2323
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
2424
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
2525

26-
// DiscoverySpec defines the desired state of Discovery
26+
// DiscoverySpec defines the desired state of Discovery.
2727
type DiscoverySpec struct {
2828

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

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

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

42-
// DiscoveryStatus defines the observed state of Discovery
42+
// DiscoveryStatus defines the observed state of Discovery.
4343
type DiscoveryStatus struct {
4444

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

55+
// Discovery is the Schema for the discoveries API.
5556
// +kubebuilder:printcolumn:name="Solver ID",type=string,JSONPath=`.spec.solverID`
5657
// +kubebuilder:printcolumn:name="Subscribe",type=boolean,JSONPath=`.spec.subscribe`
5758
// +kubebuilder:printcolumn:name="PC Namespace",type=string,JSONPath=`.status.peeringCandidate.namespace`
5859
// +kubebuilder:printcolumn:name="PC Name",type=string,JSONPath=`.status.peeringCandidate.name`
5960
// +kubebuilder:printcolumn:name="Status",type=string,JSONPath=`.status.phase.phase`
6061
// +kubebuilder:printcolumn:name="Message",type=string,JSONPath=`.status.phase.message`
61-
// Discovery is the Schema for the discoveries API
6262
type Discovery struct {
6363
metav1.TypeMeta `json:",inline"`
6464
metav1.ObjectMeta `json:"metadata,omitempty"`
@@ -69,7 +69,7 @@ type Discovery struct {
6969

7070
//+kubebuilder:object:root=true
7171

72-
// DiscoveryList contains a list of Discovery
72+
// DiscoveryList contains a list of Discovery.
7373
type DiscoveryList struct {
7474
metav1.TypeMeta `json:",inline"`
7575
metav1.ListMeta `json:"metadata,omitempty"`

apis/advertisement/v1alpha1/groupversion_info.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2022-2023 FLUIDOS Project
1+
// Copyright 2022-2024 FLUIDOS Project
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -23,10 +23,10 @@ import (
2323
)
2424

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

29-
// SchemeBuilder is used to add go types to the GroupVersionKind scheme
29+
// SchemeBuilder is used to add go types to the GroupVersionKind scheme.
3030
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
3131

3232
// AddToScheme adds the types in this group-version to the given scheme.

apis/advertisement/v1alpha1/peeringcandidate_types.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2022-2023 FLUIDOS Project
1+
// Copyright 2022-2024 FLUIDOS Project
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -23,16 +23,16 @@ import (
2323
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
2424
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
2525

26-
// PeeringCandidateSpec defines the desired state of PeeringCandidate
26+
// PeeringCandidateSpec defines the desired state of PeeringCandidate.
2727
type PeeringCandidateSpec struct {
2828
SolverID string `json:"solverID"`
2929

30-
Flavour nodecorev1alpha1.Flavour `json:"flavour"`
30+
Flavor nodecorev1alpha1.Flavor `json:"flavor"`
3131

3232
Available bool `json:"available"`
3333
}
3434

35-
// PeeringCandidateStatus defines the observed state of PeeringCandidate
35+
// PeeringCandidateStatus defines the observed state of PeeringCandidate.
3636
type PeeringCandidateStatus struct {
3737

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

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

5757
//+kubebuilder:object:root=true
5858

59-
// PeeringCandidateList contains a list of PeeringCandidate
59+
// PeeringCandidateList contains a list of PeeringCandidate.
6060
type PeeringCandidateList struct {
6161
metav1.TypeMeta `json:",inline"`
6262
metav1.ListMeta `json:"metadata,omitempty"`

apis/advertisement/v1alpha1/zz_generated.deepcopy.go

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apis/nodecore/v1alpha1/allocation_status.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2022-2023 FLUIDOS Project
1+
// Copyright 2022-2024 FLUIDOS Project
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.

apis/nodecore/v1alpha1/allocation_types.go

Lines changed: 3 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2022-2023 FLUIDOS Project
1+
// Copyright 2022-2024 FLUIDOS Project
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -18,21 +18,9 @@ import (
1818
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1919
)
2020

21-
//nolint:revive // Do not need to repeat the same comment
22-
type NodeType string
23-
2421
//nolint:revive // Do not need to repeat the same comment
2522
type Status string
2623

27-
//nolint:revive // Do not need to repeat the same comment
28-
type Destination string
29-
30-
// NodeType is the type of the node: Node (Physical node of the cluster) or VirtualNode (Remote node owned by a different cluster).
31-
const (
32-
Node NodeType = "Node"
33-
VirtualNode NodeType = "VirtualNode"
34-
)
35-
3624
// Status is the status of the allocation.
3725
const (
3826
Active Status = "Active"
@@ -42,31 +30,12 @@ const (
4230
Error Status = "Error"
4331
)
4432

45-
// Destination is the destination of the allocation: Local (the allocation will be used locally)
46-
// or Remote (the allocation will be used from a remote cluster).
47-
const (
48-
Remote Destination = "Remote"
49-
Local Destination = "Local"
50-
)
51-
52-
// AllocationSpec defines the desired state of Allocation
33+
// AllocationSpec defines the desired state of Allocation.
5334
type AllocationSpec struct {
54-
// This is the ID of the cluster that owns the allocation.
55-
RemoteClusterID string `json:"remoteClusterID,omitempty"`
56-
5735
// This is the ID of the intent for which the allocation was created.
5836
// It is used by the Node Orchestrator to identify the correct allocation for a given intent
5937
IntentID string `json:"intentID"`
6038

61-
// This is the corresponding Node or VirtualNode local name
62-
NodeName string `json:"nodeName"`
63-
64-
// This specifies the type of the node: Node (Physical node of the cluster) or VirtualNode (Remote node owned by a different cluster)
65-
Type NodeType `json:"type"`
66-
67-
// 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
68-
Destination Destination `json:"destination"`
69-
7039
// This flag indicates if the allocation is a forwarding allocation
7140
// if true it represents only a placeholder to undertand that the cluster is just a proxy to another cluster
7241
Forwarding bool `json:"forwarding,omitempty"`
@@ -102,7 +71,7 @@ type Allocation struct {
10271

10372
//+kubebuilder:object:root=true
10473

105-
// AllocationList contains a list of Allocation
74+
// AllocationList contains a list of Allocation.
10675
type AllocationList struct {
10776
metav1.TypeMeta `json:",inline"`
10877
metav1.ListMeta `json:"metadata,omitempty"`

apis/nodecore/v1alpha1/common.go

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2022-2023 FLUIDOS Project
1+
// Copyright 2022-2024 FLUIDOS Project
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -14,7 +14,12 @@
1414

1515
package v1alpha1
1616

17-
import "k8s.io/apimachinery/pkg/api/resource"
17+
import (
18+
"encoding/json"
19+
"fmt"
20+
21+
"k8s.io/apimachinery/pkg/runtime"
22+
)
1823

1924
// Set of constants for the phases of the FLUIDOS Node modules.
2025
const (
@@ -45,17 +50,15 @@ type NodeIdentity struct {
4550
Domain string `json:"domain"`
4651
NodeID string `json:"nodeID"`
4752
IP string `json:"ip"`
53+
LiqoID string `json:"liqoID,omitempty"`
4854
}
4955

50-
// Partition is the partition of the flavour.
51-
type Partition struct {
52-
Architecture string `json:"architecture"`
53-
CPU resource.Quantity `json:"cpu"`
54-
Memory resource.Quantity `json:"memory"`
55-
Pods resource.Quantity `json:"pods"`
56-
Gpu resource.Quantity `json:"gpu,omitempty"`
57-
EphemeralStorage resource.Quantity `json:"ephemeral-storage,omitempty"`
58-
Storage resource.Quantity `json:"storage,omitempty"`
56+
// Configuration represents the configuration of a FLUIDOS Node.
57+
type Configuration struct {
58+
// Identifier is the identifier of the configuration.
59+
ConfigurationTypeIdentifier FlavorTypeIdentifier `json:"type"`
60+
// ConfigurationData is the data of the configuration.
61+
ConfigurationData runtime.RawExtension `json:"data"`
5962
}
6063

6164
// LiqoCredentials contains the credentials of a Liqo cluster to enstablish a peering.
@@ -65,3 +68,19 @@ type LiqoCredentials struct {
6568
Token string `json:"token"`
6669
Endpoint string `json:"endpoint"`
6770
}
71+
72+
// ParseConfiguration parses the configuration data into the correct type.
73+
// Returns the FlavorTypeIdentifier, aka the ConfigurationTypeIdentifier and the configuration data.
74+
func ParseConfiguration(p *Configuration) (FlavorTypeIdentifier, interface{}, error) {
75+
var validationError error
76+
77+
switch p.ConfigurationTypeIdentifier {
78+
case TypeK8Slice:
79+
var partition K8SliceConfiguration
80+
validationError = json.Unmarshal(p.ConfigurationData.Raw, &partition)
81+
return TypeK8Slice, partition, validationError
82+
// TODO: implement other type of partition (if any)
83+
default:
84+
return "", nil, fmt.Errorf("partition type %s not supported", p.ConfigurationTypeIdentifier)
85+
}
86+
}

0 commit comments

Comments
 (0)