diff --git a/.dockerignore b/.dockerignore deleted file mode 100644 index 0f04682..0000000 --- a/.dockerignore +++ /dev/null @@ -1,4 +0,0 @@ -# More info: https://docs.docker.com/engine/reference/builder/#dockerignore-file -# Ignore build and test binaries. -bin/ -testbin/ diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 9a23dc6..0000000 --- a/Dockerfile +++ /dev/null @@ -1,27 +0,0 @@ -# Build the manager binary -FROM golang:1.17 as builder - -WORKDIR /workspace -# Copy the Go Modules manifests -COPY go.mod go.mod -COPY go.sum go.sum -# cache deps before building and copying source so that we don't need to re-download as much -# and so that source changes don't invalidate our downloaded layer -RUN go mod download - -# Copy the go source -COPY main.go main.go -COPY apis/ apis/ -COPY controllers/ controllers/ - -# Build -RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o manager main.go - -# Use distroless as minimal base image to package the manager binary -# Refer to https://github.com/GoogleContainerTools/distroless for more details -FROM gcr.io/distroless/static:nonroot -WORKDIR / -COPY --from=builder /workspace/manager . -USER 65532:65532 - -ENTRYPOINT ["/manager"] diff --git a/Makefile b/Makefile deleted file mode 100644 index 2189fd2..0000000 --- a/Makefile +++ /dev/null @@ -1,117 +0,0 @@ -# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set) -ifeq (,$(shell go env GOBIN)) -GOBIN=$(shell go env GOPATH)/bin -else -GOBIN=$(shell go env GOBIN) -endif - -ifeq ($(shell uname),Darwin) -SED_COMMAND=sed -i '' -n '/rules/,$$p' -else -SED_COMMAND=sed -i -n '/rules/,$$p' -endif - -# generate: generate-controller generate-groups rbacs manifests fmt -generate: generate-controller rbacs manifests fmt - -#generate helm documentation -docs: helm-docs - $(HELM_DOCS) -t deployments/node/README.gotmpl deployments/node - -# Generate manifests e.g. CRD, RBAC etc. -manifests: controller-gen - rm -f deployments/node/crds/* - $(CONTROLLER_GEN) paths="./apis/..." crd:generateEmbeddedObjectMeta=true output:crd:artifacts:config=deployments/node/crds - -#Generate RBAC for each controller -rbacs: controller-gen - rm -f deployments/node/files/* - - $(CONTROLLER_GEN) paths="./pkg/local-resource-manager" rbac:roleName=fluidos-local-resource-manager output:rbac:stdout | awk -v RS="---\n" 'NR>1{f="./deployments/node/files/fluidos-local-resource-manager-" $$4 ".yaml";printf "%s",$$0 > f; close(f)}' && $(SED_COMMAND) deployments/node/files/fluidos-local-resource-manager-ClusterRole.yaml - $(CONTROLLER_GEN) paths="./pkg/rear-manager/" rbac:roleName=fluidos-rear-manager output:rbac:stdout | awk -v RS="---\n" 'NR>1{f="./deployments/node/files/fluidos-rear-manager-" $$4 ".yaml";printf "%s",$$0 > f; close(f)}' && $(SED_COMMAND) deployments/node/files/fluidos-rear-manager-ClusterRole.yaml - $(CONTROLLER_GEN) paths="./pkg/rear-controller/..." rbac:roleName=fluidos-rear-controller output:rbac:stdout | awk -v RS="---\n" 'NR>1{f="./deployments/node/files/fluidos-rear-controller-" $$4 ".yaml";printf "%s",$$0 > f; close(f)}' && $(SED_COMMAND) deployments/node/files/fluidos-rear-controller-ClusterRole.yaml - -# Install gci if not available -gci: -ifeq (, $(shell which gci)) - @go install github.com/daixiang0/gci@v0.11.2 -GCI=$(GOBIN)/gci -else -GCI=$(shell which gci) -endif - -# Install addlicense if not available -addlicense: -ifeq (, $(shell which addlicense)) - @go install github.com/google/addlicense@v1.0.0 -ADDLICENSE=$(GOBIN)/addlicense -else -ADDLICENSE=$(shell which addlicense) -endif - -# Run go fmt against code -fmt: gci addlicense - go mod tidy - go fmt ./... - find . -type f -name '*.go' -a ! -name '*zz_generated*' -exec $(GCI) write -s standard -s default -s "prefix(github.com/fluidos-project/node)" {} \; - find . -type f -name '*.go' -exec $(ADDLICENSE) -l apache -c "FLUIDOS Project" -y "2022-$(shell date +%Y)" {} \; - -# Install golangci-lint if not available -golangci-lint: -ifeq (, $(shell which golangci-lint)) - @go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.54.2 -GOLANGCILINT=$(GOBIN)/golangci-lint -else -GOLANGCILINT=$(shell which golangci-lint) -endif - -markdownlint: -ifeq (, $(shell which markdownlint)) - @echo "markdownlint is not installed. Please install it: https://github.com/igorshubovych/markdownlint-cli#installation" - @exit 1 -else -MARKDOWNLINT=$(shell which markdownlint) -endif - -md-lint: markdownlint - @find . -type f -name '*.md' -a -not -path "./.github/*" \ - -not -path "./docs/_legacy/*" \ - -not -path "./deployments/*" \ - -not -path "./hack/code-generator/*" \ - -exec $(MARKDOWNLINT) {} + - -lint: golangci-lint - $(GOLANGCILINT) run --new - -generate-controller: controller-gen - $(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./apis/..." - -# find or download controller-gen -# download controller-gen if necessary -controller-gen: -ifeq (, $(shell which controller-gen)) - @go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.13.0 -CONTROLLER_GEN=$(GOBIN)/controller-gen -else -CONTROLLER_GEN=$(shell which controller-gen) -endif - -helm-docs: -ifeq (, $(shell which helm-docs)) - @{ \ - set -e ;\ - HELM_DOCS_TMP_DIR=$$(mktemp -d) ;\ - cd $$HELM_DOCS_TMP_DIR ;\ - version=1.11.0 ;\ - arch=x86_64 ;\ - echo $$HELM_DOCS_PATH ;\ - echo https://github.com/norwoodj/helm-docs/releases/download/v$${version}/helm-docs_$${version}_linux_$${arch}.tar.gz ;\ - curl -LO https://github.com/norwoodj/helm-docs/releases/download/v$${version}/helm-docs_$${version}_linux_$${arch}.tar.gz ;\ - tar -zxvf helm-docs_$${version}_linux_$${arch}.tar.gz ;\ - mv helm-docs $(GOBIN)/helm-docs ;\ - rm -rf $$HELM_DOCS_TMP_DIR ;\ - } -HELM_DOCS=$(GOBIN)/helm-docs -else -HELM_DOCS=$(shell which helm-docs) -endif \ No newline at end of file diff --git a/PROJECT b/PROJECT deleted file mode 100644 index 644a774..0000000 --- a/PROJECT +++ /dev/null @@ -1,34 +0,0 @@ -domain: github.com/fluidos-project/ -layout: -- go.kubebuilder.io/v3 -projectName: node -repo: github.com/fluidos-project/node -resources: -- api: - crdVersion: v1 - namespaced: true - controller: true - domain: github.com/fluidos-project/ - group: nodecore - kind: Solver - path: github.com/fluidos-project/node/api/v1alpha1 - version: v1alpha1 -- api: - crdVersion: v1 - namespaced: true - controller: true - domain: github.com/fluidos-project/ - group: nodecore - kind: Flavour - path: github.com/fluidos-project/node/api/v1alpha1 - version: v1alpha1 -- api: - crdVersion: v1 - namespaced: true - controller: true - domain: github.com/fluidos-project/ - group: nodecore - kind: Allocation - path: github.com/fluidos-project/node/api/v1alpha1 - version: v1alpha1 -version: "3" diff --git a/README.md b/README.md deleted file mode 100644 index 96dcbb1..0000000 --- a/README.md +++ /dev/null @@ -1,28 +0,0 @@ -

- -

WP3 - FLUIDOS Node

-

- -## What is a FLUIDOS Node? -A FLUIDOS node is orchestrated by a single Kubernetes control plane, and it can be composed of either a single device or a set of devices (e.g., a datacenter). Device homogeneity is desired in order to simplify the management (physical servers can be considered all equals, since they feature a similar amount of hardware resources), but it is not requested within a FLUIDOS node. In other words, a FLUIDOS node corresponds to a *Kubernetes cluster*. - -## What can I find in this repo? -This repository contains the FLUIDOS Node, along with its essential components, such as: - -- [**Local ResourceManager**](/docs/implementation/components.md#local-resourcemanager) -- [**Avaialable Resources**](/docs/implementation/components.md#available-resources) -- [**Discovery Manager**](/docs/implementation/components.md#discovery-manager) -- [**Peering Candidates**](/docs/implementation/components.md#peering-candidates) -- [**REAR Manager**](/docs/implementation/components.md#rear-manager) -- [**Contract Manager**](/docs/implementation/components.md#contract-manager) - -Please note that this repository is continually updated, with additional components slated for future inclusion. - -## Implementation -Want to know more about the implementation? Check out the [**Implementation Part**](./docs/implementation/implementation.md). - -## Installation -Want to know how to install a FLUIDOS Node? Check out the [**Installation Part**](./docs/installation/installation.md). - -## License -This project is licensed under the Apache License 2.0 - see the [LICENSE](LICENSE) file for details. \ No newline at end of file diff --git a/apis/advertisement/v1alpha1/discovery_status.go b/apis/advertisement/v1alpha1/discovery_status.go deleted file mode 100644 index 8f2e5c5..0000000 --- a/apis/advertisement/v1alpha1/discovery_status.go +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2022-2023 FLUIDOS Project -// -// 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 ( - nodecorev1alpha1 "github.com/fluidos-project/node/apis/nodecore/v1alpha1" - "github.com/fluidos-project/node/pkg/utils/tools" -) - -// 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() - d.Status.Phase.Message = msg -} diff --git a/apis/advertisement/v1alpha1/discovery_types.go b/apis/advertisement/v1alpha1/discovery_types.go deleted file mode 100644 index 744a322..0000000 --- a/apis/advertisement/v1alpha1/discovery_types.go +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright 2022-2023 FLUIDOS Project -// -// 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" - - nodecorev1alpha1 "github.com/fluidos-project/node/apis/nodecore/v1alpha1" -) - -// 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 -type DiscoverySpec struct { - - // This is the Solver ID of the solver that creates and so asks for the discovery. - // This is a reference to the Solver CRD - SolverID string `json:"solverID"` - - // 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"` - - // This flag indicates that needs to be enstablished a subscription to the provider in case a match is found. - // In order to have periodic updates of the status of the matching Flavour - Subscribe bool `json:"subscribe"` -} - -// DiscoveryStatus defines the observed state of Discovery -type DiscoveryStatus struct { - - // This is the current phase of the discovery - Phase nodecorev1alpha1.PhaseStatus `json:"phase"` - - // This is the reference to the PeeringCandidate CRD that is the result of the discovery if a match is found - PeeringCandidate nodecorev1alpha1.GenericRef `json:"peeringCandidate,omitempty"` -} - -//+kubebuilder:object:root=true -//+kubebuilder:subresource:status - -// +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"` - - Spec DiscoverySpec `json:"spec,omitempty"` - Status DiscoveryStatus `json:"status,omitempty"` -} - -//+kubebuilder:object:root=true - -// DiscoveryList contains a list of Discovery -type DiscoveryList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata,omitempty"` - Items []Discovery `json:"items"` -} - -func init() { - SchemeBuilder.Register(&Discovery{}, &DiscoveryList{}) -} diff --git a/apis/advertisement/v1alpha1/groupversion_info.go b/apis/advertisement/v1alpha1/groupversion_info.go deleted file mode 100644 index 3775192..0000000 --- a/apis/advertisement/v1alpha1/groupversion_info.go +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2022-2023 FLUIDOS Project -// -// 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 contains API Schema definitions for the advertisement v1alpha1 API group -// +kubebuilder:object:generate=true -// +groupName=advertisement.fluidos.eu -package v1alpha1 - -import ( - "k8s.io/apimachinery/pkg/runtime/schema" - "sigs.k8s.io/controller-runtime/pkg/scheme" -) - -var ( - // 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 = &scheme.Builder{GroupVersion: GroupVersion} - - // AddToScheme adds the types in this group-version to the given scheme. - AddToScheme = SchemeBuilder.AddToScheme -) diff --git a/apis/advertisement/v1alpha1/peeringcandidate_types.go b/apis/advertisement/v1alpha1/peeringcandidate_types.go deleted file mode 100644 index e3cab9b..0000000 --- a/apis/advertisement/v1alpha1/peeringcandidate_types.go +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2022-2023 FLUIDOS Project -// -// 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" - - nodecorev1alpha1 "github.com/fluidos-project/node/apis/nodecore/v1alpha1" -) - -// 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 -type PeeringCandidateSpec struct { - Reserved bool `json:"reserved"` - - SolverID string `json:"solverID"` - - Flavour nodecorev1alpha1.Flavour `json:"flavour"` -} - -// PeeringCandidateStatus defines the observed state of PeeringCandidate -type PeeringCandidateStatus struct { - - // This field represents the creation time of the PeeringCandidate. - CreationTime string `json:"creationTime"` - - // This field represents the last update time of the PeeringCandidate. - LastUpdateTime string `json:"lastUpdateTime"` -} - -//+kubebuilder:object:root=true -//+kubebuilder:subresource:status - -// PeeringCandidate is the Schema for the peeringcandidates API -type PeeringCandidate struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - Spec PeeringCandidateSpec `json:"spec,omitempty"` - Status PeeringCandidateStatus `json:"status,omitempty"` -} - -//+kubebuilder:object:root=true - -// PeeringCandidateList contains a list of PeeringCandidate -type PeeringCandidateList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata,omitempty"` - Items []PeeringCandidate `json:"items"` -} - -func init() { - SchemeBuilder.Register(&PeeringCandidate{}, &PeeringCandidateList{}) -} diff --git a/apis/advertisement/v1alpha1/zz_generated.deepcopy.go b/apis/advertisement/v1alpha1/zz_generated.deepcopy.go deleted file mode 100644 index 9d747cb..0000000 --- a/apis/advertisement/v1alpha1/zz_generated.deepcopy.go +++ /dev/null @@ -1,210 +0,0 @@ -//go:build !ignore_autogenerated - -// Copyright 2022-2023 FLUIDOS Project -// -// 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. - -// Code generated by controller-gen. DO NOT EDIT. - -package v1alpha1 - -import ( - nodecorev1alpha1 "github.com/fluidos-project/node/apis/nodecore/v1alpha1" - runtime "k8s.io/apimachinery/pkg/runtime" -) - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Discovery) DeepCopyInto(out *Discovery) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) - out.Status = in.Status -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Discovery. -func (in *Discovery) DeepCopy() *Discovery { - if in == nil { - return nil - } - out := new(Discovery) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *Discovery) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *DiscoveryList) DeepCopyInto(out *DiscoveryList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]Discovery, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DiscoveryList. -func (in *DiscoveryList) DeepCopy() *DiscoveryList { - if in == nil { - return nil - } - out := new(DiscoveryList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *DiscoveryList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *DiscoverySpec) DeepCopyInto(out *DiscoverySpec) { - *out = *in - if in.Selector != nil { - in, out := &in.Selector, &out.Selector - *out = new(nodecorev1alpha1.FlavourSelector) - (*in).DeepCopyInto(*out) - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DiscoverySpec. -func (in *DiscoverySpec) DeepCopy() *DiscoverySpec { - if in == nil { - return nil - } - out := new(DiscoverySpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *DiscoveryStatus) DeepCopyInto(out *DiscoveryStatus) { - *out = *in - out.Phase = in.Phase - out.PeeringCandidate = in.PeeringCandidate -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DiscoveryStatus. -func (in *DiscoveryStatus) DeepCopy() *DiscoveryStatus { - if in == nil { - return nil - } - out := new(DiscoveryStatus) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *PeeringCandidate) DeepCopyInto(out *PeeringCandidate) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) - out.Status = in.Status -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PeeringCandidate. -func (in *PeeringCandidate) DeepCopy() *PeeringCandidate { - if in == nil { - return nil - } - out := new(PeeringCandidate) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *PeeringCandidate) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *PeeringCandidateList) DeepCopyInto(out *PeeringCandidateList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]PeeringCandidate, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PeeringCandidateList. -func (in *PeeringCandidateList) DeepCopy() *PeeringCandidateList { - if in == nil { - return nil - } - out := new(PeeringCandidateList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *PeeringCandidateList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *PeeringCandidateSpec) DeepCopyInto(out *PeeringCandidateSpec) { - *out = *in - in.Flavour.DeepCopyInto(&out.Flavour) -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PeeringCandidateSpec. -func (in *PeeringCandidateSpec) DeepCopy() *PeeringCandidateSpec { - if in == nil { - return nil - } - out := new(PeeringCandidateSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *PeeringCandidateStatus) DeepCopyInto(out *PeeringCandidateStatus) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PeeringCandidateStatus. -func (in *PeeringCandidateStatus) DeepCopy() *PeeringCandidateStatus { - if in == nil { - return nil - } - out := new(PeeringCandidateStatus) - in.DeepCopyInto(out) - return out -} diff --git a/apis/nodecore/v1alpha1/allocation_types.go b/apis/nodecore/v1alpha1/allocation_types.go deleted file mode 100644 index fbf8bbc..0000000 --- a/apis/nodecore/v1alpha1/allocation_types.go +++ /dev/null @@ -1,99 +0,0 @@ -// Copyright 2022-2023 FLUIDOS Project -// -// 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" -) - -type NodeType string -type Status string - -const ( - Node NodeType = "Node" - VirtualNode NodeType = "VirtualNode" -) - -const ( - Active Status = "Active" - Reserved Status = "Reserved" - Released Status = "Released" - Inactive Status = "Inactive" -) - -// 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. - -// AllocationSpec defines the desired state of Allocation -type AllocationSpec struct { - - // CustomerID - - // 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 name - LocalNode string `json:"localNode"` - - // 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 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"` - - // This Flavour describes the characteristics of the allocation, it is based on the Flavour CRD from which it was created - Flavour Flavour `json:"flavour"` - - // This is the dimension of the allocation, it is based on the Flavour CRD from which it was created - Partition FlavourSelector `json:"partition,omitempty"` -} - -// AllocationStatus defines the observed state of Allocation -type AllocationStatus struct { - - // This allow to know the current status of the allocation - Status Status `json:"status"` - - // The creation time of the allocation object - CreationTime metav1.Time `json:"creationTime"` - - // The last time the allocation was updated - LastUpdateTime metav1.Time `json:"lastUpdateTime"` -} - -//+kubebuilder:object:root=true -//+kubebuilder:subresource:status - -// Allocation is the Schema for the allocations API -type Allocation struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - Spec AllocationSpec `json:"spec,omitempty"` - Status AllocationStatus `json:"status,omitempty"` -} - -//+kubebuilder:object:root=true - -// AllocationList contains a list of Allocation -type AllocationList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata,omitempty"` - Items []Allocation `json:"items"` -} - -func init() { - SchemeBuilder.Register(&Allocation{}, &AllocationList{}) -} diff --git a/apis/nodecore/v1alpha1/common.go b/apis/nodecore/v1alpha1/common.go deleted file mode 100644 index 4dfab3f..0000000 --- a/apis/nodecore/v1alpha1/common.go +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2022-2023 FLUIDOS Project -// -// 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 - -const ( - //PhaseReady Phase = "Ready" - PhaseSolved Phase = "Solved" - PhaseFailed Phase = "Failed" - PhaseRunning Phase = "Running" - PhaseIdle Phase = "Idle" - PhaseTimeout Phase = "Timed Out" - PhaseBackoff Phase = "Backoff" - PhaseActive Phase = "Active" - PhasePending Phase = "Pending" - PhaseInactive Phase = "Inactive" -) - -// GenericRef represents a reference to a generic Kubernetes resource, -// and it is composed of the resource name and (optionally) its namespace. -type GenericRef struct { - // The name of the resource to be referenced. - Name string `json:"name,omitempty"` - - // The namespace containing the resource to be referenced. It should be left - // empty in case of cluster-wide resources. - Namespace string `json:"namespace,omitempty"` -} - -type NodeIdentity struct { - Domain string `json:"domain"` - NodeID string `json:"nodeID"` - IP string `json:"ip"` -} - -// toString() returns a string representation of the GenericRef. -/* func (r GenericRef) toString() string { - if r.Namespace != "" { - return r.Namespace + "/" + r.Name - } - return r.Name -} */ diff --git a/apis/nodecore/v1alpha1/flavour_types.go b/apis/nodecore/v1alpha1/flavour_types.go deleted file mode 100644 index 570350f..0000000 --- a/apis/nodecore/v1alpha1/flavour_types.go +++ /dev/null @@ -1,172 +0,0 @@ -// Copyright 2022-2023 FLUIDOS Project -// -// 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 ( - "k8s.io/apimachinery/pkg/api/resource" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -const ( - K8S FlavourType = "k8s-fluidos" -) - -type FlavourType string - -type Characteristics struct { - - // Architecture is the architecture of the Flavour. - Architecture string `json:"architecture"` - - // CPU is the number of CPU cores of the Flavour. - Cpu resource.Quantity `json:"cpu"` - - // Memory is the amount of RAM of the Flavour. - Memory resource.Quantity `json:"memory"` - - // GPU is the number of GPU cores of the Flavour. - Gpu resource.Quantity `json:"gpu,omitempty"` - - // EphemeralStorage is the amount of ephemeral storage of the Flavour. - EphemeralStorage resource.Quantity `json:"ephemeral-storage,omitempty"` - - // PersistentStorage is the amount of persistent storage of the Flavour. - PersistentStorage resource.Quantity `json:"persistent-storage,omitempty"` -} - -type Policy struct { - - // Partitionable contains the partitioning properties of the Flavour. - Partitionable *Partitionable `json:"partitionable,omitempty"` - - // Aggregatable contains the aggregation properties of the Flavour. - Aggregatable *Aggregatable `json:"aggregatable,omitempty"` -} - -// Partitionable represents the partitioning properties of a Flavour, such as the minimum and incremental values of CPU and RAM. -type Partitionable struct { - // CpuMin is the minimum requirable number of CPU cores of the Flavour. - CpuMin resource.Quantity `json:"cpuMin"` - - // MemoryMin is the minimum requirable amount of RAM of the Flavour. - MemoryMin resource.Quantity `json:"memoryMin"` - - // CpuStep is the incremental value of CPU cores of the Flavour. - CpuStep resource.Quantity `json:"cpuStep"` - - // MemoryStep is the incremental value of RAM of the Flavour. - MemoryStep resource.Quantity `json:"memoryStep"` -} - -// Aggregatable represents the aggregation properties of a Flavour, such as the minimum instance count. -type Aggregatable struct { - // MinCount is the minimum requirable number of instances of the Flavour. - MinCount int `json:"minCount"` - - // MaxCount is the maximum requirable number of instances of the Flavour. - MaxCount int `json:"maxCount"` -} - -type Price struct { - - // Amount is the amount of the price. - Amount string `json:"amount"` - - // Currency is the currency of the price. - Currency string `json:"currency"` - - // Period is the period of the price. - Period string `json:"period"` -} - -type OptionalFields struct { - - // Availability is the availability flag of the Flavour. - // It is a field inherited from the REAR Protocol specifications. - Availability bool `json:"availability,omitempty"` - - // WorkerID is the ID of the worker that provides the Flavour. - WorkerID string `json:"workerID,omitempty"` -} - -// FlavourSpec defines the desired state of Flavour -type FlavourSpec struct { - // This specs are based on the REAR Protocol specifications. - - // FlavourID is the name of the Flavour. - FlavourID string `json:"flavourID"` - - // ProviderID is the ID of the FLUIDOS Node ID that provides this Flavour. - // It can correspond to ID of the owner FLUIDOS Node or to the ID of a FLUIDOS SuperNode that represents the entry point to a FLUIDOS Domain - ProviderID string `json:"providerID"` - - // Type is the type of the Flavour. Currently, only K8S is supported. - Type FlavourType `json:"type"` - - // Characteristics contains the characteristics of the Flavour. - // They are based on the type of the Flavour and can change depending on it. In this case, the type is K8S so the characteristics are CPU, Memory, GPU and EphemeralStorage. - Characteristics Characteristics `json:"characteristics"` - - // Policy contains the policy of the Flavour. The policy describes the partitioning and aggregation properties of the Flavour. - Policy Policy `json:"policy"` - - // Owner contains the identity info of the owner of the Flavour. It can be unknown if the Flavour is provided by a reseller or a third party. - Owner NodeIdentity `json:"owner"` - - // Price contains the price model of the Flavour. - Price Price `json:"price"` - - // This field is used to specify the optional fields that can be retrieved from the Flavour. - // In the future it will be expanded to include more optional fields defined in the REAR Protocol or custom ones. - OptionalFields OptionalFields `json:"optionalFields"` -} - -// FlavourStatus defines the observed state of Flavour -type FlavourStatus struct { - - // This field represents the expiration time of the Flavour. It is used to determine when the Flavour is no longer valid. - ExpirationTime string `json:"expirationTime"` - - // This field represents the creation time of the Flavour. - CreationTime string `json:"creationTime"` - - // This field represents the last update time of the Flavour. - LastUpdateTime string `json:"lastUpdateTime"` -} - -//+kubebuilder:object:root=true -//+kubebuilder:subresource:status - -// Flavour is the Schema for the flavours API -type Flavour struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - Spec FlavourSpec `json:"spec,omitempty"` - Status FlavourStatus `json:"status,omitempty"` -} - -//+kubebuilder:object:root=true - -// FlavourList contains a list of Flavour -type FlavourList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata,omitempty"` - Items []Flavour `json:"items"` -} - -func init() { - SchemeBuilder.Register(&Flavour{}, &FlavourList{}) -} diff --git a/apis/nodecore/v1alpha1/groupversion_info.go b/apis/nodecore/v1alpha1/groupversion_info.go deleted file mode 100644 index 760cfc7..0000000 --- a/apis/nodecore/v1alpha1/groupversion_info.go +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2022-2023 FLUIDOS Project -// -// 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 contains API Schema definitions for the nodecore v1alpha1 API group -// +kubebuilder:object:generate=true -// +groupName=nodecore.fluidos.eu -package v1alpha1 - -import ( - "k8s.io/apimachinery/pkg/runtime/schema" - "sigs.k8s.io/controller-runtime/pkg/scheme" -) - -var ( - // GroupVersion is group version used to register these objects - GroupVersion = schema.GroupVersion{Group: "nodecore.fluidos.eu", Version: "v1alpha1"} - - // 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. - AddToScheme = SchemeBuilder.AddToScheme -) diff --git a/apis/nodecore/v1alpha1/solver_status.go b/apis/nodecore/v1alpha1/solver_status.go deleted file mode 100644 index 7ed0878..0000000 --- a/apis/nodecore/v1alpha1/solver_status.go +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2022-2023 FLUIDOS Project -// -// 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 ( - "github.com/fluidos-project/node/pkg/utils/tools" -) - -func (solver *Solver) SetPhase(phase Phase, msg string) { - t := tools.GetTimeNow() - solver.Status.SolverPhase.Phase = phase - solver.Status.SolverPhase.LastChangeTime = t - solver.Status.SolverPhase.Message = msg - solver.Status.SolverPhase.EndTime = t -} - -// SetPurchasePhase sets the ReserveAndBuy phase of the solver -func (solver *Solver) SetReserveAndBuyStatus(phase Phase) { - solver.Status.ReserveAndBuy = phase - solver.Status.SolverPhase.LastChangeTime = tools.GetTimeNow() -} - -// SetFindCandidateStatus sets the FindCandidate phase of the solver -func (solver *Solver) SetFindCandidateStatus(phase Phase) { - solver.Status.FindCandidate = phase - solver.Status.SolverPhase.LastChangeTime = tools.GetTimeNow() -} - -// SetDiscoveryStatus sets the discovery phase of the solver -func (solver *Solver) SetDiscoveryStatus(phase Phase) { - solver.Status.DiscoveryPhase = phase - solver.Status.SolverPhase.LastChangeTime = tools.GetTimeNow() -} - -// SetReservationStatus sets the reservation phase of the solver -func (solver *Solver) SetReservationStatus(phase Phase) { - solver.Status.ReservationPhase = phase - solver.Status.SolverPhase.LastChangeTime = tools.GetTimeNow() -} diff --git a/apis/nodecore/v1alpha1/solver_types.go b/apis/nodecore/v1alpha1/solver_types.go deleted file mode 100644 index 533ed98..0000000 --- a/apis/nodecore/v1alpha1/solver_types.go +++ /dev/null @@ -1,173 +0,0 @@ -// Copyright 2022-2023 FLUIDOS Project -// -// 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" - - resource "k8s.io/apimachinery/pkg/api/resource" -) - -type Phase string - -// PhaseStatus represents the status of a phase of the solver. I.e. the status of the REAR phases. -type PhaseStatus struct { - Phase Phase `json:"phase"` - Message string `json:"message,omitempty"` - StartTime string `json:"startTime,omitempty"` - LastChangeTime string `json:"lastChangeTime,omitempty"` - EndTime string `json:"endTime,omitempty"` -} - -// Selector represents the criteria for selecting Flavours. -/* type Selector struct { - FlavourType string `json:"type,omitempty"` - Architecture string `json:"architecture,omitempty"` - Cpu int `json:"cpu,omitempty"` - Memory int `json:"memory,omitempty"` - EphemeralStorage int `json:"ephemeral-storage,omitempty"` - MoreThanCpu int `json:"moreThanCpu,omitempty"` - MoreThanMemory int `json:"moreThanMemory,omitempty"` - MoreThanEph int `json:"moreThanEph,omitempty"` - LessThanCpu int `json:"lessThanCpu,omitempty"` - LessThanMemory int `json:"lessThanMemory,omitempty"` - LessThanEph int `json:"lessThanEph,omitempty"` -} */ - -type FlavourSelector struct { - FlavourType string `json:"type"` - Architecture string `json:"architecture"` - RangeSelector *RangeSelector `json:"rangeSelector,omitempty"` - MatchSelector *MatchSelector `json:"matchSelector,omitempty"` -} - -// MatchSelector represents the criteria for selecting Flavours through a strict match. -type MatchSelector struct { - Cpu resource.Quantity `json:"cpu"` - Memory resource.Quantity `json:"memory"` - Storage resource.Quantity `json:"storage,omitempty"` - EphemeralStorage resource.Quantity `json:"ephemeralStorage,omitempty"` - Gpu resource.Quantity `json:"gpu,omitempty"` -} - -// RangeSelector represents the criteria for selecting Flavours through a range. -type RangeSelector struct { - MinCpu resource.Quantity `json:"minCpu,omitempty"` - MinMemory resource.Quantity `json:"minMemory,omitempty"` - MinEph resource.Quantity `json:"minEph,omitempty"` - MinStorage resource.Quantity `json:"minStorage,omitempty"` - MinGpu resource.Quantity `json:"minGpu,omitempty"` - MaxCpu resource.Quantity `json:"MaxCpu,omitempty"` - MaxMemory resource.Quantity `json:"MaxMemory,omitempty"` - MaxEph resource.Quantity `json:"MaxEph,omitempty"` - MaxStorage resource.Quantity `json:"MaxStorage,omitempty"` - MaxGpu resource.Quantity `json:"MaxGpu,omitempty"` -} - -// SolverSpec defines the desired state of Solver -type SolverSpec struct { - - // Selector contains the flavour requirements for the solver. - Selector *FlavourSelector `json:"selector,omitempty"` - - // IntentID is the ID of the intent that the Node Orchestrator is trying to solve. - // It is used to link the solver with the intent. - IntentID string `json:"intentID"` - - // FindCandidate is a flag that indicates if the solver should find a candidate to solve the intent. - FindCandidate bool `json:"findCandidate,omitempty"` - - // ReserveAndBuy is a flag that indicates if the solver should reserve and buy the resources on the candidate. - ReserveAndBuy bool `json:"reserveAndBuy,omitempty"` - - // EnstablishPeering is a flag that indicates if the solver should enstablish a peering with the candidate. - EnstablishPeering bool `json:"enstablishPeering,omitempty"` -} - -// SolverStatus defines the observed state of Solver -type SolverStatus struct { - - // FindCandidate describes the status of research of the candidate. - // Rear Manager is looking for the best candidate Flavour to solve the Node Orchestrator request. - FindCandidate Phase `json:"findCandidate,omitempty"` - - // ReserveAndBuy describes the status of the reservation and purchase of selected Flavour. - // Rear Manager is trying to reserve and purchase the resources on the candidate FLUIDOS Node. - ReserveAndBuy Phase `json:"reserveAndBuy,omitempty"` - - // Peering describes the status of the peering with the candidate. - // Rear Manager is trying to enstablish a peering with the candidate FLUIDOS Node. - Peering Phase `json:"peering,omitempty"` - - // DiscoveryPhase describes the status of the Discovery where the Discovery Manager - // is looking for matching flavours outside the FLUIDOS Node - DiscoveryPhase Phase `json:"discoveryPhase,omitempty"` - - // ReservationPhase describes the status of the Reservation where the Contract Manager - // is reserving and purchasing the resources on the candidate node. - ReservationPhase Phase `json:"reservationPhase,omitempty"` - - // ConsumePhase describes the status of the Consume phase where the VFM (Liqo) is enstablishing - // a peering with the candidate node. - ConsumePhase Phase `json:"consumePhase,omitempty"` - - // SolverPhase describes the status of the Solver generated by the Node Orchestrator. - // It is usefull to understand if the solver is still running or if it has finished or failed. - SolverPhase PhaseStatus `json:"solverPhase,omitempty"` - - // PeeringCandidate contains the candidate that the solver has eventually found to solve the intent. - PeeringCandidate GenericRef `json:"peeringCandidate,omitempty"` - - // Allocation contains the allocation that the solver has eventually created for the intent. - // It can correspond to a virtual node - // The Node Orchestrator will use this allocation to fullfill the intent. - Allocation GenericRef `json:"allocation,omitempty"` -} - -//+kubebuilder:object:root=true -//+kubebuilder:subresource:status - -// Solver is the Schema for the solvers API -// +kubebuilder:printcolumn:name="Intent ID",type=string,JSONPath=`.spec.intentID` -// +kubebuilder:printcolumn:name="Find Candidate",type=boolean,JSONPath=`.spec.findCandidate` -// +kubebuilder:printcolumn:name="Reserve and Buy",type=boolean,JSONPath=`.spec.reserveAndBuy` -// +kubebuilder:printcolumn:name="Peering",type=boolean,JSONPath=`.spec.enstablishPeering` -// +kubebuilder:printcolumn:name="Candidate Phase",type=string,priority=1,JSONPath=`.status.findCandidate` -// +kubebuilder:printcolumn:name="Reserving Phase",type=string,priority=1,JSONPath=`.status.reserveAndBuy` -// +kubebuilder:printcolumn:name="Peering Phase",type=string,priority=1,JSONPath=`.status.peering` -// +kubebuilder:printcolumn:name="Status",type=string,JSONPath=`.status.solverPhase.phase` -// +kubebuilder:printcolumn:name="Message",type=string,JSONPath=`.status.solverPhase.message` -// +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp` -// Solver is the Schema for the solvers API -type Solver struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - Spec SolverSpec `json:"spec,omitempty"` - Status SolverStatus `json:"status,omitempty"` -} - -//+kubebuilder:object:root=true - -// SolverList contains a list of Solver -type SolverList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata,omitempty"` - Items []Solver `json:"items"` -} - -func init() { - SchemeBuilder.Register(&Solver{}, &SolverList{}) -} diff --git a/apis/nodecore/v1alpha1/zz_generated.deepcopy.go b/apis/nodecore/v1alpha1/zz_generated.deepcopy.go deleted file mode 100644 index 4f86197..0000000 --- a/apis/nodecore/v1alpha1/zz_generated.deepcopy.go +++ /dev/null @@ -1,531 +0,0 @@ -//go:build !ignore_autogenerated - -// Copyright 2022-2023 FLUIDOS Project -// -// 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. - -// Code generated by controller-gen. DO NOT EDIT. - -package v1alpha1 - -import ( - runtime "k8s.io/apimachinery/pkg/runtime" -) - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Aggregatable) DeepCopyInto(out *Aggregatable) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Aggregatable. -func (in *Aggregatable) DeepCopy() *Aggregatable { - if in == nil { - return nil - } - out := new(Aggregatable) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Allocation) DeepCopyInto(out *Allocation) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) - in.Status.DeepCopyInto(&out.Status) -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Allocation. -func (in *Allocation) DeepCopy() *Allocation { - if in == nil { - return nil - } - out := new(Allocation) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *Allocation) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *AllocationList) DeepCopyInto(out *AllocationList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]Allocation, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AllocationList. -func (in *AllocationList) DeepCopy() *AllocationList { - if in == nil { - return nil - } - out := new(AllocationList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *AllocationList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *AllocationSpec) DeepCopyInto(out *AllocationSpec) { - *out = *in - in.Flavour.DeepCopyInto(&out.Flavour) - in.Partition.DeepCopyInto(&out.Partition) -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AllocationSpec. -func (in *AllocationSpec) DeepCopy() *AllocationSpec { - if in == nil { - return nil - } - out := new(AllocationSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *AllocationStatus) DeepCopyInto(out *AllocationStatus) { - *out = *in - in.CreationTime.DeepCopyInto(&out.CreationTime) - in.LastUpdateTime.DeepCopyInto(&out.LastUpdateTime) -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AllocationStatus. -func (in *AllocationStatus) DeepCopy() *AllocationStatus { - if in == nil { - return nil - } - out := new(AllocationStatus) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Characteristics) DeepCopyInto(out *Characteristics) { - *out = *in - out.Cpu = in.Cpu.DeepCopy() - out.Memory = in.Memory.DeepCopy() - out.Gpu = in.Gpu.DeepCopy() - out.EphemeralStorage = in.EphemeralStorage.DeepCopy() - out.PersistentStorage = in.PersistentStorage.DeepCopy() -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Characteristics. -func (in *Characteristics) DeepCopy() *Characteristics { - if in == nil { - return nil - } - out := new(Characteristics) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Flavour) DeepCopyInto(out *Flavour) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) - out.Status = in.Status -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Flavour. -func (in *Flavour) DeepCopy() *Flavour { - if in == nil { - return nil - } - out := new(Flavour) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *Flavour) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *FlavourList) DeepCopyInto(out *FlavourList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]Flavour, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FlavourList. -func (in *FlavourList) DeepCopy() *FlavourList { - if in == nil { - return nil - } - out := new(FlavourList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *FlavourList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *FlavourSelector) DeepCopyInto(out *FlavourSelector) { - *out = *in - if in.RangeSelector != nil { - in, out := &in.RangeSelector, &out.RangeSelector - *out = new(RangeSelector) - (*in).DeepCopyInto(*out) - } - if in.MatchSelector != nil { - in, out := &in.MatchSelector, &out.MatchSelector - *out = new(MatchSelector) - (*in).DeepCopyInto(*out) - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FlavourSelector. -func (in *FlavourSelector) DeepCopy() *FlavourSelector { - if in == nil { - return nil - } - out := new(FlavourSelector) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *FlavourSpec) DeepCopyInto(out *FlavourSpec) { - *out = *in - in.Characteristics.DeepCopyInto(&out.Characteristics) - in.Policy.DeepCopyInto(&out.Policy) - out.Owner = in.Owner - out.Price = in.Price - out.OptionalFields = in.OptionalFields -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FlavourSpec. -func (in *FlavourSpec) DeepCopy() *FlavourSpec { - if in == nil { - return nil - } - out := new(FlavourSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *FlavourStatus) DeepCopyInto(out *FlavourStatus) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FlavourStatus. -func (in *FlavourStatus) DeepCopy() *FlavourStatus { - if in == nil { - return nil - } - out := new(FlavourStatus) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *GenericRef) DeepCopyInto(out *GenericRef) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GenericRef. -func (in *GenericRef) DeepCopy() *GenericRef { - if in == nil { - return nil - } - out := new(GenericRef) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *MatchSelector) DeepCopyInto(out *MatchSelector) { - *out = *in - out.Cpu = in.Cpu.DeepCopy() - out.Memory = in.Memory.DeepCopy() - out.Storage = in.Storage.DeepCopy() - out.EphemeralStorage = in.EphemeralStorage.DeepCopy() - out.Gpu = in.Gpu.DeepCopy() -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MatchSelector. -func (in *MatchSelector) DeepCopy() *MatchSelector { - if in == nil { - return nil - } - out := new(MatchSelector) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *NodeIdentity) DeepCopyInto(out *NodeIdentity) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodeIdentity. -func (in *NodeIdentity) DeepCopy() *NodeIdentity { - if in == nil { - return nil - } - out := new(NodeIdentity) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *OptionalFields) DeepCopyInto(out *OptionalFields) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OptionalFields. -func (in *OptionalFields) DeepCopy() *OptionalFields { - if in == nil { - return nil - } - out := new(OptionalFields) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Partitionable) DeepCopyInto(out *Partitionable) { - *out = *in - out.CpuMin = in.CpuMin.DeepCopy() - out.MemoryMin = in.MemoryMin.DeepCopy() - out.CpuStep = in.CpuStep.DeepCopy() - out.MemoryStep = in.MemoryStep.DeepCopy() -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Partitionable. -func (in *Partitionable) DeepCopy() *Partitionable { - if in == nil { - return nil - } - out := new(Partitionable) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *PhaseStatus) DeepCopyInto(out *PhaseStatus) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PhaseStatus. -func (in *PhaseStatus) DeepCopy() *PhaseStatus { - if in == nil { - return nil - } - out := new(PhaseStatus) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Policy) DeepCopyInto(out *Policy) { - *out = *in - if in.Partitionable != nil { - in, out := &in.Partitionable, &out.Partitionable - *out = new(Partitionable) - (*in).DeepCopyInto(*out) - } - if in.Aggregatable != nil { - in, out := &in.Aggregatable, &out.Aggregatable - *out = new(Aggregatable) - **out = **in - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Policy. -func (in *Policy) DeepCopy() *Policy { - if in == nil { - return nil - } - out := new(Policy) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Price) DeepCopyInto(out *Price) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Price. -func (in *Price) DeepCopy() *Price { - if in == nil { - return nil - } - out := new(Price) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *RangeSelector) DeepCopyInto(out *RangeSelector) { - *out = *in - out.MinCpu = in.MinCpu.DeepCopy() - out.MinMemory = in.MinMemory.DeepCopy() - out.MinEph = in.MinEph.DeepCopy() - out.MinStorage = in.MinStorage.DeepCopy() - out.MinGpu = in.MinGpu.DeepCopy() - out.MaxCpu = in.MaxCpu.DeepCopy() - out.MaxMemory = in.MaxMemory.DeepCopy() - out.MaxEph = in.MaxEph.DeepCopy() - out.MaxStorage = in.MaxStorage.DeepCopy() - out.MaxGpu = in.MaxGpu.DeepCopy() -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RangeSelector. -func (in *RangeSelector) DeepCopy() *RangeSelector { - if in == nil { - return nil - } - out := new(RangeSelector) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Solver) DeepCopyInto(out *Solver) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) - out.Status = in.Status -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Solver. -func (in *Solver) DeepCopy() *Solver { - if in == nil { - return nil - } - out := new(Solver) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *Solver) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *SolverList) DeepCopyInto(out *SolverList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]Solver, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SolverList. -func (in *SolverList) DeepCopy() *SolverList { - if in == nil { - return nil - } - out := new(SolverList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *SolverList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *SolverSpec) DeepCopyInto(out *SolverSpec) { - *out = *in - if in.Selector != nil { - in, out := &in.Selector, &out.Selector - *out = new(FlavourSelector) - (*in).DeepCopyInto(*out) - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SolverSpec. -func (in *SolverSpec) DeepCopy() *SolverSpec { - if in == nil { - return nil - } - out := new(SolverSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *SolverStatus) DeepCopyInto(out *SolverStatus) { - *out = *in - out.SolverPhase = in.SolverPhase - out.PeeringCandidate = in.PeeringCandidate - out.Allocation = in.Allocation -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SolverStatus. -func (in *SolverStatus) DeepCopy() *SolverStatus { - if in == nil { - return nil - } - out := new(SolverStatus) - in.DeepCopyInto(out) - return out -} diff --git a/apis/reservation/v1alpha1/contract_types.go b/apis/reservation/v1alpha1/contract_types.go deleted file mode 100644 index cab5cd8..0000000 --- a/apis/reservation/v1alpha1/contract_types.go +++ /dev/null @@ -1,95 +0,0 @@ -// Copyright 2022-2023 FLUIDOS Project -// -// 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" - - nodecorev1alpha1 "github.com/fluidos-project/node/apis/nodecore/v1alpha1" -) - -// LiqoCredentials contains the credentials of a Liqo cluster to enstablish a peering. -type LiqoCredentials struct { - ClusterID string `json:"clusterID"` - ClusterName string `json:"clusterName"` - Token string `json:"token"` - Endpoint string `json:"endpoint"` -} - -// ContractSpec defines the desired state of Contract -type ContractSpec struct { - - // TODO: ClusterID is the ID used by Liqo to search a contract during the peering phase. - - // This is the flavour on which the contract is based. It is used to lifetime maintain the critical characteristics of the contract. - Flavour nodecorev1alpha1.Flavour `json:"flavour"` - - // TransactionID is the ID of the transaction that this contract is part of - TransactionID string `json:"transactionID"` - - // The partition represents the dimension of the resources sold/bought. - // So it will reflect the dimension of the resources allocated on the remote cluster and reflected on the local virtual node. - Partition *Partition `json:"partition,omitempty"` - - // This is the Node identity of the buyer FLUIDOS Node. - Buyer nodecorev1alpha1.NodeIdentity `json:"buyer"` - - // BuyerClusterID is the Liqo ClusterID used by the seller to search a contract and the related resources during the peering phase. - BuyerClusterID string `json:"buyerClusterID"` - - // This is the Node identity of the seller FLUIDOS Node. - Seller nodecorev1alpha1.NodeIdentity `json:"seller"` - - // This credentials will be used by the customer to connect and enstablish a peering with the seller FLUIDOS Node through Liqo. - SellerCredentials LiqoCredentials `json:"sellerCredentials"` - - // This is the expiration time of the contract. It can be empty if the contract is not time limited. - ExpirationTime string `json:"expirationTime,omitempty"` - - // This contains additional information about the contract if needed. - ExtraInformation map[string]string `json:"extraInformation,omitempty"` -} - -// ContractStatus defines the observed state of Contract -type ContractStatus struct { - - // This is the status of the contract. - Phase nodecorev1alpha1.PhaseStatus `json:"phase"` -} - -//+kubebuilder:object:root=true -//+kubebuilder:subresource:status - -// Contract is the Schema for the contracts API -type Contract struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - Spec ContractSpec `json:"spec,omitempty"` - Status ContractStatus `json:"status,omitempty"` -} - -//+kubebuilder:object:root=true - -// ContractList contains a list of Contract -type ContractList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata,omitempty"` - Items []Contract `json:"items"` -} - -func init() { - SchemeBuilder.Register(&Contract{}, &ContractList{}) -} diff --git a/apis/reservation/v1alpha1/groupversion_info.go b/apis/reservation/v1alpha1/groupversion_info.go deleted file mode 100644 index 3e0376c..0000000 --- a/apis/reservation/v1alpha1/groupversion_info.go +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2022-2023 FLUIDOS Project -// -// 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 contains API Schema definitions for the reservation v1alpha1 API group -// +kubebuilder:object:generate=true -// +groupName=reservation.fluidos.eu -package v1alpha1 - -import ( - "k8s.io/apimachinery/pkg/runtime/schema" - "sigs.k8s.io/controller-runtime/pkg/scheme" -) - -var ( - // GroupVersion is group version used to register these objects - GroupVersion = schema.GroupVersion{Group: "reservation.fluidos.eu", Version: "v1alpha1"} - - // 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. - AddToScheme = SchemeBuilder.AddToScheme -) diff --git a/apis/reservation/v1alpha1/reservation_status.go b/apis/reservation/v1alpha1/reservation_status.go deleted file mode 100644 index e38fa1c..0000000 --- a/apis/reservation/v1alpha1/reservation_status.go +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2022-2023 FLUIDOS Project -// -// 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 ( - nodecorev1alpha1 "github.com/fluidos-project/node/apis/nodecore/v1alpha1" - "github.com/fluidos-project/node/pkg/utils/tools" -) - -// SetPhase sets the phase of the discovery -func (r *Reservation) SetPhase(phase nodecorev1alpha1.Phase, msg string) { - r.Status.Phase.Phase = phase - r.Status.Phase.LastChangeTime = tools.GetTimeNow() - r.Status.Phase.Message = msg -} - -// SetReserveStatus sets the status of the reserve (if it is a reserve) -func (r *Reservation) SetReserveStatus(status nodecorev1alpha1.Phase) { - r.Status.ReservePhase = status -} - -// SetPurchaseStatus sets the status of the purchase (if it is a purchase) -func (r *Reservation) SetPurchaseStatus(status nodecorev1alpha1.Phase) { - r.Status.PurchasePhase = status -} diff --git a/apis/reservation/v1alpha1/reservation_types.go b/apis/reservation/v1alpha1/reservation_types.go deleted file mode 100644 index 4705be0..0000000 --- a/apis/reservation/v1alpha1/reservation_types.go +++ /dev/null @@ -1,113 +0,0 @@ -// Copyright 2022-2023 FLUIDOS Project -// -// 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 ( - "k8s.io/apimachinery/pkg/api/resource" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - - nodecorev1alpha1 "github.com/fluidos-project/node/apis/nodecore/v1alpha1" -) - -type Partition struct { - Architecture string `json:"architecture"` - Cpu resource.Quantity `json:"cpu"` - Memory resource.Quantity `json:"memory"` - Gpu resource.Quantity `json:"gpu,omitempty"` - EphemeralStorage resource.Quantity `json:"ephemeral-storage,omitempty"` - Storage resource.Quantity `json:"storage,omitempty"` -} - -// ReservationSpec defines the desired state of Reservation -type ReservationSpec struct { - - // SolverID is the ID of the solver that asks for the reservation - SolverID string `json:"solverID"` - - // This is the Node identity of the buyer FLUIDOS Node. - Buyer nodecorev1alpha1.NodeIdentity `json:"buyer"` - - // BuyerClusterID is the Liqo ClusterID used by the seller to search a contract and the related resources during the peering phase. - BuyerClusterID string `json:"buyerClusterID"` - - // This is the Node identity of the seller FLUIDOS Node. - Seller nodecorev1alpha1.NodeIdentity `json:"seller"` - - // Parition is the partition of the flavour that is being reserved - Partition *Partition `json:"partition,omitempty"` - - // Reserve indicates if the reservation is a reserve or not - Reserve bool `json:"reserve,omitempty"` - - // Purchase indicates if the reservation is an purchase or not - Purchase bool `json:"purchase,omitempty"` - - // PeeringCandidate is the reference to the PeeringCandidate of the Reservation - PeeringCandidate nodecorev1alpha1.GenericRef `json:"peeringCandidate,omitempty"` -} - -// ReservationStatus defines the observed state of Reservation -type ReservationStatus struct { - // This is the current phase of the reservation - Phase nodecorev1alpha1.PhaseStatus `json:"phase"` - - // ReservePhase is the current phase of the reservation - ReservePhase nodecorev1alpha1.Phase `json:"reservePhase,omitempty"` - - // PurchasePhase is the current phase of the reservation - PurchasePhase nodecorev1alpha1.Phase `json:"purchasePhase,omitempty"` - - // TransactionID is the ID of the transaction that this reservation is part of - TransactionID string `json:"transactionID,omitempty"` - - // Contract is the reference to the Contract of the Reservation - Contract nodecorev1alpha1.GenericRef `json:"contract,omitempty"` -} - -//+kubebuilder:object:root=true -//+kubebuilder:subresource:status - -// +kubebuilder:printcolumn:name="Solver ID",type=string,JSONPath=`.spec.solverID` -// +kubebuilder:printcolumn:name="Reserve",type=boolean,JSONPath=`.spec.reserve` -// +kubebuilder:printcolumn:name="Purchase",type=boolean,JSONPath=`.spec.purchase` -// +kubebuilder:printcolumn:name="Seller",type=string,JSONPath=`.spec.seller.name` -// +kubebuilder:printcolumn:name="Peering Candidate",type=string,priority=1,JSONPath=`.spec.peeringCandidate.name` -// +kubebuilder:printcolumn:name="Transaction ID",type=string,JSONPath=`.status.transactionID` -// +kubebuilder:printcolumn:name="Reserve Phase",type=string,priority=1,JSONPath=`.status.reservePhase.phase` -// +kubebuilder:printcolumn:name="Purchase Phase",type=string,priority=1,JSONPath=`.status.purchasePhase.phase` -// +kubebuilder:printcolumn:name="Contract Name",type=string,JSONPath=`.status.contract.name` -// +kubebuilder:printcolumn:name="Status",type=string,JSONPath=`.status.phase.phase` -// +kubebuilder:printcolumn:name="Message",type=string,priority=1,JSONPath=`.status.phase.message` -// Reservation is the Schema for the reservations API -type Reservation struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - Spec ReservationSpec `json:"spec,omitempty"` - Status ReservationStatus `json:"status,omitempty"` -} - -//+kubebuilder:object:root=true - -// ReservationList contains a list of Reservation -type ReservationList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata,omitempty"` - Items []Reservation `json:"items"` -} - -func init() { - SchemeBuilder.Register(&Reservation{}, &ReservationList{}) -} diff --git a/apis/reservation/v1alpha1/transaction_types.go b/apis/reservation/v1alpha1/transaction_types.go deleted file mode 100644 index dbe6e58..0000000 --- a/apis/reservation/v1alpha1/transaction_types.go +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright 2022-2023 FLUIDOS Project -// -// 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 ( - nodecorev1alpha1 "github.com/fluidos-project/node/apis/nodecore/v1alpha1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -// TransactionSpec defines the desired state of Transaction -type TransactionSpec struct { - // FlavourID is the ID of the flavour that is being reserved - FlavourID string `json:"flavourID"` - - // Buyer is the buyer Identity of the Fluidos Node that is reserving the Flavour - Buyer nodecorev1alpha1.NodeIdentity `json:"buyer"` - - // ClusterID is the Liqo ClusterID of the Fluidos Node that is reserving the Flavour - ClusterID string `json:"clusterID"` - - // Partition is the partition of the flavour that is being reserved - Partition *Partition `json:"partition,omitempty"` - - // StartTime is the time at which the reservation should start - StartTime string `json:"startTime,omitempty"` -} - -// TransactionStatus defines the observed state of Transaction -type TransactionStatus struct { - // This is the current phase of the reservation - Phase nodecorev1alpha1.PhaseStatus `json:"phase"` -} - -//+kubebuilder:object:root=true -//+kubebuilder:subresource:status - -// Transaction is the Schema for the transactions API -type Transaction struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - Spec TransactionSpec `json:"spec,omitempty"` - Status TransactionStatus `json:"status,omitempty"` -} - -//+kubebuilder:object:root=true - -// TransactionList contains a list of Transaction -type TransactionList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata,omitempty"` - Items []Transaction `json:"items"` -} - -func init() { - SchemeBuilder.Register(&Transaction{}, &TransactionList{}) -} diff --git a/apis/reservation/v1alpha1/zz_generated.deepcopy.go b/apis/reservation/v1alpha1/zz_generated.deepcopy.go deleted file mode 100644 index bbcfeef..0000000 --- a/apis/reservation/v1alpha1/zz_generated.deepcopy.go +++ /dev/null @@ -1,359 +0,0 @@ -//go:build !ignore_autogenerated - -// Copyright 2022-2023 FLUIDOS Project -// -// 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. - -// Code generated by controller-gen. DO NOT EDIT. - -package v1alpha1 - -import ( - runtime "k8s.io/apimachinery/pkg/runtime" -) - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Contract) DeepCopyInto(out *Contract) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) - out.Status = in.Status -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Contract. -func (in *Contract) DeepCopy() *Contract { - if in == nil { - return nil - } - out := new(Contract) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *Contract) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ContractList) DeepCopyInto(out *ContractList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]Contract, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ContractList. -func (in *ContractList) DeepCopy() *ContractList { - if in == nil { - return nil - } - out := new(ContractList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *ContractList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ContractSpec) DeepCopyInto(out *ContractSpec) { - *out = *in - in.Flavour.DeepCopyInto(&out.Flavour) - if in.Partition != nil { - in, out := &in.Partition, &out.Partition - *out = new(Partition) - (*in).DeepCopyInto(*out) - } - out.Buyer = in.Buyer - out.Seller = in.Seller - out.SellerCredentials = in.SellerCredentials - if in.ExtraInformation != nil { - in, out := &in.ExtraInformation, &out.ExtraInformation - *out = make(map[string]string, len(*in)) - for key, val := range *in { - (*out)[key] = val - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ContractSpec. -func (in *ContractSpec) DeepCopy() *ContractSpec { - if in == nil { - return nil - } - out := new(ContractSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ContractStatus) DeepCopyInto(out *ContractStatus) { - *out = *in - out.Phase = in.Phase -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ContractStatus. -func (in *ContractStatus) DeepCopy() *ContractStatus { - if in == nil { - return nil - } - out := new(ContractStatus) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *LiqoCredentials) DeepCopyInto(out *LiqoCredentials) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LiqoCredentials. -func (in *LiqoCredentials) DeepCopy() *LiqoCredentials { - if in == nil { - return nil - } - out := new(LiqoCredentials) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Partition) DeepCopyInto(out *Partition) { - *out = *in - out.Cpu = in.Cpu.DeepCopy() - out.Memory = in.Memory.DeepCopy() - out.Gpu = in.Gpu.DeepCopy() - out.EphemeralStorage = in.EphemeralStorage.DeepCopy() - out.Storage = in.Storage.DeepCopy() -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Partition. -func (in *Partition) DeepCopy() *Partition { - if in == nil { - return nil - } - out := new(Partition) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Reservation) DeepCopyInto(out *Reservation) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) - out.Status = in.Status -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Reservation. -func (in *Reservation) DeepCopy() *Reservation { - if in == nil { - return nil - } - out := new(Reservation) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *Reservation) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ReservationList) DeepCopyInto(out *ReservationList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]Reservation, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ReservationList. -func (in *ReservationList) DeepCopy() *ReservationList { - if in == nil { - return nil - } - out := new(ReservationList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *ReservationList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ReservationSpec) DeepCopyInto(out *ReservationSpec) { - *out = *in - out.Buyer = in.Buyer - out.Seller = in.Seller - if in.Partition != nil { - in, out := &in.Partition, &out.Partition - *out = new(Partition) - (*in).DeepCopyInto(*out) - } - out.PeeringCandidate = in.PeeringCandidate -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ReservationSpec. -func (in *ReservationSpec) DeepCopy() *ReservationSpec { - if in == nil { - return nil - } - out := new(ReservationSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ReservationStatus) DeepCopyInto(out *ReservationStatus) { - *out = *in - out.Phase = in.Phase - out.Contract = in.Contract -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ReservationStatus. -func (in *ReservationStatus) DeepCopy() *ReservationStatus { - if in == nil { - return nil - } - out := new(ReservationStatus) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Transaction) DeepCopyInto(out *Transaction) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) - out.Status = in.Status -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Transaction. -func (in *Transaction) DeepCopy() *Transaction { - if in == nil { - return nil - } - out := new(Transaction) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *Transaction) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *TransactionList) DeepCopyInto(out *TransactionList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]Transaction, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TransactionList. -func (in *TransactionList) DeepCopy() *TransactionList { - if in == nil { - return nil - } - out := new(TransactionList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *TransactionList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *TransactionSpec) DeepCopyInto(out *TransactionSpec) { - *out = *in - out.Buyer = in.Buyer - if in.Partition != nil { - in, out := &in.Partition, &out.Partition - *out = new(Partition) - (*in).DeepCopyInto(*out) - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TransactionSpec. -func (in *TransactionSpec) DeepCopy() *TransactionSpec { - if in == nil { - return nil - } - out := new(TransactionSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *TransactionStatus) DeepCopyInto(out *TransactionStatus) { - *out = *in - out.Phase = in.Phase -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TransactionStatus. -func (in *TransactionStatus) DeepCopy() *TransactionStatus { - if in == nil { - return nil - } - out := new(TransactionStatus) - in.DeepCopyInto(out) - return out -} diff --git a/build/common/Dockerfile b/build/common/Dockerfile deleted file mode 100644 index 11d28da..0000000 --- a/build/common/Dockerfile +++ /dev/null @@ -1,26 +0,0 @@ -FROM golang:1.21 as builder -WORKDIR /tmp/builder - -COPY go.mod ./go.mod -COPY go.sum ./go.sum -RUN go mod download - -ARG COMPONENT -RUN test -n "$COMPONENT" || ( echo "The COMPONENT argument is unset. Aborting" && false ) - -COPY . ./ -RUN CGO_ENABLED=0 GOOS=linux GOARCH=$(go env GOARCH) go build -ldflags="-s -w" ./cmd/$COMPONENT - - -FROM alpine:3.18 - -RUN apk update && \ - apk add --no-cache ca-certificates && \ - update-ca-certificates && \ - rm -rf /var/cache/apk/* - -ARG COMPONENT -COPY --from=builder /tmp/builder/$COMPONENT /usr/bin/$COMPONENT -RUN ln -s /usr/bin/$COMPONENT /usr/bin/fluidos-component - -ENTRYPOINT [ "/usr/bin/fluidos-component" ] \ No newline at end of file diff --git a/cmd/local-resource-manager/main.go b/cmd/local-resource-manager/main.go deleted file mode 100644 index a601d71..0000000 --- a/cmd/local-resource-manager/main.go +++ /dev/null @@ -1,96 +0,0 @@ -// Copyright 2022-2023 FLUIDOS Project -// -// 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 main - -import ( - "context" - "flag" - "net/http" - "os" - - corev1 "k8s.io/api/core/v1" - "k8s.io/apimachinery/pkg/runtime" - utilruntime "k8s.io/apimachinery/pkg/util/runtime" - metricsv1beta1 "k8s.io/metrics/pkg/apis/metrics/v1beta1" - ctrl "sigs.k8s.io/controller-runtime" - "sigs.k8s.io/controller-runtime/pkg/client" - - nodecorev1alpha1 "github.com/fluidos-project/node/apis/nodecore/v1alpha1" - localResourceManager "github.com/fluidos-project/node/pkg/local-resource-manager" - "github.com/fluidos-project/node/pkg/utils/flags" -) - -var ( - scheme = runtime.NewScheme() - setupLog = ctrl.Log.WithName("setup") -) - -func init() { - utilruntime.Must(metricsv1beta1.AddToScheme(scheme)) - utilruntime.Must(corev1.AddToScheme(scheme)) - utilruntime.Must(nodecorev1alpha1.AddToScheme(scheme)) - //+kubebuilder:scaffold:scheme -} - -func main() { - var probeAddr string - flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.") - flag.StringVar(&flags.AMOUNT, "amount", "", "Amount of money set for the flavours of this node") - flag.StringVar(&flags.CURRENCY, "currency", "", "Currency of the money set for the flavours of this node") - flag.StringVar(&flags.PERIOD, "period", "", "Period set for the flavours of this node") - flag.StringVar(&flags.RESOURCE_TYPE, "resources-types", "k8s-fluidos", "Type of the Flavour related to k8s resources") - flag.StringVar(&flags.CPU_MIN, "cpu-min", "0", "Minimum CPU value") - flag.StringVar(&flags.MEMORY_MIN, "memory-min", "0", "Minimum memory value") - flag.StringVar(&flags.CPU_STEP, "cpu-step", "0", "CPU step value") - flag.StringVar(&flags.MEMORY_STEP, "memory-step", "0", "Memory step value") - flag.Int64Var(&flags.MIN_COUNT, "min-count", 0, "Minimum number of flavours") - flag.Int64Var(&flags.MAX_COUNT, "max-count", 0, "Maximum number of flavours") - flag.StringVar(&flags.RESOURCE_NODE_LABEL, "node-resource-label", "node-role.fluidos.eu/resources", "Label used to filter the k8s nodes from which create flavours") - - flag.Parse() - - cfg := ctrl.GetConfigOrDie() - cl, err := client.New(cfg, client.Options{Scheme: scheme}) - if err != nil { - setupLog.Error(err, "Unable to create client") - os.Exit(1) - } - - err = localResourceManager.Start(context.Background(), cl) - if err != nil { - setupLog.Error(err, "Unable to start LocalResourceManager") - os.Exit(1) - } - - mux := http.NewServeMux() - mux.HandleFunc("/healthz", healthHandler) // health check endpoint - mux.HandleFunc("/readyz", healthHandler) // readiness check endpoint - - server := &http.Server{ - Addr: probeAddr, - Handler: mux, - } - - setupLog.Info("Starting server", "address", probeAddr) - if err := server.ListenAndServe(); err != http.ErrServerClosed { - setupLog.Error(err, "Server stopped unexpectedly") - os.Exit(1) - } -} - -func healthHandler(w http.ResponseWriter, r *http.Request) { - w.WriteHeader(http.StatusOK) - w.Write([]byte("OK")) -} diff --git a/cmd/rear-controller/main.go b/cmd/rear-controller/main.go deleted file mode 100644 index 9f5beec..0000000 --- a/cmd/rear-controller/main.go +++ /dev/null @@ -1,191 +0,0 @@ -/* -Copyright 2023. - -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 main - -import ( - "context" - "flag" - "os" - - // Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.) - // to ensure that exec-entrypoint and run can make use of them. - _ "k8s.io/client-go/plugin/pkg/client/auth" - "k8s.io/klog/v2" - - "k8s.io/apimachinery/pkg/runtime" - utilruntime "k8s.io/apimachinery/pkg/util/runtime" - clientgoscheme "k8s.io/client-go/kubernetes/scheme" - ctrl "sigs.k8s.io/controller-runtime" - "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/healthz" - "sigs.k8s.io/controller-runtime/pkg/log/zap" - "sigs.k8s.io/controller-runtime/pkg/manager" - - advertisementv1alpha1 "github.com/fluidos-project/node/apis/advertisement/v1alpha1" - nodecorev1alpha1 "github.com/fluidos-project/node/apis/nodecore/v1alpha1" - reservationv1alpha1 "github.com/fluidos-project/node/apis/reservation/v1alpha1" - contractmanager "github.com/fluidos-project/node/pkg/rear-controller/contract-manager" - discoverymanager "github.com/fluidos-project/node/pkg/rear-controller/discovery-manager" - gateway "github.com/fluidos-project/node/pkg/rear-controller/gateway" - "github.com/fluidos-project/node/pkg/rear-controller/grpc" - "github.com/fluidos-project/node/pkg/utils/flags" - //+kubebuilder:scaffold:imports -) - -var ( - scheme = runtime.NewScheme() - setupLog = ctrl.Log.WithName("setup") -) - -func init() { - utilruntime.Must(clientgoscheme.AddToScheme(scheme)) - utilruntime.Must(advertisementv1alpha1.AddToScheme(scheme)) - utilruntime.Must(reservationv1alpha1.AddToScheme(scheme)) - utilruntime.Must(nodecorev1alpha1.AddToScheme(scheme)) - //+kubebuilder:scaffold:scheme -} - -func main() { - var metricsAddr string - var enableLeaderElection bool - var probeAddr string - flag.StringVar(&metricsAddr, "metrics-bind-address", ":8080", "The address the metric endpoint binds to.") - flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.") - flag.StringVar(&flags.GRPC_PORT, "grpc-port", "2710", "Port of the HTTP server") - flag.StringVar(&flags.HTTP_PORT, "http-port", "3004", "Port of the HTTP server") - flag.BoolVar(&enableLeaderElection, "leader-elect", false, "Enable leader election for controller manager. Enabling this will ensure there is only one active controller manager.") - opts := zap.Options{ - Development: true, - } - opts.BindFlags(flag.CommandLine) - flag.Parse() - - ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts))) - - mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{ - Scheme: scheme, - MetricsBindAddress: metricsAddr, - Port: 9443, - HealthProbeBindAddress: probeAddr, - LeaderElection: enableLeaderElection, - LeaderElectionID: "efa8b828.fluidos.eu", - }) - if err != nil { - setupLog.Error(err, "unable to start manager") - os.Exit(1) - } - - cache := mgr.GetCache() - - // Index the TransactionID field of the Contract CRD - indexFuncTransaction := func(obj client.Object) []string { - contract := obj.(*reservationv1alpha1.Contract) - return []string{contract.Spec.TransactionID} - } - - // Index the ClusterID field of the Contract CRD - indexFuncClusterID := func(obj client.Object) []string { - contract := obj.(*reservationv1alpha1.Contract) - return []string{contract.Spec.BuyerClusterID} - } - - if err := cache.IndexField(context.Background(), &reservationv1alpha1.Contract{}, "spec.transactionID", indexFuncTransaction); err != nil { - setupLog.Error(err, "unable to create index for field", "field", "spec.transactionID") - os.Exit(1) - } - - if err := cache.IndexField(context.Background(), &reservationv1alpha1.Contract{}, "spec.buyerClusterID", indexFuncClusterID); err != nil { - setupLog.Error(err, "unable to create index for field", "field", "spec.buyerClusterID") - os.Exit(1) - } - - gw := gateway.NewGateway(mgr.GetClient()) - grpcServer := grpc.NewGrpcServer(mgr.GetClient()) - - if err = (&discoverymanager.DiscoveryReconciler{ - Client: mgr.GetClient(), - Scheme: mgr.GetScheme(), - Gateway: gw, - }).SetupWithManager(mgr); err != nil { - setupLog.Error(err, "unable to create controller", "controller", "Discovery") - os.Exit(1) - } - - if err = (&contractmanager.ReservationReconciler{ - Client: mgr.GetClient(), - Scheme: mgr.GetScheme(), - Gateway: gw, - }).SetupWithManager(mgr); err != nil { - setupLog.Error(err, "unable to create controller", "controller", "Reservation") - os.Exit(1) - } - //+kubebuilder:scaffold:builder - - if err := mgr.AddHealthzCheck("healthz", healthz.Ping); err != nil { - setupLog.Error(err, "unable to set up health check") - os.Exit(1) - } - if err := mgr.AddReadyzCheck("readyz", healthz.Ping); err != nil { - setupLog.Error(err, "unable to set up ready check") - os.Exit(1) - } - - // Periodically clear the transaction cache - if err := mgr.Add(manager.RunnableFunc(gw.CacheRefresher(flags.REFRESH_CACHE_INTERVAL))); err != nil { - klog.Errorf("Unable to set up transaction cache refresher: %s", err) - os.Exit(1) - } - - // Periodically check if Liqo is ready - if err := mgr.Add(manager.RunnableFunc(gw.LiqoChecker(flags.LIQO_CHECK_INTERVAL))); err != nil { - klog.Errorf("Unable to set up Liqo checker: %s", err) - os.Exit(1) - } - - // Start the REAR Gateway HTTP server - if err := mgr.Add(manager.RunnableFunc(gw.Start)); err != nil { - klog.Errorf("Unable to set up Gateway HTTP server: %s", err) - os.Exit(1) - } - - // Start the REAR GRPC server - if err := mgr.Add(manager.RunnableFunc(grpcServer.Start)); err != nil { - klog.Errorf("Unable to set up Gateway GRPC server: %s", err) - os.Exit(1) - } - - // Start the REAR Gateway HTTP server - /* go func() { - gw.Start() - }() */ - - // Start the REAR GRPC server - /* go func() { - grpcServer.Start() - }() */ - - // TODO: Uncomment this when the webhook is ready. For now it does not work (Ale) - // pcv := discoverymanager.NewPCValidator(mgr.GetClient()) - - // mgr.GetWebhookServer().Register("/validate/peeringcandidate", &webhook.Admission{Handler: pcv}) - - setupLog.Info("starting manager") - if err := mgr.Start(ctrl.SetupSignalHandler()); err != nil { - setupLog.Error(err, "problem running manager") - os.Exit(1) - } -} diff --git a/cmd/rear-manager/main.go b/cmd/rear-manager/main.go deleted file mode 100644 index 43f7e32..0000000 --- a/cmd/rear-manager/main.go +++ /dev/null @@ -1,122 +0,0 @@ -/* -Copyright 2023. - -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 main - -import ( - "flag" - "os" - - // Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.) - // to ensure that exec-entrypoint and run can make use of them. - _ "k8s.io/client-go/plugin/pkg/client/auth" - - "k8s.io/apimachinery/pkg/runtime" - utilruntime "k8s.io/apimachinery/pkg/util/runtime" - clientgoscheme "k8s.io/client-go/kubernetes/scheme" - ctrl "sigs.k8s.io/controller-runtime" - "sigs.k8s.io/controller-runtime/pkg/healthz" - "sigs.k8s.io/controller-runtime/pkg/log/zap" - //"sigs.k8s.io/controller-runtime/pkg/webhook" - - advertisementv1alpha1 "github.com/fluidos-project/node/apis/advertisement/v1alpha1" - nodecorev1alpha1 "github.com/fluidos-project/node/apis/nodecore/v1alpha1" - reservationv1alpha1 "github.com/fluidos-project/node/apis/reservation/v1alpha1" - - //"github.com/fluidos-project/node/controllers" - rearmanager "github.com/fluidos-project/node/pkg/rear-manager" - //+kubebuilder:scaffold:imports -) - -var ( - scheme = runtime.NewScheme() - setupLog = ctrl.Log.WithName("setup") -) - -func init() { - utilruntime.Must(clientgoscheme.AddToScheme(scheme)) - utilruntime.Must(nodecorev1alpha1.AddToScheme(scheme)) - utilruntime.Must(advertisementv1alpha1.AddToScheme(scheme)) - utilruntime.Must(reservationv1alpha1.AddToScheme(scheme)) - //+kubebuilder:scaffold:scheme -} - -func main() { - var metricsAddr string - var enableLeaderElection bool - var probeAddr string - flag.StringVar(&metricsAddr, "metrics-bind-address", ":8080", "The address the metric endpoint binds to.") - flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.") - flag.BoolVar(&enableLeaderElection, "leader-elect", false, - "Enable leader election for controller manager. "+ - "Enabling this will ensure there is only one active controller manager.") - opts := zap.Options{ - Development: true, - } - opts.BindFlags(flag.CommandLine) - flag.Parse() - - ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts))) - - mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{ - Scheme: scheme, - MetricsBindAddress: metricsAddr, - Port: 9443, - HealthProbeBindAddress: probeAddr, - LeaderElection: enableLeaderElection, - LeaderElectionID: "586b6b69.fluidos.eu", - }) - if err != nil { - setupLog.Error(err, "unable to start manager") - os.Exit(1) - } - - if err = (&rearmanager.SolverReconciler{ - Client: mgr.GetClient(), - Scheme: mgr.GetScheme(), - }).SetupWithManager(mgr); err != nil { - setupLog.Error(err, "unable to create controller", "controller", "Solver") - os.Exit(1) - } - - if err = (&rearmanager.AllocationReconciler{ - Client: mgr.GetClient(), - Scheme: mgr.GetScheme(), - }).SetupWithManager(mgr); err != nil { - setupLog.Error(err, "unable to create controller", "controller", "Allocation") - os.Exit(1) - } - //+kubebuilder:scaffold:builder - - if err := mgr.AddHealthzCheck("healthz", healthz.Ping); err != nil { - setupLog.Error(err, "unable to set up health check") - os.Exit(1) - } - if err := mgr.AddReadyzCheck("readyz", healthz.Ping); err != nil { - setupLog.Error(err, "unable to set up ready check") - os.Exit(1) - } - - //av := rearmanager.NewValidator(mgr.GetClient()) - - //mgr.GetWebhookServer().Register("/validate/allocation", &webhook.Admission{Handler: av}) - - setupLog.Info("starting manager") - if err := mgr.Start(ctrl.SetupSignalHandler()); err != nil { - setupLog.Error(err, "problem running manager") - os.Exit(1) - } -} diff --git a/deployments/node/.helmignore b/deployments/node/.helmignore deleted file mode 100644 index 0e8a0eb..0000000 --- a/deployments/node/.helmignore +++ /dev/null @@ -1,23 +0,0 @@ -# Patterns to ignore when building packages. -# This supports shell glob matching, relative path matching, and -# negation (prefixed with !). Only one pattern per line. -.DS_Store -# Common VCS dirs -.git/ -.gitignore -.bzr/ -.bzrignore -.hg/ -.hgignore -.svn/ -# Common backup files -*.swp -*.bak -*.tmp -*.orig -*~ -# Various IDEs -.project -.idea/ -*.tmproj -.vscode/ diff --git a/deployments/node/Chart.yaml b/deployments/node/Chart.yaml deleted file mode 100644 index 4188577..0000000 --- a/deployments/node/Chart.yaml +++ /dev/null @@ -1,24 +0,0 @@ -apiVersion: v2 -name: node -description: A Helm chart for Fluidos Node - -# A chart can be either an 'application' or a 'library' chart. -# -# Application charts are a collection of templates that can be packaged into versioned archives -# to be deployed. -# -# Library charts provide useful utilities or functions for the chart developer. They're included as -# a dependency of application charts to inject those utilities and functions into the rendering -# pipeline. Library charts do not define any templates and therefore cannot be deployed. -type: application - -# This is the chart version. This version number should be incremented each time you make changes -# to the chart and its templates, including the app version. -# Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.0.1 - -# This is the version number of the application being deployed. This version number should be -# incremented each time you make changes to the application. Versions are not expected to -# follow Semantic Versioning. They should reflect the version the application is using. -# It is recommended to use it with quotes. -appVersion: "0.0.1" diff --git a/deployments/node/README.md b/deployments/node/README.md deleted file mode 100644 index a673a1d..0000000 --- a/deployments/node/README.md +++ /dev/null @@ -1,73 +0,0 @@ -# fluidos - -![Version: 0.1.0](https://img.shields.io/badge/Version-0.1.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.1.0](https://img.shields.io/badge/AppVersion-0.1.0-informational?style=flat-square) - -A Helm chart for Fluidos Node - -## Values - -| Key | Type | Default | Description | -|-----|------|---------|-------------| -| common.affinity | object | `{}` | Affinity for all fluidos-node pods | -| common.extraArgs | list | `[]` | Extra arguments for all fluidos-node pods | -| common.nodeSelector | object | `{}` | NodeSelector for all fluidos-node pods | -| common.tolerations | list | `[]` | Tolerations for all fluidos-node pods | -| localResourceManager.config.flavour.cpuMin | string | `"0"` | The minimum number of CPUs that can be requested to purchase a flavour. | -| localResourceManager.config.flavour.cpuStep | string | `"1000m"` | The CPU step that must be respected when requesting a flavour through a Flavour Selector. | -| localResourceManager.config.flavour.memoryMin | string | `"0"` | The minimum amount of memory that can be requested to purchase a flavour. | -| localResourceManager.config.flavour.memoryStep | string | `"100Mi"` | The memory step that must be respected when requesting a flavour through a Flavour Selector. | -| localResourceManager.config.nodeResourceLabel | string | `"node-role.fluidos.eu/resources"` | Label used to identify the nodes from which resources are collected. | -| localResourceManager.config.resourceType | string | `"k8s-fluidos"` | This flag defines the resource type of the generated flavours. | -| localResourceManager.imageName | string | `"ghcr.io/fluidos-project/local-resource-manager"` | | -| localResourceManager.pod.annotations | object | `{}` | Annotations for the local-resource-manager pod. | -| localResourceManager.pod.extraArgs | list | `[]` | Extra arguments for the local-resource-manager pod. | -| localResourceManager.pod.labels | object | `{}` | Labels for the local-resource-manager pod. | -| localResourceManager.pod.resources | object | `{"limits":{},"requests":{}}` | Resource requests and limits (https://kubernetes.io/docs/user-guide/compute-resources/) for the local-resource-manager pod. | -| localResourceManager.replicas | int | `1` | The number of REAR Controller, which can be increased for active/passive high availability. | -| networkManager.configMaps.nodeIdentity.domain | string | `""` | The domain name of the FLUIDOS closed domani: It represents for instance the Enterprise and it is used to generate the FQDN of the owned FLUIDOS Nodes | -| networkManager.configMaps.nodeIdentity.ip | string | `nil` | The IP address of the FLUIDOS Node. It can be public or private, depending on the network configuration and it corresponds to the IP address to reach the Network Manager from the outside of the cluster. | -| networkManager.configMaps.nodeIdentity.name | string | `"fluidos-network-manager-identity"` | The name of the ConfigMap containing the FLUIDOS Node identity info. | -| networkManager.configMaps.nodeIdentity.nodeID | string | `nil` | The NodeID is a UUID that identifies the FLUIDOS Node. It is used to generate the FQDN of the owned FLUIDOS Nodes and it is unique in the FLUIDOS closed domain | -| networkManager.configMaps.providers.default | string | `nil` | The IP List of SuperNodes separated by commas. | -| networkManager.configMaps.providers.local | string | `""` | The IP List of Local knwon FLUIDOS Nodes separated by commas. | -| networkManager.configMaps.providers.name | string | `"fluidos-network-manager-config"` | The name of the ConfigMap containing the list of the FLUIDOS Providers and the default FLUIDOS Provider (SuperNode or Catalogue). | -| networkManager.configMaps.providers.remote | string | `nil` | The IP List of Remote known FLUIDOS Nodes separated by commas. | -| networkManager.imageName | string | `"ghcr.io/fluidos-project/network-manager"` | | -| networkManager.pod.annotations | object | `{}` | Annotations for the network-manager pod. | -| networkManager.pod.extraArgs | list | `[]` | Extra arguments for the network-manager pod. | -| networkManager.pod.labels | object | `{}` | Labels for the network-manager pod. | -| networkManager.pod.resources | object | `{"limits":{},"requests":{}}` | Resource requests and limits (https://kubernetes.io/docs/user-guide/compute-resources/) for the network-manager pod. | -| networkManager.replicas | int | `1` | The number of Network Manager, which can be increased for active/passive high availability. | -| pullPolicy | string | `"IfNotPresent"` | The pullPolicy for fluidos-node pods. | -| rearController.imageName | string | `"ghcr.io/fluidos-project/rear-controller"` | | -| rearController.pod.annotations | object | `{}` | Annotations for the rear-controller pod. | -| rearController.pod.extraArgs | list | `[]` | Extra arguments for the rear-controller pod. | -| rearController.pod.labels | object | `{}` | Labels for the rear-controller pod. | -| rearController.pod.resources | object | `{"limits":{},"requests":{}}` | Resource requests and limits (https://kubernetes.io/docs/user-guide/compute-resources/) for the rear-controller pod. | -| rearController.replicas | int | `1` | The number of REAR Controller, which can be increased for active/passive high availability. | -| rearController.service.gateway.annotations | object | `{}` | Annotations for the REAR gateway service. | -| rearController.service.gateway.labels | object | `{}` | Labels for the REAR gateway service. | -| rearController.service.gateway.loadBalancer | object | `{"ip":""}` | Options valid if service type is LoadBalancer. | -| rearController.service.gateway.loadBalancer.ip | string | `""` | Override the IP here if service type is LoadBalancer and you want to use a specific IP address, e.g., because you want a static LB. | -| rearController.service.gateway.name | string | `"gateway"` | | -| rearController.service.gateway.nodePort | object | `{"port":""}` | Options valid if service type is NodePort. | -| rearController.service.gateway.nodePort.port | string | `""` | Force the port used by the NodePort service. | -| rearController.service.gateway.port | int | `3004` | The port used by the rear-controller to expose the REAR Gateway. | -| rearController.service.gateway.targetPort | int | `3004` | The target port used by the REAR Gateway service. | -| rearController.service.gateway.type | string | `"NodePort"` | Kubernetes service to be used to expose the REAR gateway. | -| rearController.service.grpc.annotations | object | `{}` | Annotations for the gRPC service. | -| rearController.service.grpc.labels | object | `{}` | Labels for the gRPC service. | -| rearController.service.grpc.name | string | `"grpc"` | | -| rearController.service.grpc.port | int | `2710` | The gRPC port used by Liqo to connect with the Gateway of the rear-controller to obtain the Contract resources for a given consumer ClusterID. | -| rearController.service.grpc.targetPort | int | `2710` | The target port used by the gRPC service. | -| rearController.service.grpc.type | string | `"ClusterIP"` | Kubernetes service used to expose the gRPC Server to liqo. | -| rearManager.imageName | string | `"ghcr.io/fluidos-project/rear-manager"` | | -| rearManager.pod.annotations | object | `{}` | Annotations for the rear-manager pod. | -| rearManager.pod.extraArgs | list | `[]` | Extra arguments for the rear-manager pod. | -| rearManager.pod.labels | object | `{}` | Labels for the rear-manager pod. | -| rearManager.pod.resources | object | `{"limits":{},"requests":{}}` | Resource requests and limits (https://kubernetes.io/docs/user-guide/compute-resources/) for the rear-manager pod. | -| rearManager.replicas | int | `1` | The number of REAR Manager, which can be increased for active/passive high availability. | -| tag | string | `""` | Images' tag to select a development version of fluidos-node instead of a release | - ----------------------------------------------- -Autogenerated from chart metadata using [helm-docs v1.11.0](https://github.com/norwoodj/helm-docs/releases/v1.11.0) diff --git a/deployments/node/crds/advertisement.fluidos.eu_discoveries.yaml b/deployments/node/crds/advertisement.fluidos.eu_discoveries.yaml deleted file mode 100644 index 9a1c202..0000000 --- a/deployments/node/crds/advertisement.fluidos.eu_discoveries.yaml +++ /dev/null @@ -1,225 +0,0 @@ ---- -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - controller-gen.kubebuilder.io/version: v0.13.0 - name: discoveries.advertisement.fluidos.eu -spec: - group: advertisement.fluidos.eu - names: - kind: Discovery - listKind: DiscoveryList - plural: discoveries - singular: discovery - scope: Namespaced - versions: - - additionalPrinterColumns: - - jsonPath: .spec.solverID - name: Solver ID - type: string - - jsonPath: .spec.subscribe - name: Subscribe - type: boolean - - jsonPath: .status.peeringCandidate.namespace - name: PC Namespace - type: string - - jsonPath: .status.peeringCandidate.name - name: PC Name - type: string - - jsonPath: .status.phase.phase - name: Status - type: string - - jsonPath: .status.phase.message - name: Message - type: string - name: v1alpha1 - schema: - openAPIV3Schema: - description: Discovery is the Schema for the discoveries API - 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: DiscoverySpec defines the desired state of Discovery - properties: - selector: - description: 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 - properties: - architecture: - type: string - matchSelector: - description: MatchSelector represents the criteria for selecting - Flavours through a strict match. - properties: - cpu: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - ephemeralStorage: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - gpu: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - memory: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - storage: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - required: - - cpu - - memory - type: object - rangeSelector: - description: RangeSelector represents the criteria for selecting - Flavours through a range. - properties: - MaxCpu: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - MaxEph: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - MaxGpu: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - MaxMemory: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - MaxStorage: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - minCpu: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - minEph: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - minGpu: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - minMemory: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - minStorage: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - type: object - type: - type: string - required: - - architecture - - type - type: object - solverID: - description: This is the Solver ID of the solver that creates and - so asks for the discovery. This is a reference to the Solver CRD - type: string - subscribe: - description: This flag indicates that needs to be enstablished a subscription - to the provider in case a match is found. In order to have periodic - updates of the status of the matching Flavour - type: boolean - required: - - selector - - solverID - - subscribe - type: object - status: - description: DiscoveryStatus defines the observed state of Discovery - properties: - peeringCandidate: - description: This is the reference to the PeeringCandidate CRD that - is the result of the discovery if a match is found - properties: - name: - description: The name of the resource to be referenced. - type: string - namespace: - description: The namespace containing the resource to be referenced. - It should be left empty in case of cluster-wide resources. - type: string - type: object - phase: - description: This is the current phase of the discovery - properties: - endTime: - type: string - lastChangeTime: - type: string - message: - type: string - phase: - type: string - startTime: - type: string - required: - - phase - type: object - required: - - phase - type: object - type: object - served: true - storage: true - subresources: - status: {} diff --git a/deployments/node/crds/advertisement.fluidos.eu_peeringcandidates.yaml b/deployments/node/crds/advertisement.fluidos.eu_peeringcandidates.yaml deleted file mode 100644 index 8175c5d..0000000 --- a/deployments/node/crds/advertisement.fluidos.eu_peeringcandidates.yaml +++ /dev/null @@ -1,309 +0,0 @@ ---- -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - controller-gen.kubebuilder.io/version: v0.13.0 - name: peeringcandidates.advertisement.fluidos.eu -spec: - group: advertisement.fluidos.eu - names: - kind: PeeringCandidate - listKind: PeeringCandidateList - plural: peeringcandidates - singular: peeringcandidate - scope: Namespaced - versions: - - name: v1alpha1 - schema: - openAPIV3Schema: - description: PeeringCandidate is the Schema for the peeringcandidates API - 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: PeeringCandidateSpec defines the desired state of PeeringCandidate - properties: - flavour: - description: Flavour is the Schema for the flavours API - 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: - properties: - annotations: - additionalProperties: - type: string - type: object - finalizers: - items: - type: string - type: array - labels: - additionalProperties: - type: string - type: object - name: - type: string - namespace: - type: string - type: object - spec: - description: FlavourSpec defines the desired state of Flavour - properties: - characteristics: - description: Characteristics contains the characteristics - of the Flavour. They are based on the type of the Flavour - and can change depending on it. In this case, the type is - K8S so the characteristics are CPU, Memory, GPU and EphemeralStorage. - properties: - architecture: - description: Architecture is the architecture of the Flavour. - type: string - cpu: - anyOf: - - type: integer - - type: string - description: CPU is the number of CPU cores of the Flavour. - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - ephemeral-storage: - anyOf: - - type: integer - - type: string - description: EphemeralStorage is the amount of ephemeral - storage of the Flavour. - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - gpu: - anyOf: - - type: integer - - type: string - description: GPU is the number of GPU cores of the Flavour. - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - memory: - anyOf: - - type: integer - - type: string - description: Memory is the amount of RAM of the Flavour. - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - persistent-storage: - anyOf: - - type: integer - - type: string - description: PersistentStorage is the amount of persistent - storage of the Flavour. - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - required: - - architecture - - cpu - - memory - type: object - flavourID: - description: FlavourID is the name of the Flavour. - type: string - optionalFields: - description: This field is used to specify the optional fields - that can be retrieved from the Flavour. In the future it - will be expanded to include more optional fields defined - in the REAR Protocol or custom ones. - properties: - availability: - description: Availability is the availability flag of - the Flavour. It is a field inherited from the REAR Protocol - specifications. - type: boolean - workerID: - description: WorkerID is the ID of the worker that provides - the Flavour. - type: string - type: object - owner: - description: Owner contains the identity info of the owner - of the Flavour. It can be unknown if the Flavour is provided - by a reseller or a third party. - properties: - domain: - type: string - ip: - type: string - nodeID: - type: string - required: - - domain - - ip - - nodeID - type: object - policy: - description: Policy contains the policy of the Flavour. The - policy describes the partitioning and aggregation properties - of the Flavour. - properties: - aggregatable: - description: Aggregatable contains the aggregation properties - of the Flavour. - properties: - maxCount: - description: MaxCount is the maximum requirable number - of instances of the Flavour. - type: integer - minCount: - description: MinCount is the minimum requirable number - of instances of the Flavour. - type: integer - required: - - maxCount - - minCount - type: object - partitionable: - description: Partitionable contains the partitioning properties - of the Flavour. - properties: - cpuMin: - anyOf: - - type: integer - - type: string - description: CpuMin is the minimum requirable number - of CPU cores of the Flavour. - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - cpuStep: - anyOf: - - type: integer - - type: string - description: CpuStep is the incremental value of CPU - cores of the Flavour. - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - memoryMin: - anyOf: - - type: integer - - type: string - description: MemoryMin is the minimum requirable amount - of RAM of the Flavour. - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - memoryStep: - anyOf: - - type: integer - - type: string - description: MemoryStep is the incremental value of - RAM of the Flavour. - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - required: - - cpuMin - - cpuStep - - memoryMin - - memoryStep - type: object - type: object - price: - description: Price contains the price model of the Flavour. - properties: - amount: - description: Amount is the amount of the price. - type: string - currency: - description: Currency is the currency of the price. - type: string - period: - description: Period is the period of the price. - type: string - required: - - amount - - currency - - period - type: object - providerID: - description: ProviderID is the ID of the FLUIDOS Node ID that - provides this Flavour. It can correspond to ID of the owner - FLUIDOS Node or to the ID of a FLUIDOS SuperNode that represents - the entry point to a FLUIDOS Domain - type: string - type: - description: Type is the type of the Flavour. Currently, only - K8S is supported. - type: string - required: - - characteristics - - flavourID - - optionalFields - - owner - - policy - - price - - providerID - - type - type: object - status: - description: FlavourStatus defines the observed state of Flavour - properties: - creationTime: - description: This field represents the creation time of the - Flavour. - type: string - expirationTime: - description: This field represents the expiration time of - the Flavour. It is used to determine when the Flavour is - no longer valid. - type: string - lastUpdateTime: - description: This field represents the last update time of - the Flavour. - type: string - required: - - creationTime - - expirationTime - - lastUpdateTime - type: object - type: object - reserved: - type: boolean - solverID: - type: string - required: - - flavour - - reserved - - solverID - type: object - status: - description: PeeringCandidateStatus defines the observed state of PeeringCandidate - properties: - creationTime: - description: This field represents the creation time of the PeeringCandidate. - type: string - lastUpdateTime: - description: This field represents the last update time of the PeeringCandidate. - type: string - required: - - creationTime - - lastUpdateTime - type: object - type: object - served: true - storage: true - subresources: - status: {} diff --git a/deployments/node/crds/nodecore.fluidos.eu_allocations.yaml b/deployments/node/crds/nodecore.fluidos.eu_allocations.yaml deleted file mode 100644 index 4f4a82d..0000000 --- a/deployments/node/crds/nodecore.fluidos.eu_allocations.yaml +++ /dev/null @@ -1,447 +0,0 @@ ---- -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - controller-gen.kubebuilder.io/version: v0.13.0 - name: allocations.nodecore.fluidos.eu -spec: - group: nodecore.fluidos.eu - names: - kind: Allocation - listKind: AllocationList - plural: allocations - singular: allocation - scope: Namespaced - versions: - - name: v1alpha1 - schema: - openAPIV3Schema: - description: Allocation is the Schema for the allocations API - 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: AllocationSpec defines the desired state of Allocation - properties: - flavour: - description: This Flavour describes the characteristics of the allocation, - it is based on the Flavour CRD from which it was created - 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: - properties: - annotations: - additionalProperties: - type: string - type: object - finalizers: - items: - type: string - type: array - labels: - additionalProperties: - type: string - type: object - name: - type: string - namespace: - type: string - type: object - spec: - description: FlavourSpec defines the desired state of Flavour - properties: - characteristics: - description: Characteristics contains the characteristics - of the Flavour. They are based on the type of the Flavour - and can change depending on it. In this case, the type is - K8S so the characteristics are CPU, Memory, GPU and EphemeralStorage. - properties: - architecture: - description: Architecture is the architecture of the Flavour. - type: string - cpu: - anyOf: - - type: integer - - type: string - description: CPU is the number of CPU cores of the Flavour. - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - ephemeral-storage: - anyOf: - - type: integer - - type: string - description: EphemeralStorage is the amount of ephemeral - storage of the Flavour. - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - gpu: - anyOf: - - type: integer - - type: string - description: GPU is the number of GPU cores of the Flavour. - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - memory: - anyOf: - - type: integer - - type: string - description: Memory is the amount of RAM of the Flavour. - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - persistent-storage: - anyOf: - - type: integer - - type: string - description: PersistentStorage is the amount of persistent - storage of the Flavour. - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - required: - - architecture - - cpu - - memory - type: object - flavourID: - description: FlavourID is the name of the Flavour. - type: string - optionalFields: - description: This field is used to specify the optional fields - that can be retrieved from the Flavour. In the future it - will be expanded to include more optional fields defined - in the REAR Protocol or custom ones. - properties: - availability: - description: Availability is the availability flag of - the Flavour. It is a field inherited from the REAR Protocol - specifications. - type: boolean - workerID: - description: WorkerID is the ID of the worker that provides - the Flavour. - type: string - type: object - owner: - description: Owner contains the identity info of the owner - of the Flavour. It can be unknown if the Flavour is provided - by a reseller or a third party. - properties: - domain: - type: string - ip: - type: string - nodeID: - type: string - required: - - domain - - ip - - nodeID - type: object - policy: - description: Policy contains the policy of the Flavour. The - policy describes the partitioning and aggregation properties - of the Flavour. - properties: - aggregatable: - description: Aggregatable contains the aggregation properties - of the Flavour. - properties: - maxCount: - description: MaxCount is the maximum requirable number - of instances of the Flavour. - type: integer - minCount: - description: MinCount is the minimum requirable number - of instances of the Flavour. - type: integer - required: - - maxCount - - minCount - type: object - partitionable: - description: Partitionable contains the partitioning properties - of the Flavour. - properties: - cpuMin: - anyOf: - - type: integer - - type: string - description: CpuMin is the minimum requirable number - of CPU cores of the Flavour. - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - cpuStep: - anyOf: - - type: integer - - type: string - description: CpuStep is the incremental value of CPU - cores of the Flavour. - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - memoryMin: - anyOf: - - type: integer - - type: string - description: MemoryMin is the minimum requirable amount - of RAM of the Flavour. - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - memoryStep: - anyOf: - - type: integer - - type: string - description: MemoryStep is the incremental value of - RAM of the Flavour. - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - required: - - cpuMin - - cpuStep - - memoryMin - - memoryStep - type: object - type: object - price: - description: Price contains the price model of the Flavour. - properties: - amount: - description: Amount is the amount of the price. - type: string - currency: - description: Currency is the currency of the price. - type: string - period: - description: Period is the period of the price. - type: string - required: - - amount - - currency - - period - type: object - providerID: - description: ProviderID is the ID of the FLUIDOS Node ID that - provides this Flavour. It can correspond to ID of the owner - FLUIDOS Node or to the ID of a FLUIDOS SuperNode that represents - the entry point to a FLUIDOS Domain - type: string - type: - description: Type is the type of the Flavour. Currently, only - K8S is supported. - type: string - required: - - characteristics - - flavourID - - optionalFields - - owner - - policy - - price - - providerID - - type - type: object - status: - description: FlavourStatus defines the observed state of Flavour - properties: - creationTime: - description: This field represents the creation time of the - Flavour. - type: string - expirationTime: - description: This field represents the expiration time of - the Flavour. It is used to determine when the Flavour is - no longer valid. - type: string - lastUpdateTime: - description: This field represents the last update time of - the Flavour. - type: string - required: - - creationTime - - expirationTime - - lastUpdateTime - type: object - type: object - forwarding: - description: 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 - type: boolean - intentID: - description: 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 - type: string - localNode: - description: This is the corresponding Node or VirtualNode name - type: string - partition: - description: This is the dimension of the allocation, it is based - on the Flavour CRD from which it was created - properties: - architecture: - type: string - matchSelector: - description: MatchSelector represents the criteria for selecting - Flavours through a strict match. - properties: - cpu: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - ephemeralStorage: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - gpu: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - memory: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - storage: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - required: - - cpu - - memory - type: object - rangeSelector: - description: RangeSelector represents the criteria for selecting - Flavours through a range. - properties: - MaxCpu: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - MaxEph: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - MaxGpu: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - MaxMemory: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - MaxStorage: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - minCpu: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - minEph: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - minGpu: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - minMemory: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - minStorage: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - type: object - type: - type: string - required: - - architecture - - type - type: object - type: - description: 'This specifies the type of the node: Node (Physical - node of the cluster) or VirtualNode (Remote node owned by a different - cluster)' - type: string - required: - - flavour - - forwarding - - intentID - - localNode - - type - type: object - status: - description: AllocationStatus defines the observed state of Allocation - properties: - creationTime: - description: The creation time of the allocation object - format: date-time - type: string - lastUpdateTime: - description: The last time the allocation was updated - format: date-time - type: string - status: - description: This allow to know the current status of the allocation - type: string - required: - - creationTime - - lastUpdateTime - - status - type: object - type: object - served: true - storage: true - subresources: - status: {} diff --git a/deployments/node/crds/nodecore.fluidos.eu_flavours.yaml b/deployments/node/crds/nodecore.fluidos.eu_flavours.yaml deleted file mode 100644 index 1754b77..0000000 --- a/deployments/node/crds/nodecore.fluidos.eu_flavours.yaml +++ /dev/null @@ -1,244 +0,0 @@ ---- -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - controller-gen.kubebuilder.io/version: v0.13.0 - name: flavours.nodecore.fluidos.eu -spec: - group: nodecore.fluidos.eu - names: - kind: Flavour - listKind: FlavourList - plural: flavours - singular: flavour - scope: Namespaced - versions: - - name: v1alpha1 - schema: - openAPIV3Schema: - description: Flavour is the Schema for the flavours API - 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: FlavourSpec defines the desired state of Flavour - properties: - characteristics: - description: Characteristics contains the characteristics of the Flavour. - They are based on the type of the Flavour and can change depending - on it. In this case, the type is K8S so the characteristics are - CPU, Memory, GPU and EphemeralStorage. - properties: - architecture: - description: Architecture is the architecture of the Flavour. - type: string - cpu: - anyOf: - - type: integer - - type: string - description: CPU is the number of CPU cores of the Flavour. - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - ephemeral-storage: - anyOf: - - type: integer - - type: string - description: EphemeralStorage is the amount of ephemeral storage - of the Flavour. - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - gpu: - anyOf: - - type: integer - - type: string - description: GPU is the number of GPU cores of the Flavour. - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - memory: - anyOf: - - type: integer - - type: string - description: Memory is the amount of RAM of the Flavour. - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - persistent-storage: - anyOf: - - type: integer - - type: string - description: PersistentStorage is the amount of persistent storage - of the Flavour. - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - required: - - architecture - - cpu - - memory - type: object - flavourID: - description: FlavourID is the name of the Flavour. - type: string - optionalFields: - description: This field is used to specify the optional fields that - can be retrieved from the Flavour. In the future it will be expanded - to include more optional fields defined in the REAR Protocol or - custom ones. - properties: - availability: - description: Availability is the availability flag of the Flavour. - It is a field inherited from the REAR Protocol specifications. - type: boolean - workerID: - description: WorkerID is the ID of the worker that provides the - Flavour. - type: string - type: object - owner: - description: Owner contains the identity info of the owner of the - Flavour. It can be unknown if the Flavour is provided by a reseller - or a third party. - properties: - domain: - type: string - ip: - type: string - nodeID: - type: string - required: - - domain - - ip - - nodeID - type: object - policy: - description: Policy contains the policy of the Flavour. The policy - describes the partitioning and aggregation properties of the Flavour. - properties: - aggregatable: - description: Aggregatable contains the aggregation properties - of the Flavour. - properties: - maxCount: - description: MaxCount is the maximum requirable number of - instances of the Flavour. - type: integer - minCount: - description: MinCount is the minimum requirable number of - instances of the Flavour. - type: integer - required: - - maxCount - - minCount - type: object - partitionable: - description: Partitionable contains the partitioning properties - of the Flavour. - properties: - cpuMin: - anyOf: - - type: integer - - type: string - description: CpuMin is the minimum requirable number of CPU - cores of the Flavour. - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - cpuStep: - anyOf: - - type: integer - - type: string - description: CpuStep is the incremental value of CPU cores - of the Flavour. - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - memoryMin: - anyOf: - - type: integer - - type: string - description: MemoryMin is the minimum requirable amount of - RAM of the Flavour. - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - memoryStep: - anyOf: - - type: integer - - type: string - description: MemoryStep is the incremental value of RAM of - the Flavour. - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - required: - - cpuMin - - cpuStep - - memoryMin - - memoryStep - type: object - type: object - price: - description: Price contains the price model of the Flavour. - properties: - amount: - description: Amount is the amount of the price. - type: string - currency: - description: Currency is the currency of the price. - type: string - period: - description: Period is the period of the price. - type: string - required: - - amount - - currency - - period - type: object - providerID: - description: ProviderID is the ID of the FLUIDOS Node ID that provides - this Flavour. It can correspond to ID of the owner FLUIDOS Node - or to the ID of a FLUIDOS SuperNode that represents the entry point - to a FLUIDOS Domain - type: string - type: - description: Type is the type of the Flavour. Currently, only K8S - is supported. - type: string - required: - - characteristics - - flavourID - - optionalFields - - owner - - policy - - price - - providerID - - type - type: object - status: - description: FlavourStatus defines the observed state of Flavour - properties: - creationTime: - description: This field represents the creation time of the Flavour. - type: string - expirationTime: - description: This field represents the expiration time of the Flavour. - It is used to determine when the Flavour is no longer valid. - type: string - lastUpdateTime: - description: This field represents the last update time of the Flavour. - type: string - required: - - creationTime - - expirationTime - - lastUpdateTime - type: object - type: object - served: true - storage: true - subresources: - status: {} diff --git a/deployments/node/crds/nodecore.fluidos.eu_solvers.yaml b/deployments/node/crds/nodecore.fluidos.eu_solvers.yaml deleted file mode 100644 index d716922..0000000 --- a/deployments/node/crds/nodecore.fluidos.eu_solvers.yaml +++ /dev/null @@ -1,287 +0,0 @@ ---- -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - controller-gen.kubebuilder.io/version: v0.13.0 - name: solvers.nodecore.fluidos.eu -spec: - group: nodecore.fluidos.eu - names: - kind: Solver - listKind: SolverList - plural: solvers - singular: solver - scope: Namespaced - versions: - - additionalPrinterColumns: - - jsonPath: .spec.intentID - name: Intent ID - type: string - - jsonPath: .spec.findCandidate - name: Find Candidate - type: boolean - - jsonPath: .spec.reserveAndBuy - name: Reserve and Buy - type: boolean - - jsonPath: .spec.enstablishPeering - name: Peering - type: boolean - - jsonPath: .status.findCandidate - name: Candidate Phase - priority: 1 - type: string - - jsonPath: .status.reserveAndBuy - name: Reserving Phase - priority: 1 - type: string - - jsonPath: .status.peering - name: Peering Phase - priority: 1 - type: string - - jsonPath: .status.solverPhase.phase - name: Status - type: string - - jsonPath: .status.solverPhase.message - name: Message - type: string - - jsonPath: .metadata.creationTimestamp - name: Age - type: date - name: v1alpha1 - schema: - openAPIV3Schema: - description: Solver is the Schema for the solvers API Solver is the Schema - for the solvers API - 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: SolverSpec defines the desired state of Solver - properties: - enstablishPeering: - description: EnstablishPeering is a flag that indicates if the solver - should enstablish a peering with the candidate. - type: boolean - findCandidate: - description: FindCandidate is a flag that indicates if the solver - should find a candidate to solve the intent. - type: boolean - intentID: - description: IntentID is the ID of the intent that the Node Orchestrator - is trying to solve. It is used to link the solver with the intent. - type: string - reserveAndBuy: - description: ReserveAndBuy is a flag that indicates if the solver - should reserve and buy the resources on the candidate. - type: boolean - selector: - description: Selector contains the flavour requirements for the solver. - properties: - architecture: - type: string - matchSelector: - description: MatchSelector represents the criteria for selecting - Flavours through a strict match. - properties: - cpu: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - ephemeralStorage: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - gpu: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - memory: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - storage: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - required: - - cpu - - memory - type: object - rangeSelector: - description: RangeSelector represents the criteria for selecting - Flavours through a range. - properties: - MaxCpu: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - MaxEph: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - MaxGpu: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - MaxMemory: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - MaxStorage: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - minCpu: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - minEph: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - minGpu: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - minMemory: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - minStorage: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - type: object - type: - type: string - required: - - architecture - - type - type: object - required: - - intentID - type: object - status: - description: SolverStatus defines the observed state of Solver - properties: - allocation: - description: Allocation contains the allocation that the solver has - eventually created for the intent. It can correspond to a virtual - node The Node Orchestrator will use this allocation to fullfill - the intent. - properties: - name: - description: The name of the resource to be referenced. - type: string - namespace: - description: The namespace containing the resource to be referenced. - It should be left empty in case of cluster-wide resources. - type: string - type: object - consumePhase: - description: ConsumePhase describes the status of the Consume phase - where the VFM (Liqo) is enstablishing a peering with the candidate - node. - type: string - discoveryPhase: - description: DiscoveryPhase describes the status of the Discovery - where the Discovery Manager is looking for matching flavours outside - the FLUIDOS Node - type: string - findCandidate: - description: FindCandidate describes the status of research of the - candidate. Rear Manager is looking for the best candidate Flavour - to solve the Node Orchestrator request. - type: string - peering: - description: Peering describes the status of the peering with the - candidate. Rear Manager is trying to enstablish a peering with the - candidate FLUIDOS Node. - type: string - peeringCandidate: - description: PeeringCandidate contains the candidate that the solver - has eventually found to solve the intent. - properties: - name: - description: The name of the resource to be referenced. - type: string - namespace: - description: The namespace containing the resource to be referenced. - It should be left empty in case of cluster-wide resources. - type: string - type: object - reservationPhase: - description: ReservationPhase describes the status of the Reservation - where the Contract Manager is reserving and purchasing the resources - on the candidate node. - type: string - reserveAndBuy: - description: ReserveAndBuy describes the status of the reservation - and purchase of selected Flavour. Rear Manager is trying to reserve - and purchase the resources on the candidate FLUIDOS Node. - type: string - solverPhase: - description: SolverPhase describes the status of the Solver generated - by the Node Orchestrator. It is usefull to understand if the solver - is still running or if it has finished or failed. - properties: - endTime: - type: string - lastChangeTime: - type: string - message: - type: string - phase: - type: string - startTime: - type: string - required: - - phase - type: object - type: object - type: object - served: true - storage: true - subresources: - status: {} diff --git a/deployments/node/crds/reservation.fluidos.eu_contracts.yaml b/deployments/node/crds/reservation.fluidos.eu_contracts.yaml deleted file mode 100644 index 2087007..0000000 --- a/deployments/node/crds/reservation.fluidos.eu_contracts.yaml +++ /dev/null @@ -1,426 +0,0 @@ ---- -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - controller-gen.kubebuilder.io/version: v0.13.0 - name: contracts.reservation.fluidos.eu -spec: - group: reservation.fluidos.eu - names: - kind: Contract - listKind: ContractList - plural: contracts - singular: contract - scope: Namespaced - versions: - - name: v1alpha1 - schema: - openAPIV3Schema: - description: Contract is the Schema for the contracts API - 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: ContractSpec defines the desired state of Contract - properties: - buyer: - description: This is the Node identity of the buyer FLUIDOS Node. - properties: - domain: - type: string - ip: - type: string - nodeID: - type: string - required: - - domain - - ip - - nodeID - type: object - buyerClusterID: - description: BuyerClusterID is the Liqo ClusterID used by the seller - to search a contract and the related resources during the peering - phase. - type: string - expirationTime: - description: This is the expiration time of the contract. It can be - empty if the contract is not time limited. - type: string - extraInformation: - additionalProperties: - type: string - description: This contains additional information about the contract - if needed. - type: object - flavour: - description: This is the flavour on which the contract is based. It - is used to lifetime maintain the critical characteristics of the - contract. - 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: - properties: - annotations: - additionalProperties: - type: string - type: object - finalizers: - items: - type: string - type: array - labels: - additionalProperties: - type: string - type: object - name: - type: string - namespace: - type: string - type: object - spec: - description: FlavourSpec defines the desired state of Flavour - properties: - characteristics: - description: Characteristics contains the characteristics - of the Flavour. They are based on the type of the Flavour - and can change depending on it. In this case, the type is - K8S so the characteristics are CPU, Memory, GPU and EphemeralStorage. - properties: - architecture: - description: Architecture is the architecture of the Flavour. - type: string - cpu: - anyOf: - - type: integer - - type: string - description: CPU is the number of CPU cores of the Flavour. - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - ephemeral-storage: - anyOf: - - type: integer - - type: string - description: EphemeralStorage is the amount of ephemeral - storage of the Flavour. - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - gpu: - anyOf: - - type: integer - - type: string - description: GPU is the number of GPU cores of the Flavour. - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - memory: - anyOf: - - type: integer - - type: string - description: Memory is the amount of RAM of the Flavour. - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - persistent-storage: - anyOf: - - type: integer - - type: string - description: PersistentStorage is the amount of persistent - storage of the Flavour. - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - required: - - architecture - - cpu - - memory - type: object - flavourID: - description: FlavourID is the name of the Flavour. - type: string - optionalFields: - description: This field is used to specify the optional fields - that can be retrieved from the Flavour. In the future it - will be expanded to include more optional fields defined - in the REAR Protocol or custom ones. - properties: - availability: - description: Availability is the availability flag of - the Flavour. It is a field inherited from the REAR Protocol - specifications. - type: boolean - workerID: - description: WorkerID is the ID of the worker that provides - the Flavour. - type: string - type: object - owner: - description: Owner contains the identity info of the owner - of the Flavour. It can be unknown if the Flavour is provided - by a reseller or a third party. - properties: - domain: - type: string - ip: - type: string - nodeID: - type: string - required: - - domain - - ip - - nodeID - type: object - policy: - description: Policy contains the policy of the Flavour. The - policy describes the partitioning and aggregation properties - of the Flavour. - properties: - aggregatable: - description: Aggregatable contains the aggregation properties - of the Flavour. - properties: - maxCount: - description: MaxCount is the maximum requirable number - of instances of the Flavour. - type: integer - minCount: - description: MinCount is the minimum requirable number - of instances of the Flavour. - type: integer - required: - - maxCount - - minCount - type: object - partitionable: - description: Partitionable contains the partitioning properties - of the Flavour. - properties: - cpuMin: - anyOf: - - type: integer - - type: string - description: CpuMin is the minimum requirable number - of CPU cores of the Flavour. - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - cpuStep: - anyOf: - - type: integer - - type: string - description: CpuStep is the incremental value of CPU - cores of the Flavour. - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - memoryMin: - anyOf: - - type: integer - - type: string - description: MemoryMin is the minimum requirable amount - of RAM of the Flavour. - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - memoryStep: - anyOf: - - type: integer - - type: string - description: MemoryStep is the incremental value of - RAM of the Flavour. - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - required: - - cpuMin - - cpuStep - - memoryMin - - memoryStep - type: object - type: object - price: - description: Price contains the price model of the Flavour. - properties: - amount: - description: Amount is the amount of the price. - type: string - currency: - description: Currency is the currency of the price. - type: string - period: - description: Period is the period of the price. - type: string - required: - - amount - - currency - - period - type: object - providerID: - description: ProviderID is the ID of the FLUIDOS Node ID that - provides this Flavour. It can correspond to ID of the owner - FLUIDOS Node or to the ID of a FLUIDOS SuperNode that represents - the entry point to a FLUIDOS Domain - type: string - type: - description: Type is the type of the Flavour. Currently, only - K8S is supported. - type: string - required: - - characteristics - - flavourID - - optionalFields - - owner - - policy - - price - - providerID - - type - type: object - status: - description: FlavourStatus defines the observed state of Flavour - properties: - creationTime: - description: This field represents the creation time of the - Flavour. - type: string - expirationTime: - description: This field represents the expiration time of - the Flavour. It is used to determine when the Flavour is - no longer valid. - type: string - lastUpdateTime: - description: This field represents the last update time of - the Flavour. - type: string - required: - - creationTime - - expirationTime - - lastUpdateTime - type: object - type: object - partition: - description: The partition represents the dimension of the resources - sold/bought. So it will reflect the dimension of the resources allocated - on the remote cluster and reflected on the local virtual node. - properties: - architecture: - type: string - cpu: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - ephemeral-storage: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - gpu: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - memory: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - storage: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - required: - - architecture - - cpu - - memory - type: object - seller: - description: This is the Node identity of the seller FLUIDOS Node. - properties: - domain: - type: string - ip: - type: string - nodeID: - type: string - required: - - domain - - ip - - nodeID - type: object - sellerCredentials: - description: This credentials will be used by the customer to connect - and enstablish a peering with the seller FLUIDOS Node through Liqo. - properties: - clusterID: - type: string - clusterName: - type: string - endpoint: - type: string - token: - type: string - required: - - clusterID - - clusterName - - endpoint - - token - type: object - transactionID: - description: TransactionID is the ID of the transaction that this - contract is part of - type: string - required: - - buyer - - buyerClusterID - - flavour - - seller - - sellerCredentials - - transactionID - type: object - status: - description: ContractStatus defines the observed state of Contract - properties: - phase: - description: This is the status of the contract. - properties: - endTime: - type: string - lastChangeTime: - type: string - message: - type: string - phase: - type: string - startTime: - type: string - required: - - phase - type: object - required: - - phase - type: object - type: object - served: true - storage: true - subresources: - status: {} diff --git a/deployments/node/crds/reservation.fluidos.eu_reservations.yaml b/deployments/node/crds/reservation.fluidos.eu_reservations.yaml deleted file mode 100644 index 42644c5..0000000 --- a/deployments/node/crds/reservation.fluidos.eu_reservations.yaml +++ /dev/null @@ -1,225 +0,0 @@ ---- -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - controller-gen.kubebuilder.io/version: v0.13.0 - name: reservations.reservation.fluidos.eu -spec: - group: reservation.fluidos.eu - names: - kind: Reservation - listKind: ReservationList - plural: reservations - singular: reservation - scope: Namespaced - versions: - - additionalPrinterColumns: - - jsonPath: .spec.solverID - name: Solver ID - type: string - - jsonPath: .spec.reserve - name: Reserve - type: boolean - - jsonPath: .spec.purchase - name: Purchase - type: boolean - - jsonPath: .spec.seller.name - name: Seller - type: string - - jsonPath: .spec.peeringCandidate.name - name: Peering Candidate - priority: 1 - type: string - - jsonPath: .status.transactionID - name: Transaction ID - type: string - - jsonPath: .status.reservePhase.phase - name: Reserve Phase - priority: 1 - type: string - - jsonPath: .status.purchasePhase.phase - name: Purchase Phase - priority: 1 - type: string - - jsonPath: .status.contract.name - name: Contract Name - type: string - - jsonPath: .status.phase.phase - name: Status - type: string - - jsonPath: .status.phase.message - name: Message - priority: 1 - type: string - name: v1alpha1 - schema: - openAPIV3Schema: - description: Reservation is the Schema for the reservations API - 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: ReservationSpec defines the desired state of Reservation - properties: - buyer: - description: This is the Node identity of the buyer FLUIDOS Node. - properties: - domain: - type: string - ip: - type: string - nodeID: - type: string - required: - - domain - - ip - - nodeID - type: object - buyerClusterID: - description: BuyerClusterID is the Liqo ClusterID used by the seller - to search a contract and the related resources during the peering - phase. - type: string - partition: - description: Parition is the partition of the flavour that is being - reserved - properties: - architecture: - type: string - cpu: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - ephemeral-storage: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - gpu: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - memory: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - storage: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - required: - - architecture - - cpu - - memory - type: object - peeringCandidate: - description: PeeringCandidate is the reference to the PeeringCandidate - of the Reservation - properties: - name: - description: The name of the resource to be referenced. - type: string - namespace: - description: The namespace containing the resource to be referenced. - It should be left empty in case of cluster-wide resources. - type: string - type: object - purchase: - description: Purchase indicates if the reservation is an purchase - or not - type: boolean - reserve: - description: Reserve indicates if the reservation is a reserve or - not - type: boolean - seller: - description: This is the Node identity of the seller FLUIDOS Node. - properties: - domain: - type: string - ip: - type: string - nodeID: - type: string - required: - - domain - - ip - - nodeID - type: object - solverID: - description: SolverID is the ID of the solver that asks for the reservation - type: string - required: - - buyer - - buyerClusterID - - seller - - solverID - type: object - status: - description: ReservationStatus defines the observed state of Reservation - properties: - contract: - description: Contract is the reference to the Contract of the Reservation - properties: - name: - description: The name of the resource to be referenced. - type: string - namespace: - description: The namespace containing the resource to be referenced. - It should be left empty in case of cluster-wide resources. - type: string - type: object - phase: - description: This is the current phase of the reservation - properties: - endTime: - type: string - lastChangeTime: - type: string - message: - type: string - phase: - type: string - startTime: - type: string - required: - - phase - type: object - purchasePhase: - description: PurchasePhase is the current phase of the reservation - type: string - reservePhase: - description: ReservePhase is the current phase of the reservation - type: string - transactionID: - description: TransactionID is the ID of the transaction that this - reservation is part of - type: string - required: - - phase - type: object - type: object - served: true - storage: true - subresources: - status: {} diff --git a/deployments/node/crds/reservation.fluidos.eu_transactions.yaml b/deployments/node/crds/reservation.fluidos.eu_transactions.yaml deleted file mode 100644 index ec04673..0000000 --- a/deployments/node/crds/reservation.fluidos.eu_transactions.yaml +++ /dev/null @@ -1,135 +0,0 @@ ---- -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - controller-gen.kubebuilder.io/version: v0.13.0 - name: transactions.reservation.fluidos.eu -spec: - group: reservation.fluidos.eu - names: - kind: Transaction - listKind: TransactionList - plural: transactions - singular: transaction - scope: Namespaced - versions: - - name: v1alpha1 - schema: - openAPIV3Schema: - description: Transaction is the Schema for the transactions API - 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: TransactionSpec defines the desired state of Transaction - properties: - buyer: - description: Buyer is the buyer Identity of the Fluidos Node that - is reserving the Flavour - properties: - domain: - type: string - ip: - type: string - nodeID: - type: string - required: - - domain - - ip - - nodeID - type: object - clusterID: - description: ClusterID is the Liqo ClusterID of the Fluidos Node that - is reserving the Flavour - type: string - flavourID: - description: FlavourID is the ID of the flavour that is being reserved - type: string - partition: - description: Partition is the partition of the flavour that is being - reserved - properties: - architecture: - type: string - cpu: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - ephemeral-storage: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - gpu: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - memory: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - storage: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - required: - - architecture - - cpu - - memory - type: object - startTime: - description: StartTime is the time at which the reservation should - start - type: string - required: - - buyer - - clusterID - - flavourID - type: object - status: - description: TransactionStatus defines the observed state of Transaction - properties: - phase: - description: This is the current phase of the reservation - properties: - endTime: - type: string - lastChangeTime: - type: string - message: - type: string - phase: - type: string - startTime: - type: string - required: - - phase - type: object - required: - - phase - type: object - type: object - served: true - storage: true - subresources: - status: {} diff --git a/deployments/node/files/fluidos-local-resource-manager-ClusterRole.yaml b/deployments/node/files/fluidos-local-resource-manager-ClusterRole.yaml deleted file mode 100644 index 7179a1d..0000000 --- a/deployments/node/files/fluidos-local-resource-manager-ClusterRole.yaml +++ /dev/null @@ -1,45 +0,0 @@ -rules: -- apiGroups: - - "" - resources: - - configmaps - verbs: - - get - - list - - watch -- apiGroups: - - "" - resources: - - nodes - verbs: - - get - - list - - watch -- apiGroups: - - metrics.k8s.io - resources: - - nodes - verbs: - - get - - list - - watch -- apiGroups: - - metrics.k8s.io - resources: - - pods - verbs: - - get - - list - - watch -- apiGroups: - - nodecore.fluidos.eu - resources: - - flavours - verbs: - - create - - delete - - get - - list - - patch - - update - - watch diff --git a/deployments/node/files/fluidos-rear-controller-ClusterRole.yaml b/deployments/node/files/fluidos-rear-controller-ClusterRole.yaml deleted file mode 100644 index 044e17c..0000000 --- a/deployments/node/files/fluidos-rear-controller-ClusterRole.yaml +++ /dev/null @@ -1,173 +0,0 @@ -rules: -- apiGroups: - - advertisement.fluidos.eu - resources: - - discoveries - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - advertisement.fluidos.eu - resources: - - discoveries/finalizers - verbs: - - update -- apiGroups: - - advertisement.fluidos.eu - resources: - - discoveries/status - verbs: - - get - - patch - - update -- apiGroups: - - advertisement.fluidos.eu - resources: - - peeringcandidates - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - advertisement.fluidos.eu - resources: - - peeringcandidates/finalizers - verbs: - - update -- apiGroups: - - advertisement.fluidos.eu - resources: - - peeringcandidates/status - verbs: - - get - - patch - - update -- apiGroups: - - "" - resources: - - configmaps - verbs: - - get - - list - - watch -- apiGroups: - - "" - resources: - - secrets - verbs: - - get - - list - - watch -- apiGroups: - - nodecore.fluidos.eu - resources: - - flavours - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - nodecore.fluidos.eu - resources: - - flavours/finalizers - verbs: - - update -- apiGroups: - - nodecore.fluidos.eu - resources: - - flavours/status - verbs: - - get - - patch - - update -- apiGroups: - - reservation.fluidos.eu - resources: - - contracts - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - reservation.fluidos.eu - resources: - - contracts/finalizers - verbs: - - update -- apiGroups: - - reservation.fluidos.eu - resources: - - contracts/status - verbs: - - get - - patch - - update -- apiGroups: - - reservation.fluidos.eu - resources: - - reservations - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - reservation.fluidos.eu - resources: - - reservations/finalizers - verbs: - - update -- apiGroups: - - reservation.fluidos.eu - resources: - - reservations/status - verbs: - - get - - patch - - update -- apiGroups: - - reservation.fluidos.eu - resources: - - transactions - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - reservation.fluidos.eu - resources: - - transactions/finalizers - verbs: - - update -- apiGroups: - - reservation.fluidos.eu - resources: - - transactions/status - verbs: - - get - - patch - - update diff --git a/deployments/node/files/fluidos-rear-manager-ClusterRole.yaml b/deployments/node/files/fluidos-rear-manager-ClusterRole.yaml deleted file mode 100644 index ec852e9..0000000 --- a/deployments/node/files/fluidos-rear-manager-ClusterRole.yaml +++ /dev/null @@ -1,191 +0,0 @@ -rules: -- apiGroups: - - advertisement.fluidos.eu - resources: - - discoveries - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - advertisement.fluidos.eu - resources: - - discoveries/finalizers - verbs: - - update -- apiGroups: - - advertisement.fluidos.eu - resources: - - discoveries/status - verbs: - - get - - patch - - update -- apiGroups: - - advertisement.fluidos.eu - resources: - - peeringcandidates - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - advertisement.fluidos.eu - resources: - - peeringcandidates/finalizers - verbs: - - update -- apiGroups: - - advertisement.fluidos.eu - resources: - - peeringcandidates/status - verbs: - - get - - patch - - update -- apiGroups: - - "" - resources: - - configmaps - verbs: - - get - - list - - watch -- apiGroups: - - nodecore.fluidos.eu - resources: - - allocations - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - nodecore.fluidos.eu - resources: - - allocations/finalizers - verbs: - - update -- apiGroups: - - nodecore.fluidos.eu - resources: - - allocations/status - verbs: - - get - - patch - - update -- apiGroups: - - nodecore.fluidos.eu - resources: - - flavours - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - nodecore.fluidos.eu - resources: - - flavours/finalizers - verbs: - - update -- apiGroups: - - nodecore.fluidos.eu - resources: - - flavours/status - verbs: - - get - - patch - - update -- apiGroups: - - nodecore.fluidos.eu - resources: - - solvers - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - nodecore.fluidos.eu - resources: - - solvers/finalizers - verbs: - - update -- apiGroups: - - nodecore.fluidos.eu - resources: - - solvers/status - verbs: - - get - - patch - - update -- apiGroups: - - reservation.fluidos.eu - resources: - - contracts - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - reservation.fluidos.eu - resources: - - contracts/finalizers - verbs: - - update -- apiGroups: - - reservation.fluidos.eu - resources: - - contracts/status - verbs: - - get - - patch - - update -- apiGroups: - - reservation.fluidos.eu - resources: - - reservations - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - reservation.fluidos.eu - resources: - - reservations/finalizers - verbs: - - update -- apiGroups: - - reservation.fluidos.eu - resources: - - reservations/status - verbs: - - get - - patch - - update diff --git a/deployments/node/fluidos-0.1.0.tgz b/deployments/node/fluidos-0.1.0.tgz deleted file mode 100644 index de8e744..0000000 Binary files a/deployments/node/fluidos-0.1.0.tgz and /dev/null differ diff --git a/deployments/node/index.yaml b/deployments/node/index.yaml deleted file mode 100644 index 02eabb3..0000000 --- a/deployments/node/index.yaml +++ /dev/null @@ -1,14 +0,0 @@ -apiVersion: v1 -entries: - node: - - apiVersion: v2 - appVersion: 0.0.1 - created: "2023-10-17T17:14:59.809373+02:00" - description: A Helm chart for Fluidos Node - digest: 8b51c13b01d65407087391bfada5f579cd2e9a1f668d4a0ce1c1178fe3bf4859 - name: node - type: application - urls: - - https://github.com/fluidos-project/node/deployments/node/node-0.0.1.tgz - version: 0.0.1 -generated: "2023-10-17T17:14:59.808177+02:00" diff --git a/deployments/node/node-0.0.1.tgz b/deployments/node/node-0.0.1.tgz deleted file mode 100644 index 27480dd..0000000 Binary files a/deployments/node/node-0.0.1.tgz and /dev/null differ diff --git a/deployments/node/robots.tx b/deployments/node/robots.tx deleted file mode 100644 index c6742d8..0000000 --- a/deployments/node/robots.tx +++ /dev/null @@ -1,2 +0,0 @@ -User-Agent: * -Disallow: / diff --git a/deployments/node/samples/nodecore_v1alpha1_solver.yaml b/deployments/node/samples/nodecore_v1alpha1_solver.yaml deleted file mode 100644 index e8e5db1..0000000 --- a/deployments/node/samples/nodecore_v1alpha1_solver.yaml +++ /dev/null @@ -1,16 +0,0 @@ -apiVersion: nodecore.fluidos.eu/v1alpha1 -kind: Solver -metadata: - name: solver-sample - namespace: fluidos -spec: - selector: - type: k8s-fluidos - architecture: arm64 - rangeSelector: - minCpu: 1 - minMemory: 1 - intentID: "intent-sample" - findCandidate: true - reserveAndBuy: true - enstablishPeering: false \ No newline at end of file diff --git a/deployments/node/templates/_helpers.tpl b/deployments/node/templates/_helpers.tpl deleted file mode 100644 index 97c9e84..0000000 --- a/deployments/node/templates/_helpers.tpl +++ /dev/null @@ -1,126 +0,0 @@ -{{/* -Expand the name of the chart. -*/}} -{{- define "fluidos.name" -}} -{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} -{{- end }} - -{{/* -Create a default fully qualified app name. -We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). -If release name contains chart name it will be used as a full name. -*/}} -{{- define "fluidos.fullname" -}} -{{- if .Values.fullnameOverride }} -{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} -{{- else }} -{{- $name := default .Chart.Name .Values.nameOverride }} -{{- if contains $name .Release.Name }} -{{- .Release.Name | trunc 63 | trimSuffix "-" }} -{{- else }} -{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} -{{- end }} -{{- end }} -{{- end }} - -{{/* -Create version used to select the Fluidos node version to be installed . -*/}} -{{- define "fluidos.version" -}} -{{- if .Values.tag }} -{{- .Values.tag }} -{{- else if .Chart.AppVersion }} -{{- .Chart.AppVersion }} -{{- else }} -{{- fail "At least one between .Values.tag and .Chart.AppVersion should be set" }} -{{- end }} -{{- end }} - -{{/* -The suffix added to the Fluidos images, to identify CI builds. -*/}} -{{- define "fluidos.suffix" -}} -{{/* https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string */}} -{{- $semverregex := "^v(?P0|[1-9]\\d*)\\.(?P0|[1-9]\\d*)\\.(?P0|[1-9]\\d*)(?:-(?P(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+(?P[0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$" }} -{{- if or (eq .Values.tag "") (mustRegexMatch $semverregex .Values.tag) }} -{{- print "" }} -{{- else }} -{{- print "-ci" }} -{{- end }} -{{- end }} - -{{/* -Create a name prefixed with the chart name, it accepts a dict which contains the field "name". -*/}} -{{- define "fluidos.prefixedName" -}} -{{- printf "%s-%s" (include "fluidos.name" .) .name }} -{{- end }} - -{{/* -Create the file name of a role starting from a prefix, it accepts a dict which contains the field "prefix". -*/}} -{{- define "fluidos.role-filename" -}} -{{- printf "files/%s-%s" .prefix "Role.yaml" }} -{{- end }} - -{{/* -Create the file name of a cluster role starting from a prefix, it accepts a dict which contains the field "prefix". -*/}} -{{- define "fluidos.cluster-role-filename" -}} -{{- printf "files/%s-%s" .prefix "ClusterRole.yaml" }} -{{- end }} - -{{/* -Create chart name and version as used by the chart label. -*/}} -{{- define "fluidos.chart" -}} -{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} -{{- end }} - -{{/* -Common labels -*/}} -{{- define "fluidos.labels" -}} -{{ include "fluidos.selectorLabels" . }} -helm.sh/chart: {{ include "fluidos.chart" . }} -app.kubernetes.io/version: {{ quote (include "fluidos.version" .) }} -app.kubernetes.io/managed-by: {{ quote .Release.Service }} -{{- end }} - -{{/* -Selector labels, it accepts a dict which contains fields "name" and "module" -*/}} -{{- define "fluidos.selectorLabels" -}} -app.kubernetes.io/name: {{ quote .name }} -app.kubernetes.io/instance: {{ quote (printf "%s-%s" .Release.Name .name) }} -app.kubernetes.io/component: {{ quote .module }} -app.kubernetes.io/part-of: {{ quote (include "fluidos.name" .) }} -{{- end }} - -{{/* -Create the name of the service account to use -*/}} -{{- define "fluidos.serviceAccountName" -}} -{{- if .Values.serviceAccount.create }} -{{- default (include "fluidos.fullname" .) .Values.serviceAccount.name }} -{{- else }} -{{- default "default" .Values.serviceAccount.name }} -{{- end }} -{{- end }} - -{{/* -Get the Pod security context -*/}} -{{- define "fluidos.podSecurityContext" -}} -runAsNonRoot: true -runAsUser: 1000 -runAsGroup: 1000 -fsGroup: 1000 -{{- end -}} - -{{/* -Get the Container security context -*/}} -{{- define "fluidos.containerSecurityContext" -}} -allowPrivilegeEscalation: false -{{- end -}} \ No newline at end of file diff --git a/deployments/node/templates/fluidos-local-resource-manager-deployment.yaml b/deployments/node/templates/fluidos-local-resource-manager-deployment.yaml deleted file mode 100644 index 0ec7af8..0000000 --- a/deployments/node/templates/fluidos-local-resource-manager-deployment.yaml +++ /dev/null @@ -1,76 +0,0 @@ -{{- $resManagerConfig := (merge (dict "name" "local-resource-manager" "module" "local-resource-manager") .) -}} - -apiVersion: apps/v1 -kind: Deployment -metadata: - labels: - {{- include "fluidos.labels" $resManagerConfig | nindent 4 }} - name: {{ include "fluidos.prefixedName" $resManagerConfig }} - namespace: {{ .Release.Namespace }} -spec: - replicas: {{ .Values.localResourceManager.replicas }} - selector: - matchLabels: - {{- include "fluidos.labels" $resManagerConfig | nindent 6 }} - template: - metadata: - {{ if .Values.localResourceManager.pod.annotations }} - annotations: - {{- toYaml .Values.localResourceManager.pod.annotations | nindent 8 }} - {{ end }} - labels: - {{- include "fluidos.labels" $resManagerConfig | nindent 8 }} - {{ if .Values.localResourceManager.pod.labels }} - {{ toYaml .Values.localResourceManager.pod.labels | nindent 8 }} - {{ end }} - spec: - {{- if gt .Values.localResourceManager.replicas 1.0 }} - affinity: - podAntiAffinity: - preferredDuringSchedulingIgnoredDuringExecution: - - weight: 100 - podAffinityTerm: - labelSelector: - matchLabels: - {{- include "fluidos.labels" $resManagerConfig | nindent 18 }} - topologyKey: kubernetes.io/hostname - {{- end }} - securityContext: - {{- include "fluidos.podSecurityContext" $resManagerConfig | nindent 8 }} - serviceAccountName: {{ include "fluidos.prefixedName" $resManagerConfig }} - containers: - - image: {{ .Values.localResourceManager.imageName }}:{{ include "fluidos.version" $resManagerConfig }} - imagePullPolicy: {{ .Values.pullPolicy }} - securityContext: - {{- include "fluidos.containerSecurityContext" $resManagerConfig | nindent 10 }} - name: {{ $resManagerConfig.name }} - command: ["/usr/bin/local-resource-manager"] - args: - - --node-resource-label={{ .Values.localResourceManager.config.nodeResourceLabel }} - - --resources-types={{ .Values.localResourceManager.config.resourceType }} - - --cpu-min={{ .Values.localResourceManager.config.flavour.cpuMin }} - - --memory-min={{ .Values.localResourceManager.config.flavour.memoryMin }} - - --cpu-step={{ .Values.localResourceManager.config.flavour.cpuStep }} - - --memory-step={{ .Values.localResourceManager.config.flavour.memoryStep }} - resources: {{- toYaml .Values.localResourceManager.pod.resources | nindent 10 }} - ports: - - name: healthz - containerPort: 8081 - protocol: TCP - readinessProbe: - httpGet: - path: /readyz - port: healthz - {{- if ((.Values.common).nodeSelector) }} - nodeSelector: - {{- toYaml .Values.common.nodeSelector | nindent 8 }} - {{- end }} - {{- if ((.Values.common).tolerations) }} - tolerations: - {{- toYaml .Values.common.tolerations | nindent 8 }} - {{- end }} - {{- if ((.Values.common).affinity) }} - affinity: - {{- toYaml .Values.common.affinity | nindent 8 }} - {{- end }} - diff --git a/deployments/node/templates/fluidos-local-resource-manager-rbac.yaml b/deployments/node/templates/fluidos-local-resource-manager-rbac.yaml deleted file mode 100644 index b991b4a..0000000 --- a/deployments/node/templates/fluidos-local-resource-manager-rbac.yaml +++ /dev/null @@ -1,32 +0,0 @@ -{{- $resManagerConfig := (merge (dict "name" "local-resource-manager" "module" "local-resource-manager") .) -}} - -apiVersion: v1 -kind: ServiceAccount -metadata: - name: {{ include "fluidos.prefixedName" $resManagerConfig }} - labels: - {{- include "fluidos.labels" $resManagerConfig | nindent 4 }} ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRoleBinding -metadata: - name: {{ include "fluidos.prefixedName" $resManagerConfig }} - labels: - {{- include "fluidos.labels" $resManagerConfig | nindent 4 }} -subjects: - - kind: ServiceAccount - name: {{ include "fluidos.prefixedName" $resManagerConfig }} - namespace: {{ .Release.Namespace }} -roleRef: - apiGroup: rbac.authorization.k8s.io - kind: ClusterRole - name: {{ include "fluidos.prefixedName" $resManagerConfig }} ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - name: {{ include "fluidos.prefixedName" $resManagerConfig }} - labels: - {{- include "fluidos.labels" $resManagerConfig | nindent 4 }} -{{ .Files.Get (include "fluidos.cluster-role-filename" (dict "prefix" ( include "fluidos.prefixedName" $resManagerConfig )))}} - diff --git a/deployments/node/templates/fluidos-network-manager-configmap.yaml b/deployments/node/templates/fluidos-network-manager-configmap.yaml deleted file mode 100644 index 7d50b79..0000000 --- a/deployments/node/templates/fluidos-network-manager-configmap.yaml +++ /dev/null @@ -1,51 +0,0 @@ -{{- $networkManagerConfig := (merge (dict "name" "network-manager" "module" "network-manager") .) -}} - -apiVersion: v1 -kind: ConfigMap -metadata: - {{- if .Values.networkManager.pod.annotations }} - annotations: - {{- toYaml .Values.networkManager.pod.annotations | nindent 4 }} - {{- end}} - labels: - {{- include "fluidos.labels" $networkManagerConfig | nindent 4 }} - name: {{ .Values.networkManager.configMaps.providers.name }} - namespace: {{ .Release.Namespace }} -data: - {{ if .Values.networkManager.configMaps.providers.local }} - local: {{ .Values.networkManager.configMaps.providers.local }} - {{- end }} - {{ if .Values.networkManager.configMaps.providers.remote }} - remote: {{ .Values.networkManager.configMaps.providers.remote }} - {{- end }} - {{ if .Values.networkManager.configMaps.providers.default }} - default: {{ .Values.networkManager.configMaps.providers.default }} - {{- end }} ---- -apiVersion: v1 -kind: ConfigMap -metadata: - {{- if .Values.networkManager.pod.annotations }} - annotations: - {{- toYaml .Values.networkManager.pod.annotations | nindent 4 }} - {{- end}} - labels: - {{- include "fluidos.labels" $networkManagerConfig | nindent 4 }} - name: {{ .Values.networkManager.configMaps.nodeIdentity.name }} - namespace: {{ .Release.Namespace }} -data: - {{ if .Values.networkManager.configMaps.nodeIdentity.domain }} - domain: {{ .Values.networkManager.configMaps.nodeIdentity.domain }} - {{- else }} - {{- fail "The FLUIDOS Node domain (.Values.networkManager.configMaps.nodeIdentity.domain) must be set." }} - {{- end }} - {{- if .Values.networkManager.configMaps.nodeIdentity.ip }} - ip: {{ .Values.networkManager.configMaps.nodeIdentity.ip }} - {{- end }} - {{- if .Values.networkManager.configMaps.nodeIdentity.nodeID }} - nodeID: {{ .Values.networkManager.configMaps.nodeIdentity.nodeID }} - {{- else }} - nodeID: {{ randAlphaNum 10 | lower }} - {{- end }} - - diff --git a/deployments/node/templates/fluidos-rear-controller-deployment.yaml b/deployments/node/templates/fluidos-rear-controller-deployment.yaml deleted file mode 100644 index ce5e931..0000000 --- a/deployments/node/templates/fluidos-rear-controller-deployment.yaml +++ /dev/null @@ -1,78 +0,0 @@ -{{- $rearControllerConfig := (merge (dict "name" "rear-controller" "module" "rear-controller") .) -}} - -apiVersion: apps/v1 -kind: Deployment -metadata: - labels: - {{- include "fluidos.labels" $rearControllerConfig | nindent 4 }} - name: {{ include "fluidos.prefixedName" $rearControllerConfig }} - namespace: {{ .Release.Namespace }} -spec: - replicas: {{ .Values.rearController.replicas }} - selector: - matchLabels: - {{- include "fluidos.labels" $rearControllerConfig | nindent 6 }} - template: - metadata: - {{ if .Values.rearController.pod.annotations }} - annotations: - {{- toYaml .Values.rearController.pod.annotations | nindent 8 }} - {{ end }} - labels: - {{- include "fluidos.labels" $rearControllerConfig | nindent 8 }} - {{ if .Values.rearController.pod.labels }} - {{ toYaml .Values.rearController.pod.labels | nindent 8 }} - {{ end }} - spec: - {{- if gt .Values.rearController.replicas 1.0 }} - affinity: - podAntiAffinity: - preferredDuringSchedulingIgnoredDuringExecution: - - weight: 100 - podAffinityTerm: - labelSelector: - matchLabels: - {{- include "fluidos.labels" $rearControllerConfig | nindent 18 }} - topologyKey: kubernetes.io/hostname - {{- end }} - securityContext: - {{- include "fluidos.podSecurityContext" $rearControllerConfig | nindent 8 }} - serviceAccountName: {{ include "fluidos.prefixedName" $rearControllerConfig }} - containers: - - image: {{ .Values.rearController.imageName }}:{{ include "fluidos.version" $rearControllerConfig }} - imagePullPolicy: {{ .Values.pullPolicy }} - securityContext: - {{- include "fluidos.containerSecurityContext" $rearControllerConfig | nindent 10 }} - name: {{ $rearControllerConfig.name }} - command: ["/usr/bin/rear-controller"] - args: - - --grpc-port={{ .Values.rearController.service.grpc.port }} - - --http-port={{ .Values.rearController.service.gateway.port }} - resources: {{- toYaml .Values.rearController.pod.resources | nindent 10 }} - ports: - - name: healthz - containerPort: 8081 - protocol: TCP - - name: {{ .Values.rearController.service.gateway.name }} - containerPort: {{ .Values.rearController.service.gateway.port }} - protocol: TCP - - name: {{ .Values.rearController.service.grpc.name }} - containerPort: {{ .Values.rearController.service.grpc.port }} - protocol: TCP - readinessProbe: - httpGet: - path: /readyz - port: healthz - {{- if (.Values.common).nodeSelector }} - nodeSelector: - {{- toYaml .Values.common.nodeSelector | nindent 8 }} - {{- end }} - {{- if ((.Values.common).tolerations) }} - tolerations: - {{- toYaml .Values.common.tolerations | nindent 8 }} - {{- end }} - {{- if ((.Values.common).affinity) }} - affinity: - {{- toYaml .Values.common.affinity | nindent 8 }} - {{- end }} - diff --git a/deployments/node/templates/fluidos-rear-controller-rbac.yaml b/deployments/node/templates/fluidos-rear-controller-rbac.yaml deleted file mode 100644 index 2a70980..0000000 --- a/deployments/node/templates/fluidos-rear-controller-rbac.yaml +++ /dev/null @@ -1,32 +0,0 @@ -{{- $rearControllerConfig := (merge (dict "name" "rear-controller" "module" "rear-controller") .) -}} - -apiVersion: v1 -kind: ServiceAccount -metadata: - name: {{ include "fluidos.prefixedName" $rearControllerConfig }} - labels: - {{- include "fluidos.labels" $rearControllerConfig | nindent 4 }} ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRoleBinding -metadata: - name: {{ include "fluidos.prefixedName" $rearControllerConfig }} - labels: - {{- include "fluidos.labels" $rearControllerConfig | nindent 4 }} -subjects: - - kind: ServiceAccount - name: {{ include "fluidos.prefixedName" $rearControllerConfig }} - namespace: {{ .Release.Namespace }} -roleRef: - apiGroup: rbac.authorization.k8s.io - kind: ClusterRole - name: {{ include "fluidos.prefixedName" $rearControllerConfig }} ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - name: {{ include "fluidos.prefixedName" $rearControllerConfig }} - labels: - {{- include "fluidos.labels" $rearControllerConfig | nindent 4 }} -{{ .Files.Get (include "fluidos.cluster-role-filename" (dict "prefix" ( include "fluidos.prefixedName" $rearControllerConfig )))}} - diff --git a/deployments/node/templates/fluidos-rear-controller-service.yaml b/deployments/node/templates/fluidos-rear-controller-service.yaml deleted file mode 100644 index f1c5e33..0000000 --- a/deployments/node/templates/fluidos-rear-controller-service.yaml +++ /dev/null @@ -1,53 +0,0 @@ -{{- $rearControllerConfig := (merge (dict "name" "rear-controller" "module" "rear-controller") .) -}} - -apiVersion: v1 -kind: Service -metadata: - name: {{ include "fluidos.prefixedName" $rearControllerConfig }}-grpc - annotations: - {{- if .Values.rearController.service.grpc.annotations }} - {{- toYaml .Values.rearController.service.grpc.annotations | nindent 4 }} - {{- end}} - labels: - {{- include "fluidos.labels" $rearControllerConfig | nindent 4 }} - {{- if .Values.rearController.service.grpc.labels }} - {{- toYaml .Values.rearController.service.grpc.labels | nindent 4 }} - {{- end}} -spec: - selector: - {{- include "fluidos.selectorLabels" $rearControllerConfig | nindent 4 }} - type: {{ .Values.rearController.service.grpc.type }} - ports: - - name: {{ .Values.rearController.service.grpc.name }} - port: {{ .Values.rearController.service.grpc.port }} - targetPort: {{ .Values.rearController.service.grpc.targetPort }} - protocol: TCP ---- -apiVersion: v1 -kind: Service -metadata: - name: {{ include "fluidos.prefixedName" $rearControllerConfig }}-gateway - annotations: - {{- if .Values.rearController.service.gateway.annotations }} - {{- toYaml .Values.rearController.service.gateway.annotations | nindent 4 }} - {{- end}} - labels: - {{- include "fluidos.labels" $rearControllerConfig | nindent 4 }} - {{- if .Values.rearController.service.gateway.labels }} - {{- toYaml .Values.rearController.service.gateway.labels | nindent 4 }} - {{- end}} -spec: - selector: - {{- include "fluidos.selectorLabels" $rearControllerConfig | nindent 4 }} - type: {{ .Values.rearController.service.gateway.type }} - {{- if and (eq .Values.rearController.service.gateway.type "LoadBalancer") (.Values.rearController.service.gateway.loadBalancer.ip) }} - loadBalancerIP: {{ .Values.rearController.service.gateway.loadBalancer.ip }} - {{- end }} - ports: - - name: {{ .Values.rearController.service.gateway.name }} - {{- if and (eq .Values.rearController.service.gateway.type "NodePort") ( .Values.rearController.service.gateway.nodePort.port ) }} - nodePort: {{ .Values.rearController.service.gateway.nodePort.port }} - {{- end }} - port: {{ .Values.rearController.service.gateway.port }} - targetPort: {{ .Values.rearController.service.gateway.targetPort }} - protocol: TCP diff --git a/deployments/node/templates/fluidos-rear-manager-deployment.yaml b/deployments/node/templates/fluidos-rear-manager-deployment.yaml deleted file mode 100644 index 6e33edf..0000000 --- a/deployments/node/templates/fluidos-rear-manager-deployment.yaml +++ /dev/null @@ -1,70 +0,0 @@ -{{- $rearManagerConfig := (merge (dict "name" "rear-manager" "module" "rear-manager") .) -}} - -apiVersion: apps/v1 -kind: Deployment -metadata: - labels: - {{- include "fluidos.labels" $rearManagerConfig | nindent 4 }} - name: {{ include "fluidos.prefixedName" $rearManagerConfig }} - namespace: {{ .Release.Namespace }} -spec: - replicas: {{ .Values.rearManager.replicas }} - selector: - matchLabels: - {{- include "fluidos.labels" $rearManagerConfig | nindent 6 }} - template: - metadata: - {{ if .Values.rearManager.pod.annotations }} - annotations: - {{- toYaml .Values.rearManager.pod.annotations | nindent 8 }} - {{ end }} - labels: - {{- include "fluidos.labels" $rearManagerConfig | nindent 8 }} - {{ if .Values.rearManager.pod.labels }} - {{ toYaml .Values.rearManager.pod.labels | nindent 8 }} - {{ end }} - spec: - {{- if gt .Values.rearManager.replicas 1.0 }} - affinity: - podAntiAffinity: - preferredDuringSchedulingIgnoredDuringExecution: - - weight: 100 - podAffinityTerm: - labelSelector: - matchLabels: - {{- include "fluidos.labels" $rearManagerConfig | nindent 18 }} - topologyKey: kubernetes.io/hostname - {{- end }} - securityContext: - {{- include "fluidos.podSecurityContext" $rearManagerConfig | nindent 8 }} - serviceAccountName: {{ include "fluidos.prefixedName" $rearManagerConfig }} - containers: - - image: {{ .Values.rearManager.imageName }}:{{ include "fluidos.version" $rearManagerConfig }} - imagePullPolicy: {{ .Values.pullPolicy }} - securityContext: - {{- include "fluidos.containerSecurityContext" $rearManagerConfig | nindent 10 }} - name: {{ $rearManagerConfig.name }} - command: ["/usr/bin/rear-manager"] - args: - resources: {{- toYaml .Values.rearManager.pod.resources | nindent 10 }} - ports: - - name: healthz - containerPort: 8081 - protocol: TCP - readinessProbe: - httpGet: - path: /readyz - port: healthz - {{- if ((.Values.common).nodeSelector) }} - nodeSelector: - {{- toYaml .Values.common.nodeSelector | nindent 8 }} - {{- end }} - {{- if ((.Values.common).tolerations) }} - tolerations: - {{- toYaml .Values.common.tolerations | nindent 8 }} - {{- end }} - {{- if ((.Values.common).affinity) }} - affinity: - {{- toYaml .Values.common.affinity | nindent 8 }} - {{- end }} - diff --git a/deployments/node/templates/fluidos-rear-manager-rbac.yaml b/deployments/node/templates/fluidos-rear-manager-rbac.yaml deleted file mode 100644 index 2c3e611..0000000 --- a/deployments/node/templates/fluidos-rear-manager-rbac.yaml +++ /dev/null @@ -1,32 +0,0 @@ -{{- $rearManagerConfig := (merge (dict "name" "rear-manager" "module" "rear-manager") .) -}} - -apiVersion: v1 -kind: ServiceAccount -metadata: - name: {{ include "fluidos.prefixedName" $rearManagerConfig }} - labels: - {{- include "fluidos.labels" $rearManagerConfig | nindent 4 }} ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRoleBinding -metadata: - name: {{ include "fluidos.prefixedName" $rearManagerConfig }} - labels: - {{- include "fluidos.labels" $rearManagerConfig | nindent 4 }} -subjects: - - kind: ServiceAccount - name: {{ include "fluidos.prefixedName" $rearManagerConfig }} - namespace: {{ .Release.Namespace }} -roleRef: - apiGroup: rbac.authorization.k8s.io - kind: ClusterRole - name: {{ include "fluidos.prefixedName" $rearManagerConfig }} ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - name: {{ include "fluidos.prefixedName" $rearManagerConfig }} - labels: - {{- include "fluidos.labels" $rearManagerConfig | nindent 4 }} -{{ .Files.Get (include "fluidos.cluster-role-filename" (dict "prefix" ( include "fluidos.prefixedName" $rearManagerConfig )))}} - diff --git a/deployments/node/values.yaml b/deployments/node/values.yaml deleted file mode 100644 index ba92994..0000000 --- a/deployments/node/values.yaml +++ /dev/null @@ -1,149 +0,0 @@ -# Default values for fluidos-node. -# This is a YAML-formatted file. -# Declare variables to be passed into your templates. - -# -- Images' tag to select a development version of fluidos-node instead of a release -tag: "" -# -- The pullPolicy for fluidos-node pods. -pullPolicy: "IfNotPresent" - -common: - # -- NodeSelector for all fluidos-node pods - nodeSelector: {} - # -- Tolerations for all fluidos-node pods - tolerations: [] - # -- Affinity for all fluidos-node pods - affinity: {} - # -- Extra arguments for all fluidos-node pods - extraArgs: [] - -localResourceManager: - # -- The number of REAR Controller, which can be increased for active/passive high availability. - replicas: 1 - pod: - # -- Annotations for the local-resource-manager pod. - annotations: {} - # -- Labels for the local-resource-manager pod. - labels: {} - # -- Extra arguments for the local-resource-manager pod. - extraArgs: [] - # -- Resource requests and limits (https://kubernetes.io/docs/user-guide/compute-resources/) for the local-resource-manager pod. - resources: - limits: {} - requests: {} - imageName: "ghcr.io/fluidos-project/local-resource-manager" - config: - # -- Label used to identify the nodes from which resources are collected. - nodeResourceLabel: "node-role.fluidos.eu/resources" - # -- This flag defines the resource type of the generated flavours. - resourceType: "k8s-fluidos" - flavour: - # -- The minimum number of CPUs that can be requested to purchase a flavour. - cpuMin: "0" - # -- The minimum amount of memory that can be requested to purchase a flavour. - memoryMin: "0" - # -- The CPU step that must be respected when requesting a flavour through a Flavour Selector. - cpuStep: "1000m" - # -- The memory step that must be respected when requesting a flavour through a Flavour Selector. - memoryStep: "100Mi" - -rearManager: - # -- The number of REAR Manager, which can be increased for active/passive high availability. - replicas: 1 - pod: - # -- Annotations for the rear-manager pod. - annotations: {} - # -- Labels for the rear-manager pod. - labels: {} - # -- Extra arguments for the rear-manager pod. - extraArgs: [] - # -- Resource requests and limits (https://kubernetes.io/docs/user-guide/compute-resources/) for the rear-manager pod. - resources: - limits: {} - requests: {} - imageName: "ghcr.io/fluidos-project/rear-manager" - -rearController: - # -- The number of REAR Controller, which can be increased for active/passive high availability. - replicas: 1 - pod: - # -- Annotations for the rear-controller pod. - annotations: {} - # -- Labels for the rear-controller pod. - labels: {} - # -- Extra arguments for the rear-controller pod. - extraArgs: [] - # -- Resource requests and limits (https://kubernetes.io/docs/user-guide/compute-resources/) for the rear-controller pod. - resources: - limits: {} - requests: {} - imageName: "ghcr.io/fluidos-project/rear-controller" - service: - grpc: - name: "grpc" - # -- Kubernetes service used to expose the gRPC Server to liqo. - type: "ClusterIP" - # -- Annotations for the gRPC service. - annotations: {} - # -- Labels for the gRPC service. - labels: {} - # -- The gRPC port used by Liqo to connect with the Gateway of the rear-controller to obtain the Contract resources for a given consumer ClusterID. - port: 2710 - # -- The target port used by the gRPC service. - targetPort: 2710 - gateway: - name: "gateway" - # -- Kubernetes service to be used to expose the REAR gateway. - type: "NodePort" - # -- Annotations for the REAR gateway service. - annotations: {} - # -- Labels for the REAR gateway service. - labels: {} - # -- Options valid if service type is NodePort. - nodePort: - # -- Force the port used by the NodePort service. - port: "" - # -- Options valid if service type is LoadBalancer. - loadBalancer: - # -- Override the IP here if service type is LoadBalancer and you want to use a specific IP address, e.g., because you want a static LB. - ip: "" - # -- The port used by the rear-controller to expose the REAR Gateway. - port: 3004 - # -- The target port used by the REAR Gateway service. - targetPort: 3004 - -networkManager: - # -- The number of Network Manager, which can be increased for active/passive high availability. - replicas: 1 - pod: - # -- Annotations for the network-manager pod. - annotations: {} - # -- Labels for the network-manager pod. - labels: {} - # -- Extra arguments for the network-manager pod. - extraArgs: [] - # -- Resource requests and limits (https://kubernetes.io/docs/user-guide/compute-resources/) for the network-manager pod. - resources: - limits: {} - requests: {} - # -- The resource image to be used by the network-manager pod. - imageName: "ghcr.io/fluidos-project/network-manager" - configMaps: - providers: - # -- The name of the ConfigMap containing the list of the FLUIDOS Providers and the default FLUIDOS Provider (SuperNode or Catalogue). - name: "fluidos-network-manager-config" - # -- The IP List of Local knwon FLUIDOS Nodes separated by commas. - local: "" - # -- The IP List of Remote known FLUIDOS Nodes separated by commas. - remote: - # -- The IP List of SuperNodes separated by commas. - default: - nodeIdentity: - # -- The name of the ConfigMap containing the FLUIDOS Node identity info. - name: "fluidos-network-manager-identity" - # -- The domain name of the FLUIDOS closed domani: It represents for instance the Enterprise and it is used to generate the FQDN of the owned FLUIDOS Nodes - domain: "" - # -- The IP address of the FLUIDOS Node. It can be public or private, depending on the network configuration and it corresponds to the IP address to reach the Network Manager from the outside of the cluster. - ip: - # -- The NodeID is a UUID that identifies the FLUIDOS Node. It is used to generate the FQDN of the owned FLUIDOS Nodes and it is unique in the FLUIDOS closed domain - nodeID: diff --git a/docs/images/FLUIDOSNodeImplementation.svg b/docs/images/FLUIDOSNodeImplementation.svg deleted file mode 100644 index 2296b8d..0000000 --- a/docs/images/FLUIDOSNodeImplementation.svg +++ /dev/null @@ -1,4 +0,0 @@ - - - -
FLUIDOS Node
FLUIDOS Node
Peering
Candidates
Peering...
Node
Orchestrator
Node...
Available
Resources
Available...
Resource
Importer / Exporter
Resource...
Local resource manager
Local resource manager
Ratings and
Metrics
Ratings and...
Service
Handler
Service...

Virtual Fabric Manager
Virtual Fabric Manag...
Local Resource Manager
Local Resource Manager
REAR Manager
REAR Manager
Solver Controller
Solver Controll...
Allocation Controller
Allocation Cont...
Discovery Manager
Discovery Manager
Contract Manager
Contract Manager
Discovery Controller
Discovery Contr...
Reservation Controller
Reservation Con...
Gateway
Gateway
REAR Manager
REAR Manager
REAR Controller
REAR Controller
Text is not SVG - cannot display
\ No newline at end of file diff --git a/docs/images/fluidoslogo.png b/docs/images/fluidoslogo.png deleted file mode 100644 index 90432ee..0000000 Binary files a/docs/images/fluidoslogo.png and /dev/null differ diff --git a/docs/implementation/components.md b/docs/implementation/components.md deleted file mode 100644 index f4e2de1..0000000 --- a/docs/implementation/components.md +++ /dev/null @@ -1,52 +0,0 @@ -## Components -Let's see how each component has been implemented: - -- [**Local ResourceManager**](#local-resourcemanager) -- [**Available Resources**](#available-resources) -- [**Discovery Manager**](#discovery-manager) -- [**Peering Candidates**](#peering-candidates) -- [**REAR Manager**](#rear-manager) -- [**Contract Manager**](#contract-manager) - -### Local ResourceManager -The **Local Resource Manager** was constructed through the development of a Kubernetes controller. This controller serves the purpose of monitoring the internal resources of individual nodes within a FLUIDOS Node, representing a cluster. Subsequently, it generates a *Flavour Custom Resource (CR)* for each node and stores these CRs within the cluster for further management and utilization. - -### Available Resources -**Available Resources** component is a critical part of the FLUIDOS system responsible for managing and storing Flavours. It consists of two primary data structures: - -1. **Free Flavours**: This section is dedicated to storing Flavours, as defined in the REAR component. - -2. **Reserved Flavours**: In this section, objects or documents representing various resource allocations are stored, with each represented as a Flavour. - -The primary function of Available Resources is to serve as a centralized repository for Flavours. When queried, it provides a list of these resources. Under the hood, Available Resources seamlessly integrates with Kubernetes' `etcd`, ensuring efficient storage and retrieval of data. - -This component plays a crucial role in facilitating resource management within the FLUIDOS ecosystem, enabling efficient allocation and utilization of computing resources. -### Discovery Manager -The **Discovery Manager** component within the FLUIDOS system serves as a critical part of the resource discovery process. It operates as a Kubernetes controller, continuously monitoring Discovery Custom Resources (CRs) generated by the Solver Controller. - -The primary objectives of the Discovery Manager are as follows: - -- **Populating Peering Candidates Table (Client)**: The Discovery Manager's primary responsibility is to populate the Peering Candidates table. It achieves this by identifying suitable resources known as "Flavours" based on the initial messages exchanged as part of the REAR protocol. - -- **Discovery (Client)**: it initiates a LIST_FLAVOURS message, broadcasting it to all known list of FLUIDOS Nodes. - -- **Offering Appropriate Flavours (Provider)**: In response to incoming requests, it will provide Flavours that best match the specific request. - -### Peering Candidates -The **Peering Candidates** component manages a dynamic list of nodes that are potentially suitable for establishing peering connections. This list is continuously updated by the Discovery Manager. - -Under the hood, Peering Candidates are stored through an appropriate Custom Resource. - -### REAR Manager -The **REAR Manager** plays a pivotal role in orchestrating the service provisioning process. It receives a solving request, translates them into resource or service requests, and looks up external suitable resources: - -- If no Peering Candidates are found, it initiates the **Discovery**. -- Optionally, if a suitable candidate is found, it triggers the **Reservation** phase. -- If this process is successfully fulfilled, resources are allocated, contracts are stored, and optionally can start the **Peering** phase. - -### Contract Manager -The Contract Manager is in charge of managing the reserve and purchase of resources. It handles the negotiation and management of resource contracts between nodes: - -- When a suitable peering candidate is identified and a Reservation is forged, the Contract Manager initiates the `Reserve` phase by sending a **RESERVE\_FLAVOUR** message. - -- Upon successful reservation of resources, it proceeds to the `Purchase` phase by sending a **PURCHASE\_FLAVOUR** message. Following this, it stores the contract received. \ No newline at end of file diff --git a/docs/implementation/controllers.md b/docs/implementation/controllers.md deleted file mode 100644 index dc1f25a..0000000 --- a/docs/implementation/controllers.md +++ /dev/null @@ -1,42 +0,0 @@ -## Controllers -In the following, the controllers developed for the FLUIDOS Node are described. To see the different objects, see [**Custom Resources**](./customresources.md#custom-resources) part. - -### Solver Controller (`solver_controller.go`) -The Solver controller, tasked with reconciliation on the `Solver` object, continuously monitors and manages its state to ensure alignment with the desired configuration. It follows the following steps: - -1. When there is a new Solver object, it firstly checks if the `Solver` has expired or failed (if so, it marks the Solver as `Timed Out`). -2. It checks if the Solver has to find a candidate. -3. If so, it starts to search a matching Peering Candidate if available. -4. If some Peering Candidates are available, it selects one and book it. -5. If no Peering Candidates are available, it starts the discovery process by creating a `Discovery`. -6. If the `findCandidate` status is solved, it means that a Peering Candidate has been found. Otherwise, it means that the `Solver` has failed. -7. If in the `Solver` there is also a `ReserveAndBuy` phase, it starts the reservation process. Otherwise, it ends the process, the solver is already solved. -8. Firstly, it starts to get the `PeeringCandidate` from the `Solver` object. Then, it forge the Partition starting from the `Solver` selector. At this point, it creates a `Reservation` object. -9. If the `Reservation` is successfully fulfilled, it means that the `Solver` has reserved and purchased the resources. Otherwise, it means that the `Solver` has failed. -10. If in the `Solver` there is also a `EnstablishPeering` phase, it starts the peering process (to be implemented). Otherwise, it ends the process. - -### Discovery Controller (`discovery_controller.go`) -The Discovery controller, tasked with reconciliation on the `Discovery` object, continuously monitors and manages its state to ensure alignment with the desired configuration. It follows the following steps: - -1. When there is a new Discovery object, it firstly starts the discovery process by contacting the `Gateway` to discover flavours that fits the `Discovery` selector. -2. If no flavours are found, it means that the `Discovery` has failed. Otherwise, it refers to the first `PeeringCandidate` as the one that will be reserved (more complex logic should be implemented), while the other will be stored as not reserved. -3. It update the `Discovery` object with the `PeeringCandidates` found. -4. The `Discovery` is solved, so it ends the process. - -### Reservation Controller (`reservation_controller.go`) -The Reservation controller, tasked with reconciliation on the `Reservation` object, continuously monitors and manages its state to ensure alignment with the desired configuration. It follows the following steps: - -1. When there is a new `Reservation` object it checks if the `Reserve` flag is set. If so, it starts the **Reserve** process. -2. It retrieves the FlavourID from the `PeeringCandidate` of the `Reservation` object. With this information, it starts the reservation process through the `Gateway`. -3. If the reserve phase of the reservation is successful, it will create a `Transaction` object from the response received. Otherwise, the `Reservation` has failed. -4. If the `Reservation` has the `Purchase` flag set, it starts the **Purchase** process. Otherwise, it ends the process because the `Reservation` has already succeeded. -5. Using the `Transaction` object from the `Reservation`, it starts the purchase process. -6. If the purchase phase is successfully fulfilled, it will update the status of the `Reservation` object and it will store the received `Contract`. Otherwise, the `Reservation` has failed. - - -### Allocation Controller (`allocation_controller.go`) -The Allocation controller, tasked with reconciliation on the `Allocation` object, continuously monitors and manages its state to ensure alignment with the desired configuration. - -(To be implemented) - - diff --git a/docs/implementation/customresources.md b/docs/implementation/customresources.md deleted file mode 100644 index 9d8874b..0000000 --- a/docs/implementation/customresources.md +++ /dev/null @@ -1,221 +0,0 @@ -## Custom Resources -The following custom resources have been developed for the FLUIDOS Node: - -- [**Discovery**](./customresources.md#discovery) -- [**Reservation**](./customresources.md#reservation) -- [**Allocation**](./customresources.md#allocation) -- [**Flavour**](./customresources.md#flavour) -- [**Contract**](./customresources.md#contract) -- [**PeeringCandidate**](./customresources.md#peeringcandidate) -- [**Solver**](./customresources.md#solver) -- [**Transaction**](./customresources.md#transaction) - -### Discovery -Here is a `Discovery` sample: - -```yaml -apiVersion: advertisement.fluidos.eu/v1alpha1 -kind: Discovery -metadata: - name: discovery-solver1 -spec: - selector: - type: k8s-fluidos - architecture: arm64 - rangeSelector: - minCpu: 1 - minMemory: 1 - solverID: solver1 - subscribe: true -``` - -### Reservation -Here is a `Reservation` sample: - -```yaml -apiVersion: reservation.fluidos.eu/v1alpha1 -kind: Reservation -metadata: - name: reservation-solver1 -spec: - buyer: - domain: topix.fluidos.eu - ip: 17.3.4.11 - nodeID: 95c0614o1d0 - flavourID: k8s-002 - peeringCandidate: - name: peeringcandidate-k8s-002 - namespace: default - purchase: true - reserve: true - seller: - domain: polito.fluidos.eu - ip: 13.3.5.1 - nodeID: 91cbd32s0q1 -``` - -### Allocation -To be implemented. - -### Flavour -Here is a `Flavour` sample: - -```yaml -apiVersion: nodecore.fluidos.eu/v1alpha1 -kind: Flavour -metadata: - name: k8s-fluidos-002 - namespace: default -spec: - characteristics: - architecture: amd64 - cpu: 4 - memory: 16 - optionalFields: - availability: true - owner: - domain: polito.fluidos.eu - ip: 13.3.5.1 - nodeID: 91cbd32s0q1 - policy: - aggregatable: - maxCount: 5 - minCount: 1 - price: - amount: "10" - currency: USD - period: hourly - providerID: 05a2a55a-9939-4e94-9587-barlo14 - type: k8s-fluidos -``` - -### Contract -Here is a `Contract` sample: - -```yaml -Name: contract-k8s-fluidos-002-4o5g -API Version: reservation.fluidos.eu/v1alpha1 -Kind: Contract -Spec: - Buyer: - domain: topix.fluidos.eu - ip: 17.3.4.11 - nodeID: 95c0614o1d0 - Credentials: - Cluster ID: - Cluster Name: - Endpoint: - Token: - Flavour: - Spec: - Characteristics: - Architecture: - Cpu: 4 - Ephemeral - Storage: 0 - Gpu: 0 - Memory: 16 - Persistent - Storage: 0 - Optional Fields: - Availability: true - Owner: - domain: polito.fluidos.eu - ip: 13.3.5.1 - nodeID: 91cbd32s0q1 - Policy: - Aggregatable: - Max Count: 5 - Min Count: 1 - Price: - Amount: 10 - Currency: USD - Period: hourly - Provider ID: 05a2a55a-9939-4e94-9587-barlo14 - Type: k8s-fluidos - Status: - Creation Time: 2023-09-29T10:22:13+02:00 - Expiration Time: 2023-11-29T10:22:13+02:00 - Last Update Time: 2023-09-29T11:26:37+02:00 - Partition: - Cpu: 0 - Ephemeral Storage: 0 - Gpu: 0 - Memory: 0 - Storage: 0 - Seller: - domain: polito.fluidos.eu - ip: 13.3.5.1 - nodeID: 91cbd32s0q1 -``` - -### PeeringCandidate -Here is a `PeeringCandidate` sample: - -```yaml -Name: peeringcandidate-k8s-fluidos-002 -API Version: advertisement.fluidos.eu/v1alpha1 -Kind: PeeringCandidate -Spec: - Flavour: - Spec: - Characteristics: - Architecture: - Cpu: 4 - Ephemeral - Storage: 0 - Gpu: 0 - Memory: 16 - Persistent - Storage: 0 - Optional Fields: - Availability: true - Owner: - domain: polito.fluidos.eu - ip: 13.3.5.1 - nodeID: 91cbd32s0q1 - Policy: - Aggregatable: - Max Count: 5 - Min Count: 1 - Price: - Amount: 10 - Currency: USD - Period: hourly - Provider ID: 05a2a55a-9939-4e94-9587-barlo14 - Type: k8s-fluidos-fluidos - Status: - Creation Time: 2023-09-29T10:22:13+02:00 - Expiration Time: 2023-11-29T10:22:13+02:00 - Last Update Time: 2023-09-29T11:26:38+02:00 - Reserved: true - Solver ID: solver1 -``` - -### Solver -Here is a `Solver` sample: - -```yaml -apiVersion: nodecore.fluidos.eu/v1alpha1 -kind: Solver -metadata: - name: solver1 -spec: - selector: - type: k8s-fluidos-fluidos - architecture: arm64 - rangeSelector: - minCpu: 1 - minMemory: 1 - solverID: solver1 - findCandidate: true - enstablishPeering: false -``` - -### Transaction -Here is a `Transaction` sample: - -```yaml -Name: 2738d980b9c4c45a172c7a4e18273492-1693646797264948000 -API Version: reservation.fluidos.eu/v1alpha1 -Kind: Transaction -Spec: - Flavour ID: k8s-fluidos-002 - Start Time: 2023-09-29T11:26:37+02:00 -``` \ No newline at end of file diff --git a/docs/implementation/implementation.md b/docs/implementation/implementation.md deleted file mode 100644 index b255077..0000000 --- a/docs/implementation/implementation.md +++ /dev/null @@ -1,18 +0,0 @@ -# Implementation -Regarding the implementation part, the components have been developed using **Kubernetes controllers** with Kubebuilder, making extensive use of the *Kubernetes API* and *Custom Resource Definitions (CRDs)*. - -Implementation is divided into three main parts: - -- **Local Resource Manager**, that contains the implementation of the Local Resource Manager component. -- **REAR Manager**, that contains the implementation of the REAR Manager component and the Solver & Allocation controllers. -- **REAR Controller**, that contains the implementation of the Discovery Manager, Gateway and Contract Manager components with the Discovery and Reservation controllers. - -

- -

- -See the different implementation for: - -- [**Components**](./components.md#components) -- [**Controllers**](./controllers.md#controllers) -- [**Custom Resources**](./customresources.md#custom-resources) \ No newline at end of file diff --git a/docs/installation/installation.md b/docs/installation/installation.md deleted file mode 100644 index 2fd9f95..0000000 --- a/docs/installation/installation.md +++ /dev/null @@ -1 +0,0 @@ -TBD \ No newline at end of file diff --git a/docs/quickstart/quickstart.md b/docs/quickstart/quickstart.md deleted file mode 100644 index 2fd9f95..0000000 --- a/docs/quickstart/quickstart.md +++ /dev/null @@ -1 +0,0 @@ -TBD \ No newline at end of file diff --git a/examples/kind/consumer/cluster-multi-worker.yaml b/examples/kind/consumer/cluster-multi-worker.yaml deleted file mode 100644 index 60fe086..0000000 --- a/examples/kind/consumer/cluster-multi-worker.yaml +++ /dev/null @@ -1,14 +0,0 @@ -kind: Cluster -apiVersion: kind.x-k8s.io/v1alpha4 -nodes: - - role: control-plane - image: kindest/node:v1.25.0 - - role: worker - labels: - node-role.fluidos.eu/resources: "true" - node-role.fluidos.eu/worker: "true" - image: kindest/node:v1.25.0 - - role: worker - image: kindest/node:v1.25.0 - labels: - node-role.fluidos.eu/resources: "true" \ No newline at end of file diff --git a/examples/kind/consumer/values.yaml b/examples/kind/consumer/values.yaml deleted file mode 100644 index 650253c..0000000 --- a/examples/kind/consumer/values.yaml +++ /dev/null @@ -1,151 +0,0 @@ -# Default values for fluidos-node. -# This is a YAML-formatted file. -# Declare variables to be passed into your templates. - -# -- Images' tag to select a development version of fluidos-node instead of a release -tag: "v0.1" -# -- The pullPolicy for fluidos-node pods. -pullPolicy: "IfNotPresent" - -common: - # -- NodeSelector for all fluidos-node pods - nodeSelector: { - node-role.fluidos.eu/worker: "true" - } - # -- Tolerations for all fluidos-node pods - tolerations: [] - # -- Affinity for all fluidos-node pods - affinity: {} - # -- Extra arguments for all fluidos-node pods - extraArgs: [] - -localResourceManager: - # -- The number of REAR Controller, which can be increased for active/passive high availability. - replicas: 1 - pod: - # -- Annotations for the local-resource-manager pod. - annotations: {} - # -- Labels for the local-resource-manager pod. - labels: {} - # -- Extra arguments for the local-resource-manager pod. - extraArgs: [] - # -- Resource requests and limits (https://kubernetes.io/docs/user-guide/compute-resources/) for the local-resource-manager pod. - resources: - limits: {} - requests: {} - imageName: "ghcr.io/fluidos-project/local-resource-manager" - config: - # -- Label used to identify the nodes from which resources are collected. - nodeResourceLabel: "node-role.fluidos.eu/resources" - # -- This flag defines the resource type of the generated flavours. - resourceType: "k8s-fluidos" - flavour: - # -- The minimum number of CPUs that can be requested to purchase a flavour. - cpuMin: "0" - # -- The minimum amount of memory that can be requested to purchase a flavour. - memoryMin: "0" - # -- The CPU step that must be respected when requesting a flavour through a Flavour Selector. - cpuStep: "1000m" - # -- The memory step that must be respected when requesting a flavour through a Flavour Selector. - memoryStep: "100Mi" - -rearManager: - # -- The number of REAR Manager, which can be increased for active/passive high availability. - replicas: 1 - pod: - # -- Annotations for the rear-manager pod. - annotations: {} - # -- Labels for the rear-manager pod. - labels: {} - # -- Extra arguments for the rear-manager pod. - extraArgs: [] - # -- Resource requests and limits (https://kubernetes.io/docs/user-guide/compute-resources/) for the rear-manager pod. - resources: - limits: {} - requests: {} - imageName: "ghcr.io/fluidos-project/rear-manager" - -rearController: - # -- The number of REAR Controller, which can be increased for active/passive high availability. - replicas: 1 - pod: - # -- Annotations for the rear-controller pod. - annotations: {} - # -- Labels for the rear-controller pod. - labels: {} - # -- Extra arguments for the rear-controller pod. - extraArgs: [] - # -- Resource requests and limits (https://kubernetes.io/docs/user-guide/compute-resources/) for the rear-controller pod. - resources: - limits: {} - requests: {} - imageName: "ghcr.io/fluidos-project/rear-controller" - service: - grpc: - name: "grpc" - # -- Kubernetes service used to expose the gRPC Server to liqo. - type: "ClusterIP" - # -- Annotations for the gRPC service. - annotations: {} - # -- Labels for the gRPC service. - labels: {} - # -- The gRPC port used by Liqo to connect with the Gateway of the rear-controller to obtain the Contract resources for a given consumer ClusterID. - port: 2710 - # -- The target port used by the gRPC service. - targetPort: 2710 - gateway: - name: "gateway" - # -- Kubernetes service to be used to expose the REAR gateway. - type: "NodePort" - # -- Annotations for the REAR gateway service. - annotations: {} - # -- Labels for the REAR gateway service. - labels: {} - # -- Options valid if service type is NodePort. - nodePort: - # -- Force the port used by the NodePort service. - port: 30000 - # -- Options valid if service type is LoadBalancer. - loadBalancer: - # -- Override the IP here if service type is LoadBalancer and you want to use a specific IP address, e.g., because you want a static LB. - ip: "" - # -- The port used by the rear-controller to expose the REAR Gateway. - port: 3004 - # -- The target port used by the REAR Gateway service. - targetPort: 3004 - -networkManager: - # -- The number of Network Manager, which can be increased for active/passive high availability. - replicas: 1 - pod: - # -- Annotations for the network-manager pod. - annotations: {} - # -- Labels for the network-manager pod. - labels: {} - # -- Extra arguments for the network-manager pod. - extraArgs: [] - # -- Resource requests and limits (https://kubernetes.io/docs/user-guide/compute-resources/) for the network-manager pod. - resources: - limits: {} - requests: {} - # -- The resource image to be used by the network-manager pod. - imageName: "ghcr.io/fluidos/network-manager" - configMaps: - providers: - # -- The name of the ConfigMap containing the list of the FLUIDOS Providers and the default FLUIDOS Provider (SuperNode or Catalogue). - name: "fluidos-network-manager-config" - # -- The IP List of Local knwon FLUIDOS Nodes separated by commas. - local: - # -- The IP List of Remote known FLUIDOS Nodes separated by commas. - remote: - # -- The IP List of SuperNodes separated by commas. - default: - nodeIdentity: - # -- The name of the ConfigMap containing the FLUIDOS Node identity info. - name: "fluidos-network-manager-identity" - # -- The domain name of the FLUIDOS closed domani: It represents for instance the Enterprise and it is used to generate the FQDN of the owned FLUIDOS Nodes - domain: "fluidos.eu" - # -- The IP address of the FLUIDOS Node. It can be public or private, depending on the network configuration and it corresponds to the IP address to reach the Network Manager from the outside of the cluster. - ip: - # -- The NodeID is a UUID that identifies the FLUIDOS Node. It is used to generate the FQDN of the owned FLUIDOS Nodes and it is unique in the FLUIDOS closed domain - nodeID: diff --git a/examples/kind/metrics-server.yaml b/examples/kind/metrics-server.yaml deleted file mode 100644 index d84b7e2..0000000 --- a/examples/kind/metrics-server.yaml +++ /dev/null @@ -1,197 +0,0 @@ -apiVersion: v1 -kind: ServiceAccount -metadata: - labels: - k8s-app: metrics-server - name: metrics-server - namespace: kube-system ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - labels: - k8s-app: metrics-server - rbac.authorization.k8s.io/aggregate-to-admin: "true" - rbac.authorization.k8s.io/aggregate-to-edit: "true" - rbac.authorization.k8s.io/aggregate-to-view: "true" - name: system:aggregated-metrics-reader -rules: -- apiGroups: - - metrics.k8s.io - resources: - - pods - - nodes - verbs: - - get - - list - - watch ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - labels: - k8s-app: metrics-server - name: system:metrics-server -rules: -- apiGroups: - - "" - resources: - - nodes/metrics - verbs: - - get -- apiGroups: - - "" - resources: - - pods - - nodes - verbs: - - get - - list - - watch ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: RoleBinding -metadata: - labels: - k8s-app: metrics-server - name: metrics-server-auth-reader - namespace: kube-system -roleRef: - apiGroup: rbac.authorization.k8s.io - kind: Role - name: extension-apiserver-authentication-reader -subjects: -- kind: ServiceAccount - name: metrics-server - namespace: kube-system ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRoleBinding -metadata: - labels: - k8s-app: metrics-server - name: metrics-server:system:auth-delegator -roleRef: - apiGroup: rbac.authorization.k8s.io - kind: ClusterRole - name: system:auth-delegator -subjects: -- kind: ServiceAccount - name: metrics-server - namespace: kube-system ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRoleBinding -metadata: - labels: - k8s-app: metrics-server - name: system:metrics-server -roleRef: - apiGroup: rbac.authorization.k8s.io - kind: ClusterRole - name: system:metrics-server -subjects: -- kind: ServiceAccount - name: metrics-server - namespace: kube-system ---- -apiVersion: v1 -kind: Service -metadata: - labels: - k8s-app: metrics-server - name: metrics-server - namespace: kube-system -spec: - ports: - - name: https - port: 443 - protocol: TCP - targetPort: https - selector: - k8s-app: metrics-server ---- -apiVersion: apps/v1 -kind: Deployment -metadata: - labels: - k8s-app: metrics-server - name: metrics-server - namespace: kube-system -spec: - selector: - matchLabels: - k8s-app: metrics-server - strategy: - rollingUpdate: - maxUnavailable: 0 - template: - metadata: - labels: - k8s-app: metrics-server - spec: - containers: - - args: - - --cert-dir=/tmp - - --secure-port=4443 - - --kubelet-preferred-address-types=InternalIP,ExternalIP,Hostname - - --kubelet-use-node-status-port - - --metric-resolution=15s - - --kubelet-insecure-tls - image: registry.k8s.io/metrics-server/metrics-server:v0.6.4 - imagePullPolicy: IfNotPresent - livenessProbe: - failureThreshold: 3 - httpGet: - path: /livez - port: https - scheme: HTTPS - periodSeconds: 10 - name: metrics-server - ports: - - containerPort: 4443 - name: https - protocol: TCP - readinessProbe: - failureThreshold: 3 - httpGet: - path: /readyz - port: https - scheme: HTTPS - initialDelaySeconds: 20 - periodSeconds: 10 - resources: - requests: - cpu: 100m - memory: 200Mi - securityContext: - allowPrivilegeEscalation: false - readOnlyRootFilesystem: true - runAsNonRoot: true - runAsUser: 1000 - volumeMounts: - - mountPath: /tmp - name: tmp-dir - nodeSelector: - kubernetes.io/os: linux - priorityClassName: system-cluster-critical - serviceAccountName: metrics-server - volumes: - - emptyDir: {} - name: tmp-dir ---- -apiVersion: apiregistration.k8s.io/v1 -kind: APIService -metadata: - labels: - k8s-app: metrics-server - name: v1beta1.metrics.k8s.io -spec: - group: metrics.k8s.io - groupPriorityMinimum: 100 - insecureSkipTLSVerify: true - service: - name: metrics-server - namespace: kube-system - version: v1beta1 - versionPriority: 100 diff --git a/examples/kind/provider/cluster-multi-worker.yaml b/examples/kind/provider/cluster-multi-worker.yaml deleted file mode 100644 index 5822274..0000000 --- a/examples/kind/provider/cluster-multi-worker.yaml +++ /dev/null @@ -1,14 +0,0 @@ -kind: Cluster -apiVersion: kind.x-k8s.io/v1alpha4 -nodes: - - role: control-plane - image: kindest/node:v1.25.0 - - role: worker - labels: - node-role.fluidos.eu/resources: "true" - node-role.fluidos.eu/worker: "true" - image: kindest/node:v1.25.0 - - role: worker - image: kindest/node:v1.25.0 - labels: - node-role.fluidos.eu/resources: "true" diff --git a/examples/kind/provider/values.yaml b/examples/kind/provider/values.yaml deleted file mode 100644 index b42215e..0000000 --- a/examples/kind/provider/values.yaml +++ /dev/null @@ -1,151 +0,0 @@ -# Default values for fluidos-node. -# This is a YAML-formatted file. -# Declare variables to be passed into your templates. - -# -- Images' tag to select a development version of fluidos-node instead of a release -tag: "v0.1" -# -- The pullPolicy for fluidos-node pods. -pullPolicy: "IfNotPresent" - -common: - # -- NodeSelector for all fluidos-node pods - nodeSelector: { - node-role.fluidos.eu/worker: "true" - } - # -- Tolerations for all fluidos-node pods - tolerations: [] - # -- Affinity for all fluidos-node pods - affinity: {} - # -- Extra arguments for all fluidos-node pods - extraArgs: [] - -localResourceManager: - # -- The number of REAR Controller, which can be increased for active/passive high availability. - replicas: 1 - pod: - # -- Annotations for the local-resource-manager pod. - annotations: {} - # -- Labels for the local-resource-manager pod. - labels: {} - # -- Extra arguments for the local-resource-manager pod. - extraArgs: [] - # -- Resource requests and limits (https://kubernetes.io/docs/user-guide/compute-resources/) for the local-resource-manager pod. - resources: - limits: {} - requests: {} - imageName: "cannarelladev/local-resource-manager" - config: - # -- Label used to identify the nodes from which resources are collected. - nodeResourceLabel: "node-role.fluidos.eu/resources" - # -- This flag defines the resource type of the generated flavours. - resourceType: "k8s-fluidos" - flavour: - # -- The minimum number of CPUs that can be requested to purchase a flavour. - cpuMin: "0" - # -- The minimum amount of memory that can be requested to purchase a flavour. - memoryMin: "0" - # -- The CPU step that must be respected when requesting a flavour through a Flavour Selector. - cpuStep: "1000m" - # -- The memory step that must be respected when requesting a flavour through a Flavour Selector. - memoryStep: "100Mi" - -rearManager: - # -- The number of REAR Manager, which can be increased for active/passive high availability. - replicas: 1 - pod: - # -- Annotations for the rear-manager pod. - annotations: {} - # -- Labels for the rear-manager pod. - labels: {} - # -- Extra arguments for the rear-manager pod. - extraArgs: [] - # -- Resource requests and limits (https://kubernetes.io/docs/user-guide/compute-resources/) for the rear-manager pod. - resources: - limits: {} - requests: {} - imageName: "cannarelladev/rear-manager" - -rearController: - # -- The number of REAR Controller, which can be increased for active/passive high availability. - replicas: 1 - pod: - # -- Annotations for the rear-controller pod. - annotations: {} - # -- Labels for the rear-controller pod. - labels: {} - # -- Extra arguments for the rear-controller pod. - extraArgs: [] - # -- Resource requests and limits (https://kubernetes.io/docs/user-guide/compute-resources/) for the rear-controller pod. - resources: - limits: {} - requests: {} - imageName: "cannarelladev/rear-controller" - service: - grpc: - name: "grpc" - # -- Kubernetes service used to expose the gRPC Server to liqo. - type: "ClusterIP" - # -- Annotations for the gRPC service. - annotations: {} - # -- Labels for the gRPC service. - labels: {} - # -- The gRPC port used by Liqo to connect with the Gateway of the rear-controller to obtain the Contract resources for a given consumer ClusterID. - port: 2710 - # -- The target port used by the gRPC service. - targetPort: 2710 - gateway: - name: "gateway" - # -- Kubernetes service to be used to expose the REAR gateway. - type: "NodePort" - # -- Annotations for the REAR gateway service. - annotations: {} - # -- Labels for the REAR gateway service. - labels: {} - # -- Options valid if service type is NodePort. - nodePort: - # -- Force the port used by the NodePort service. - port: 30001 - # -- Options valid if service type is LoadBalancer. - loadBalancer: - # -- Override the IP here if service type is LoadBalancer and you want to use a specific IP address, e.g., because you want a static LB. - ip: "" - # -- The port used by the rear-controller to expose the REAR Gateway. - port: 3004 - # -- The target port used by the REAR Gateway service. - targetPort: 3004 - -networkManager: - # -- The number of Network Manager, which can be increased for active/passive high availability. - replicas: 1 - pod: - # -- Annotations for the network-manager pod. - annotations: {} - # -- Labels for the network-manager pod. - labels: {} - # -- Extra arguments for the network-manager pod. - extraArgs: [] - # -- Resource requests and limits (https://kubernetes.io/docs/user-guide/compute-resources/) for the network-manager pod. - resources: - limits: {} - requests: {} - # -- The resource image to be used by the network-manager pod. - imageName: "ghcr.io/fluidos/network-manager" - configMaps: - providers: - # -- The name of the ConfigMap containing the list of the FLUIDOS Providers and the default FLUIDOS Provider (SuperNode or Catalogue). - name: "fluidos-network-manager-config" - # -- The IP List of Local knwon FLUIDOS Nodes separated by commas. - local: "host.docker.internal:9000" - # -- The IP List of Remote known FLUIDOS Nodes separated by commas. - remote: - # -- The IP List of SuperNodes separated by commas. - default: - nodeIdentity: - # -- The name of the ConfigMap containing the FLUIDOS Node identity info. - name: "fluidos-network-manager-identity" - # -- The domain name of the FLUIDOS closed domani: It represents for instance the Enterprise and it is used to generate the FQDN of the owned FLUIDOS Nodes - domain: "fluidos.eu" - # -- The IP address of the FLUIDOS Node. It can be public or private, depending on the network configuration and it corresponds to the IP address to reach the Network Manager from the outside of the cluster. - ip: - # -- The NodeID is a UUID that identifies the FLUIDOS Node. It is used to generate the FQDN of the owned FLUIDOS Nodes and it is unique in the FLUIDOS closed domain - nodeID: diff --git a/examples/kind/setup.sh b/examples/kind/setup.sh deleted file mode 100644 index 0c2c893..0000000 --- a/examples/kind/setup.sh +++ /dev/null @@ -1,56 +0,0 @@ -#!/usr/bin/bash - -set -xeu - -lrmImage="cannarelladev/local-resource-manager:v0.1" -rearManagerImage="cannarelladev/rear-manager:v0.1" -rearControllerImage="cannarelladev/rear-controller:v0.1" - -consumer_node_port=30000 -provider_node_port=30001 - -kind create cluster --config consumer/cluster-multi-worker.yaml --name fluidos-consumer --kubeconfig $PWD/consumer/config -kind create cluster --config provider/cluster-multi-worker.yaml --name fluidos-provider --kubeconfig $PWD/provider/config - -consumer_controlplane_ip=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' fluidos-consumer-control-plane) -provider_controlplane_ip=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' fluidos-provider-control-plane) - -export KUBECONFIG=$PWD/consumer/config - -kubectl apply -f ../../deployments/node/crds -kubectl apply -f $PWD/metrics-server.yaml - -echo "Waiting for metrics-server to be ready" -kubectl wait --for=condition=ready pod -l k8s-app=metrics-server -n kube-system --timeout=300s - -kind load docker-image $lrmImage --name=fluidos-consumer -kind load docker-image $rearManagerImage --name=fluidos-consumer -kind load docker-image $rearControllerImage --name=fluidos-consumer - -helm install node ../../deployments/node -n fluidos \ - --create-namespace -f consumer/values.yaml \ - --set networkManager.configMaps.nodeIdentity.ip=$consumer_controlplane_ip:$consumer_node_port \ - --set networkManager.configMaps.providers.local=$provider_controlplane_ip:$provider_node_port - -liqoctl install kind --cluster-name fluidos-consumer - -export KUBECONFIG=$PWD/provider/config - -kubectl apply -f ../../deployments/node/crds -kubectl apply -f $PWD/metrics-server.yaml - -echo "Waiting for metrics-server to be ready" -kubectl wait --for=condition=ready pod -l k8s-app=metrics-server -n kube-system --timeout=300s - -kind load docker-image $lrmImage --name=fluidos-provider -kind load docker-image $rearManagerImage --name=fluidos-provider -kind load docker-image $rearControllerImage --name=fluidos-provider - -helm install node ../../deployments/node -n fluidos \ - --create-namespace -f provider/values.yaml \ - --set networkManager.configMaps.nodeIdentity.ip=$provider_controlplane_ip:$provider_node_port \ - --set networkManager.configMaps.providers.local=$consumer_controlplane_ip:$consumer_node_port - -liqoctl install kind --cluster-name fluidos-provider - - diff --git a/go.mod b/go.mod deleted file mode 100644 index acfc961..0000000 --- a/go.mod +++ /dev/null @@ -1,80 +0,0 @@ -module github.com/fluidos-project/node //node - -go 1.21.0 - -require ( - github.com/gorilla/mux v1.8.0 - github.com/liqotech/liqo v0.9.4 - google.golang.org/grpc v1.59.0-dev - k8s.io/api v0.28.2 - k8s.io/apimachinery v0.28.2 - k8s.io/client-go v0.28.2 - k8s.io/klog/v2 v2.100.1 - k8s.io/metrics v0.28.2 - sigs.k8s.io/controller-runtime v0.15.1 -) - -require ( - github.com/aws/aws-sdk-go v1.44.213 // indirect - github.com/beorn7/perks v1.0.1 // indirect - github.com/cespare/xxhash/v2 v2.2.0 // indirect - github.com/davecgh/go-spew v1.1.1 // indirect - github.com/emicklei/go-restful/v3 v3.10.1 // indirect - github.com/evanphx/json-patch/v5 v5.6.0 // indirect - github.com/fsnotify/fsnotify v1.6.0 // indirect - github.com/go-logr/logr v1.2.4 // indirect - github.com/go-logr/zapr v1.2.4 // indirect - github.com/go-openapi/jsonpointer v0.19.6 // indirect - github.com/go-openapi/jsonreference v0.20.2 // indirect - github.com/go-openapi/swag v0.22.3 // indirect - github.com/gogo/protobuf v1.3.2 // indirect - github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect - github.com/golang/protobuf v1.5.3 // indirect - github.com/google/gnostic-models v0.6.8 // indirect - github.com/google/go-cmp v0.5.9 // indirect - github.com/google/gofuzz v1.2.0 // indirect - github.com/google/uuid v1.3.1 // indirect - github.com/imdario/mergo v0.3.15 // indirect - github.com/jmespath/go-jmespath v0.4.0 // indirect - github.com/josharian/intern v1.0.0 // indirect - github.com/json-iterator/go v1.1.12 // indirect - github.com/mailru/easyjson v0.7.7 // indirect - github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect - github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect - github.com/modern-go/reflect2 v1.0.2 // indirect - github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect - github.com/pkg/errors v0.9.1 // indirect - github.com/prometheus/client_golang v1.16.0 // indirect - github.com/prometheus/client_model v0.4.0 // indirect - github.com/prometheus/common v0.44.0 // indirect - github.com/prometheus/procfs v0.10.1 // indirect - github.com/spf13/pflag v1.0.5 // indirect - github.com/virtual-kubelet/virtual-kubelet v1.10.0 // indirect - go.uber.org/atomic v1.10.0 // indirect - go.uber.org/multierr v1.11.0 // indirect - go.uber.org/zap v1.24.0 // indirect - golang.org/x/crypto v0.13.0 // indirect - golang.org/x/exp v0.0.0-20221114191408-850992195362 // indirect - golang.org/x/net v0.15.0 // indirect - golang.org/x/oauth2 v0.10.0 // indirect - golang.org/x/sys v0.12.0 // indirect - golang.org/x/term v0.12.0 // indirect - golang.org/x/text v0.13.0 // indirect - golang.org/x/time v0.3.0 // indirect - golang.zx2c4.com/wireguard/wgctrl v0.0.0-20220504211119-3d4a969bb56b // indirect - gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect - google.golang.org/appengine v1.6.7 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 // indirect - google.golang.org/protobuf v1.31.0 // indirect - gopkg.in/inf.v0 v0.9.1 // indirect - gopkg.in/yaml.v2 v2.4.0 // indirect - gopkg.in/yaml.v3 v3.0.1 // indirect - k8s.io/apiextensions-apiserver v0.28.2 // indirect - k8s.io/component-base v0.28.2 // indirect - k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9 // indirect - k8s.io/kubectl v0.28.2 // indirect - k8s.io/utils v0.0.0-20230406110748-d93618cff8a2 // indirect - sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect - sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect - sigs.k8s.io/yaml v1.3.0 // indirect -) diff --git a/go.sum b/go.sum deleted file mode 100644 index 32844e6..0000000 --- a/go.sum +++ /dev/null @@ -1,269 +0,0 @@ -github.com/aws/aws-sdk-go v1.44.213 h1:WahquyWs7cQdz0vpDVWyWETEemgSoORx0PbWL9oz2WA= -github.com/aws/aws-sdk-go v1.44.213/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= -github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= -github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= -github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= -github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= -github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= -github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/emicklei/go-restful/v3 v3.10.1 h1:rc42Y5YTp7Am7CS630D7JmhRjq4UlEUuEKfrDac4bSQ= -github.com/emicklei/go-restful/v3 v3.10.1/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= -github.com/evanphx/json-patch v5.6.0+incompatible h1:jBYDEEiFBPxA0v50tFdvOzQQTCvpL6mnFh5mB2/l16U= -github.com/evanphx/json-patch v5.6.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= -github.com/evanphx/json-patch/v5 v5.6.0 h1:b91NhWfaz02IuVxO9faSllyAtNXHMPkC5J8sJCLunww= -github.com/evanphx/json-patch/v5 v5.6.0/go.mod h1:G79N1coSVB93tBe7j6PhzjmR3/2VvlbKOFpnXhI9Bw4= -github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= -github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= -github.com/go-logr/logr v1.2.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ= -github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -github.com/go-logr/zapr v1.2.4 h1:QHVo+6stLbfJmYGkQ7uGHUCu5hnAFAj6mDe6Ea0SeOo= -github.com/go-logr/zapr v1.2.4/go.mod h1:FyHWQIzQORZ0QVE1BtVHv3cKtNLuXsbNLtpuhNapBOA= -github.com/go-openapi/jsonpointer v0.19.6 h1:eCs3fxoIi3Wh6vtgmLTOjdhSpiqphQ+DaPn38N2ZdrE= -github.com/go-openapi/jsonpointer v0.19.6/go.mod h1:osyAmYz/mB/C3I+WsTTSgw1ONzaLJoLCyoi6/zppojs= -github.com/go-openapi/jsonreference v0.20.2 h1:3sVjiK66+uXK/6oQ8xgcRKcFgQ5KXa2KvnJRumpMGbE= -github.com/go-openapi/jsonreference v0.20.2/go.mod h1:Bl1zwGIM8/wsvqjsOQLJ/SH+En5Ap4rVB5KVcIDZG2k= -github.com/go-openapi/swag v0.22.3 h1:yMBqmnQ0gyZvEb/+KzuWZOXgllrXT4SADYbvDaXHv/g= -github.com/go-openapi/swag v0.22.3/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= -github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= -github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= -github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= -github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/google/gnostic-models v0.6.8 h1:yo/ABAfM5IMRsS1VnXjTBvUb61tFIHozhlYvRgGre9I= -github.com/google/gnostic-models v0.6.8/go.mod h1:5n7qKqH0f5wFt+aWF8CW6pZLLNOfYuF5OpfBSENuI8U= -github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= -github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= -github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/pprof v0.0.0-20230323073829-e72429f035bd h1:r8yyd+DJDmsUhGrRBxH5Pj7KeFK5l+Y3FsgT8keqKtk= -github.com/google/pprof v0.0.0-20230323073829-e72429f035bd/go.mod h1:79YE0hCXdHag9sBkw2o+N/YnZtTkXi0UT9Nnixa5eYk= -github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4= -github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= -github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= -github.com/imdario/mergo v0.3.15 h1:M8XP7IuFNsqUx6VPK2P9OSmsYsI/YFaGil0uD21V3dM= -github.com/imdario/mergo v0.3.15/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY= -github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= -github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= -github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= -github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8= -github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= -github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= -github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= -github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= -github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= -github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= -github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= -github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= -github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/liqotech/liqo v0.9.4 h1:LwKDSO/0E5uCXd6vfxoEQ59bFVJ1jb1JfR1AEB8jjK8= -github.com/liqotech/liqo v0.9.4/go.mod h1:SYbULfgspXacnmyIY7PLbYtHsUnXozRbCvPVGf65N/w= -github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= -github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= -github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo= -github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= -github.com/miekg/dns v1.1.50 h1:DQUfb9uc6smULcREF09Uc+/Gd46YWqJd5DbpPE9xkcA= -github.com/miekg/dns v1.1.50/go.mod h1:e3IlAVfNqAllflbibAZEWOXOQ+Ynzk/dDozDxY7XnME= -github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= -github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= -github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= -github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= -github.com/onsi/ginkgo/v2 v2.12.0 h1:UIVDowFPwpg6yMUpPjGkYvf06K3RAiJXUhCxEwQVHRI= -github.com/onsi/ginkgo/v2 v2.12.0/go.mod h1:ZNEzXISYlqpb8S36iN71ifqLi3vVD1rVJGvWRCJOUpQ= -github.com/onsi/gomega v1.27.10 h1:naR28SdDFlqrG6kScpT8VWpu1xWY5nJRCF3XaYyBjhI= -github.com/onsi/gomega v1.27.10/go.mod h1:RsS8tutOdbdgzbPtzzATp12yT7kM5I5aElG3evPbQ0M= -github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= -github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prometheus/client_golang v1.16.0 h1:yk/hx9hDbrGHovbci4BY+pRMfSuuat626eFsHb7tmT8= -github.com/prometheus/client_golang v1.16.0/go.mod h1:Zsulrv/L9oM40tJ7T815tM89lFEugiJ9HzIqaAx4LKc= -github.com/prometheus/client_model v0.4.0 h1:5lQXD3cAg1OXBf4Wq03gTrXHeaV0TQvGfUooCfx1yqY= -github.com/prometheus/client_model v0.4.0/go.mod h1:oMQmHW1/JoDwqLtg57MGgP/Fb1CJEYF2imWWhWtMkYU= -github.com/prometheus/common v0.44.0 h1:+5BrQJwiBB9xsMygAB3TNvpQKOwlkc25LbISbrdOOfY= -github.com/prometheus/common v0.44.0/go.mod h1:ofAIvZbQ1e/nugmZGz4/qCb9Ap1VoSTIO7x0VV9VvuY= -github.com/prometheus/procfs v0.10.1 h1:kYK1Va/YMlutzCGazswoHKo//tZVlFpKYh+PymziUAg= -github.com/prometheus/procfs v0.10.1/go.mod h1:nwNm2aOCAYw8uTR/9bWRREkZFxAUcWzPHWJq+XBB/FM= -github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= -github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= -github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= -github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= -github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -github.com/virtual-kubelet/virtual-kubelet v1.10.0 h1:eV/mFFqThOJLz7Gjn1Ev8LchanGKGA2qZlsW6wipb4g= -github.com/virtual-kubelet/virtual-kubelet v1.10.0/go.mod h1:7Pvdei1p82C9uWS1VzLrnXbHTwQcGBoqShahChpacgI= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= -github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= -go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ= -go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= -go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= -go.uber.org/goleak v1.2.1 h1:NBol2c7O1ZokfZ0LEU9K6Whx/KnwvepVetCUhtKja4A= -go.uber.org/goleak v1.2.1/go.mod h1:qlT2yGI9QafXHhZZLxlSuNsMw3FFLxBr+tBRlmO1xH4= -go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= -go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= -go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= -go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60= -go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.13.0 h1:mvySKfSWJ+UKUii46M40LOvyWfN0s2U+46/jDd0e6Ck= -golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc= -golang.org/x/exp v0.0.0-20221114191408-850992195362 h1:NoHlPRbyl1VFI6FjwHtPQCN7wAMXI6cKcqrmXhOOfBQ= -golang.org/x/exp v0.0.0-20221114191408-850992195362/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= -golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc= -golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= -golang.org/x/net v0.15.0 h1:ugBLEUaxABaB5AJqW9enI0ACdci2RUd4eP51NTBvuJ8= -golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk= -golang.org/x/oauth2 v0.10.0 h1:zHCpF2Khkwy4mMB4bv0U37YtJdTGW8jI0glAApi0Kh8= -golang.org/x/oauth2 v0.10.0/go.mod h1:kTpgurOux7LqtuxjuyZa4Gj2gdezIt/jQtGnNFfypQI= -golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o= -golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.12.0 h1:/ZfYdc3zq+q02Rv9vGqTeSItdzZTSNDmfTi0mBAuidU= -golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= -golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= -golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4= -golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.13.0 h1:Iey4qkscZuv0VvIt8E0neZjtPVQFSc870HQ448QgEmQ= -golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.zx2c4.com/wireguard/wgctrl v0.0.0-20220504211119-3d4a969bb56b h1:9JncmKXcUwE918my+H6xmjBdhK2jM/UTUNXxhRG1BAk= -golang.zx2c4.com/wireguard/wgctrl v0.0.0-20220504211119-3d4a969bb56b/go.mod h1:yp4gl6zOlnDGOZeWeDfMwQcsdOIQnMdhuPx9mwwWBL4= -gomodules.xyz/jsonpatch/v2 v2.4.0 h1:Ci3iUJyx9UeRx7CeFN8ARgGbkESwJK+KB9lLcWxY/Zw= -gomodules.xyz/jsonpatch/v2 v2.4.0/go.mod h1:AH3dM2RI6uoBZxn3LVrfvJ3E0/9dG4cSrbuBJT4moAY= -google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= -google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 h1:bVf09lpb+OJbByTj913DRJioFFAjf/ZGxEz7MajTp2U= -google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98/go.mod h1:TUfxEVdsvPg18p6AslUXFoLdpED4oBnGwyqk3dV1XzM= -google.golang.org/grpc v1.59.0-dev h1:kGGaLrcUHIrrkQ82zIKBy3ERlPAO3DpVN3gbA8NShgg= -google.golang.org/grpc v1.59.0-dev/go.mod h1:tgX3ZQDlNJGU96V6yHh1T/JeoBQ2TXdr43YbYSsCJk0= -google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= -google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= -gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= -gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= -gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= -gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= -gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= -gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -k8s.io/api v0.28.2 h1:9mpl5mOb6vXZvqbQmankOfPIGiudghwCoLl1EYfUZbw= -k8s.io/api v0.28.2/go.mod h1:RVnJBsjU8tcMq7C3iaRSGMeaKt2TWEUXcpIt/90fjEg= -k8s.io/apiextensions-apiserver v0.28.2 h1:J6/QRWIKV2/HwBhHRVITMLYoypCoPY1ftigDM0Kn+QU= -k8s.io/apiextensions-apiserver v0.28.2/go.mod h1:5tnkxLGa9nefefYzWuAlWZ7RZYuN/765Au8cWLA6SRg= -k8s.io/apimachinery v0.28.2 h1:KCOJLrc6gu+wV1BYgwik4AF4vXOlVJPdiqn0yAWWwXQ= -k8s.io/apimachinery v0.28.2/go.mod h1:RdzF87y/ngqk9H4z3EL2Rppv5jj95vGS/HaFXrLDApU= -k8s.io/client-go v0.28.2 h1:DNoYI1vGq0slMBN/SWKMZMw0Rq+0EQW6/AK4v9+3VeY= -k8s.io/client-go v0.28.2/go.mod h1:sMkApowspLuc7omj1FOSUxSoqjr+d5Q0Yc0LOFnYFJY= -k8s.io/component-base v0.28.2 h1:Yc1yU+6AQSlpJZyvehm/NkJBII72rzlEsd6MkBQ+G0E= -k8s.io/component-base v0.28.2/go.mod h1:4IuQPQviQCg3du4si8GpMrhAIegxpsgPngPRR/zWpzc= -k8s.io/klog/v2 v2.100.1 h1:7WCHKK6K8fNhTqfBhISHQ97KrnJNFZMcQvKp7gP/tmg= -k8s.io/klog/v2 v2.100.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0= -k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9 h1:LyMgNKD2P8Wn1iAwQU5OhxCKlKJy0sHc+PcDwFB24dQ= -k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9/go.mod h1:wZK2AVp1uHCp4VamDVgBP2COHZjqD1T68Rf0CM3YjSM= -k8s.io/kubectl v0.28.2 h1:fOWOtU6S0smdNjG1PB9WFbqEIMlkzU5ahyHkc7ESHgM= -k8s.io/kubectl v0.28.2/go.mod h1:6EQWTPySF1fn7yKoQZHYf9TPwIl2AygHEcJoxFekr64= -k8s.io/metrics v0.28.2 h1:Z/oMk5SmiT/Ji1SaWOPfW2l9W831BLO9/XxDq9iS3ak= -k8s.io/metrics v0.28.2/go.mod h1:QTIIdjMrq+KodO+rmp6R9Pr1LZO8kTArNtkWoQXw0sw= -k8s.io/utils v0.0.0-20230406110748-d93618cff8a2 h1:qY1Ad8PODbnymg2pRbkyMT/ylpTrCM8P2RJ0yroCyIk= -k8s.io/utils v0.0.0-20230406110748-d93618cff8a2/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= -sigs.k8s.io/controller-runtime v0.15.1 h1:9UvgKD4ZJGcj24vefUFgZFP3xej/3igL9BsOUTb/+4c= -sigs.k8s.io/controller-runtime v0.15.1/go.mod h1:7ngYvp1MLT+9GeZ+6lH3LOlcHkp/+tzA/fmHa4iq9kk= -sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo= -sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0= -sigs.k8s.io/structured-merge-diff/v4 v4.2.3 h1:PRbqxJClWWYMNV1dhaG4NsibJbArud9kFxnAMREiWFE= -sigs.k8s.io/structured-merge-diff/v4 v4.2.3/go.mod h1:qjx8mGObPmV2aSZepjQjbmb2ihdVs8cGKBraizNC69E= -sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo= -sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8= diff --git a/hack/boilerplate.go.txt b/hack/boilerplate.go.txt deleted file mode 100644 index 015241e..0000000 --- a/hack/boilerplate.go.txt +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2022-2023 FLUIDOS Project -// -// 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. \ No newline at end of file diff --git a/pkg/local-resource-manager/controller_manager.go b/pkg/local-resource-manager/controller_manager.go deleted file mode 100644 index 12afafe..0000000 --- a/pkg/local-resource-manager/controller_manager.go +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright 2022-2023 FLUIDOS Project -// -// 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 localResourceManager - -import ( - "context" - "fmt" - "log" - - "github.com/fluidos-project/node/pkg/utils/getters" - "github.com/fluidos-project/node/pkg/utils/resourceforge" - "k8s.io/klog/v2" - "sigs.k8s.io/controller-runtime/pkg/client" -) - -// clusterRole -//+kubebuilder:rbac:groups=nodecore.fluidos.eu,resources=flavours,verbs=get;list;watch;create;update;patch;delete -//+kubebuilder:rbac:groups=core,resources=nodes,verbs=get;list;watch -//+kubebuilder:rbac:groups=core,resources=configmaps,verbs=get;list;watch -//+kubebuilder:rbac:groups=metrics.k8s.io,resources=pods,verbs=get;list;watch -//+kubebuilder:rbac:groups=metrics.k8s.io,resources=nodes,verbs=get;list;watch - -// TODO: If the local resource manager restarts, -// ensure to check and subtract the already allocated resources from the node -// resources calculation. - -// Start starts the controller -func Start(ctx context.Context, cl client.Client) error { - - klog.Info("Getting FLUIDOS Node identity...") - - nodeIdentity := getters.GetNodeIdentity(ctx, cl) - if nodeIdentity == nil { - klog.Info("Error getting FLUIDOS Node identity") - return fmt.Errorf("Error getting FLUIDOS Node identity") - } - - klog.Info("Getting nodes resources...") - nodes, err := GetNodesResources(ctx, cl) - if err != nil { - log.Printf("Error getting nodes resources: %v", err) - return err - } - - klog.Infof("Creating Flavours: found %d nodes", len(*nodes)) - - // For each node create a Flavour - for _, node := range *nodes { - flavour := resourceforge.ForgeFlavourFromMetrics(node, *nodeIdentity) - err := cl.Create(ctx, flavour) - if err != nil { - log.Printf("Error creating Flavour: %v", err) - return err - } - klog.Infof("Flavour created: %s", flavour.Name) - } - - return nil -} diff --git a/pkg/local-resource-manager/doc.go b/pkg/local-resource-manager/doc.go deleted file mode 100644 index 053d25e..0000000 --- a/pkg/local-resource-manager/doc.go +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2022-2023 FLUIDOS Project -// -// 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 localResourceManager implements the utility functions for the local resource manager controller -package localResourceManager diff --git a/pkg/local-resource-manager/node_services.go b/pkg/local-resource-manager/node_services.go deleted file mode 100644 index 9177c47..0000000 --- a/pkg/local-resource-manager/node_services.go +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright 2022-2023 FLUIDOS Project -// -// 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 localResourceManager - -import ( - "context" - - corev1 "k8s.io/api/core/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/klog/v2" - metricsv1beta1 "k8s.io/metrics/pkg/apis/metrics/v1beta1" - "sigs.k8s.io/controller-runtime/pkg/client" - - "github.com/fluidos-project/node/pkg/utils/flags" - "github.com/fluidos-project/node/pkg/utils/models" -) - -// GetNodesResources retrieves the metrics from all the worker nodes in the cluster -func GetNodesResources(ctx context.Context, cl client.Client) (*[]models.NodeInfo, error) { - // Set a label selector to filter worker nodes - labelSelector := labels.Set{flags.RESOURCE_NODE_LABEL: "true"}.AsSelector() - - // Get a list of nodes - nodes := &corev1.NodeList{} - err := cl.List(ctx, nodes, &client.ListOptions{ - LabelSelector: labelSelector, - }) - if err != nil { - klog.Errorf("Error when listing nodes: %s", err) - return nil, err - } - - // Get a list of nodes metrics - nodesMetrics := &metricsv1beta1.NodeMetricsList{} - err = cl.List(ctx, nodesMetrics, &client.ListOptions{ - LabelSelector: labelSelector, - }) - if err != nil { - klog.Errorf("Error when listing nodes metrics: %s", err) - return nil, err - } - - var nodesInfo []models.NodeInfo - // Print the name of each node - for _, node := range nodes.Items { - for _, metrics := range nodesMetrics.Items { - if node.Name != metrics.Name { - // So that we can select just the nodes that we want - continue - } - metricsStruct := forgeResourceMetrics(&metrics, &node) - nodeInfo := forgeNodeInfo(&node, metricsStruct) - nodesInfo = append(nodesInfo, *nodeInfo) - } - } - - return &nodesInfo, nil -} - -// forgeResourceMetrics creates from params a new ResourceMetrics Struct -func forgeResourceMetrics(nodeMetrics *metricsv1beta1.NodeMetrics, node *corev1.Node) *models.ResourceMetrics { - // Get the total and used resources - cpuTotal := node.Status.Allocatable.Cpu() - cpuUsed := nodeMetrics.Usage.Cpu() - memoryTotal := node.Status.Allocatable.Memory() - memoryUsed := nodeMetrics.Usage.Memory() - ephemeralStorage := nodeMetrics.Usage.StorageEphemeral() - - // Compute the available resources - cpuAvail := cpuTotal.DeepCopy() - memAvail := memoryTotal.DeepCopy() - cpuAvail.Sub(*cpuUsed) - memAvail.Sub(*memoryUsed) - - return &models.ResourceMetrics{ - CPUTotal: *cpuTotal, - CPUAvailable: cpuAvail, - MemoryTotal: *memoryTotal, - MemoryAvailable: memAvail, - EphemeralStorage: *ephemeralStorage, - } -} - -// forgeNodeInfo creates from params a new NodeInfo Struct -func forgeNodeInfo(node *corev1.Node, metrics *models.ResourceMetrics) *models.NodeInfo { - return &models.NodeInfo{ - UID: string(node.UID), - Name: node.Name, - Architecture: node.Status.NodeInfo.Architecture, - OperatingSystem: node.Status.NodeInfo.OperatingSystem, - ResourceMetrics: *metrics, - } -} - -// maxNode find the node with the maximum value based on the provided comparison function -/* func maxNode(nodes []models.NodeInfo, compareFunc func(models.NodeInfo, models.NodeInfo) bool) models.NodeInfo { - if len(nodes) == 0 { - klog.Errorf("Error when finding the node with the maximum value: the list of nodes is empty") - return models.NodeInfo{} - } - - maxNode := nodes[0] - for _, node := range nodes { - if compareFunc(node, maxNode) { - maxNode = node - } - } - return maxNode -} */ diff --git a/pkg/rear-controller/contract-manager/doc.go b/pkg/rear-controller/contract-manager/doc.go deleted file mode 100644 index 73e7cad..0000000 --- a/pkg/rear-controller/contract-manager/doc.go +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2022-2023 FLUIDOS Project -// -// 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 contractmanager implements the utility functions for the contract manager controller -package contractmanager diff --git a/pkg/rear-controller/contract-manager/models.go b/pkg/rear-controller/contract-manager/models.go deleted file mode 100644 index de779d0..0000000 --- a/pkg/rear-controller/contract-manager/models.go +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2022-2023 FLUIDOS Project -// -// 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 contractmanager - -import "time" - -// Selector represents the criteria for selecting Flavours. -type Selector struct { - FlavourType string `json:"type,omitempty"` - CPU int `json:"cpu,omitempty"` - RAM int `json:"ram,omitempty"` - EphemeralStorage int `json:"ephemeral-storage,omitempty"` -} - -// Transaction contains information regarding the transaction for a flavour -type Transaction struct { - TransactionID string `json:"transactionID"` - FlavourID string `json:"flavourID"` - StartTime time.Time `json:"startTime,omitempty"` -} - -// Purchase contains information regarding the purchase for a flavour -type Purchase struct { - TransactionID string `json:"transactionID"` - FlavourID string `json:"flavourID"` - BuyerID string `json:"buyerID"` -} - -// ResponsePurchase contain information after purchase a Flavour -type ResponsePurchase struct { - FlavourID string `json:"flavourID"` - BuyerID string `json:"buyerID"` - Status string `json:"status"` -} diff --git a/pkg/rear-controller/contract-manager/reservation_controller.go b/pkg/rear-controller/contract-manager/reservation_controller.go deleted file mode 100644 index 28a4b45..0000000 --- a/pkg/rear-controller/contract-manager/reservation_controller.go +++ /dev/null @@ -1,280 +0,0 @@ -/* -Copyright 2023. - -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 contractmanager - -import ( - "context" - - "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/klog/v2" - ctrl "sigs.k8s.io/controller-runtime" - "sigs.k8s.io/controller-runtime/pkg/client" - - advertisementv1alpha1 "github.com/fluidos-project/node/apis/advertisement/v1alpha1" - nodecorev1alpha1 "github.com/fluidos-project/node/apis/nodecore/v1alpha1" - reservationv1alpha1 "github.com/fluidos-project/node/apis/reservation/v1alpha1" - "github.com/fluidos-project/node/pkg/rear-controller/gateway" - "github.com/fluidos-project/node/pkg/utils/namings" - "github.com/fluidos-project/node/pkg/utils/resourceforge" - "github.com/fluidos-project/node/pkg/utils/tools" -) - -// ReservationReconciler reconciles a Reservation object -type ReservationReconciler struct { - client.Client - Scheme *runtime.Scheme - Gateway *gateway.Gateway -} - -// clusterRole -//+kubebuilder:rbac:groups=reservation.fluidos.eu,resources=reservations,verbs=get;list;watch;create;update;patch;delete -//+kubebuilder:rbac:groups=reservation.fluidos.eu,resources=reservations/status,verbs=get;update;patch -//+kubebuilder:rbac:groups=reservation.fluidos.eu,resources=reservations/finalizers,verbs=update -//+kubebuilder:rbac:groups=reservation.fluidos.eu,resources=contracts,verbs=get;list;watch;create;update;patch;delete -//+kubebuilder:rbac:groups=reservation.fluidos.eu,resources=contracts/status,verbs=get;update;patch -//+kubebuilder:rbac:groups=reservation.fluidos.eu,resources=contracts/finalizers,verbs=update -//+kubebuilder:rbac:groups=reservation.fluidos.eu,resources=transactions,verbs=get;list;watch;create;update;patch;delete -//+kubebuilder:rbac:groups=reservation.fluidos.eu,resources=transactions/status,verbs=get;update;patch -//+kubebuilder:rbac:groups=reservation.fluidos.eu,resources=transactions/finalizers,verbs=update -//+kubebuilder:rbac:groups=core,resources=configmaps,verbs=get;list;watch - -// Reconcile is part of the main kubernetes reconciliation loop which aims to -// move the current state of the cluster closer to the desired state. -// -// For more details, check Reconcile and its Result here: -// - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.11.2/pkg/reconcile -func (r *ReservationReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { - klog.Info("Reconciling Reservation") - log := ctrl.LoggerFrom(ctx, "reservation", req.NamespacedName) - ctx = ctrl.LoggerInto(ctx, log) - - // var contract *reservationv1alpha1.Contract - - var reservation reservationv1alpha1.Reservation - if err := r.Get(ctx, req.NamespacedName, &reservation); client.IgnoreNotFound(err) != nil { - klog.Errorf("Error when getting Reservation %s before reconcile: %s", req.NamespacedName, err) - return ctrl.Result{}, err - } else if err != nil { - klog.Infof("Reservation %s not found, probably deleted", req.NamespacedName) - return ctrl.Result{}, nil - } - - var peeringCandidate advertisementv1alpha1.PeeringCandidate - if err := r.Get(ctx, client.ObjectKey{ - Name: reservation.Spec.PeeringCandidate.Name, - Namespace: reservation.Spec.PeeringCandidate.Namespace, - }, &peeringCandidate); err != nil { - klog.Errorf("Error when getting PeeringCandidate %s before reconcile: %s", req.NamespacedName, err) - reservation.SetPhase(nodecorev1alpha1.PhaseFailed, "Reservation failed: error when getting PeeringCandidate") - if err := r.updateReservationStatus(ctx, &reservation); err != nil { - klog.Errorf("Error when updating Reservation %s status before reconcile: %s", req.NamespacedName, err) - return ctrl.Result{}, err - } - return ctrl.Result{}, err - } - - if reservation.Status.Phase.Phase != nodecorev1alpha1.PhaseSolved && - reservation.Status.Phase.Phase != nodecorev1alpha1.PhaseTimeout && - reservation.Status.Phase.Phase != nodecorev1alpha1.PhaseFailed && - reservation.Status.Phase.Phase != nodecorev1alpha1.PhaseRunning && - reservation.Status.Phase.Phase != nodecorev1alpha1.PhaseIdle { - - klog.Infof("Reservation %s started", reservation.Name) - reservation.Status.Phase.StartTime = tools.GetTimeNow() - reservation.SetPhase(nodecorev1alpha1.PhaseRunning, "Reservation started") - reservation.SetReserveStatus(nodecorev1alpha1.PhaseIdle) - reservation.SetPurchaseStatus(nodecorev1alpha1.PhaseIdle) - - if err := r.updateReservationStatus(ctx, &reservation); err != nil { - klog.Errorf("Error when updating Reservation %s status before reconcile: %s", req.NamespacedName, err) - return ctrl.Result{}, err - } - return ctrl.Result{}, nil - } - - if reservation.Spec.Reserve { - reservePhase := reservation.Status.ReservePhase - switch reservePhase { - case nodecorev1alpha1.PhaseRunning: - klog.Infof("Reservation %s: Reserve phase running", reservation.Name) - flavourID := namings.RetrieveFlavourNameFromPC(reservation.Spec.PeeringCandidate.Name) - res, err := r.Gateway.ReserveFlavour(ctx, &reservation, flavourID) - if err != nil { - if res != nil { - klog.Infof("Transaction is non correctly set, Retrying...") - return ctrl.Result{Requeue: true}, nil - } - klog.Errorf("Error when reserving flavour for Reservation %s: %s", req.NamespacedName, err) - reservation.SetReserveStatus(nodecorev1alpha1.PhaseFailed) - reservation.SetPhase(nodecorev1alpha1.PhaseFailed, "Reservation failed: error when reserving flavour") - if err := r.updateReservationStatus(ctx, &reservation); err != nil { - klog.Errorf("Error when updating Reservation %s status: %s", req.NamespacedName, err) - return ctrl.Result{}, err - } - return ctrl.Result{}, err - } - - klog.Infof("Transaction: %v", res) - - // Create a Transaction CR starting from the transaction object - transaction := resourceforge.ForgeTransactionFromObj(res) - - if err := r.Create(ctx, transaction); err != nil { - klog.Errorf("Error when creating Transaction %s: %s", transaction.Name, err) - return ctrl.Result{}, err - } - - klog.Infof("Transaction %s created", transaction.Name) - reservation.Status.TransactionID = res.TransactionID - reservation.SetReserveStatus(nodecorev1alpha1.PhaseSolved) - - // Update the status for reconcile - if err := r.updateReservationStatus(ctx, &reservation); err != nil { - klog.Errorf("Error when updating Reservation %s status: %s", req.NamespacedName, err) - return ctrl.Result{}, err - } - - return ctrl.Result{}, nil - - case nodecorev1alpha1.PhaseSolved: - klog.Infof("Reserve %s solved", reservation.Name) - case nodecorev1alpha1.PhaseFailed: - klog.Infof("Reserve %s failed", reservation.Name) - return ctrl.Result{}, nil - case nodecorev1alpha1.PhaseIdle: - klog.Infof("Reserve %s idle", reservation.Name) - reservation.SetReserveStatus(nodecorev1alpha1.PhaseRunning) - if err := r.updateReservationStatus(ctx, &reservation); err != nil { - klog.Errorf("Error when updating Reservation %s status: %s", req.NamespacedName, err) - return ctrl.Result{}, err - } - return ctrl.Result{}, nil - default: - klog.Infof("Reserve %s unknown phase", reservation.Name) - reservation.SetReserveStatus(nodecorev1alpha1.PhaseIdle) - if err := r.updateReservationStatus(ctx, &reservation); err != nil { - klog.Errorf("Error when updating Reservation %s status: %s", req.NamespacedName, err) - return ctrl.Result{}, err - } - return ctrl.Result{}, nil - } - } - - if reservation.Spec.Purchase && reservation.Status.ReservePhase == nodecorev1alpha1.PhaseSolved { - purchasePhase := reservation.Status.PurchasePhase - switch purchasePhase { - case nodecorev1alpha1.PhaseIdle: - klog.Infof("Purchase phase for the reservation %s idle, starting...", reservation.Name) - reservation.SetPurchaseStatus(nodecorev1alpha1.PhaseRunning) - if err := r.updateReservationStatus(ctx, &reservation); err != nil { - klog.Errorf("Error when updating Reservation %s status: %s", req.NamespacedName, err) - return ctrl.Result{}, err - } - return ctrl.Result{}, nil - case nodecorev1alpha1.PhaseRunning: - if reservation.Status.TransactionID == "" { - klog.Infof("TransactionID not set for Reservation %s", reservation.Name) - reservation.SetPurchaseStatus(nodecorev1alpha1.PhaseFailed) - reservation.SetPhase(nodecorev1alpha1.PhaseFailed, "Reservation failed: TransactionID not set") - if err := r.updateReservationStatus(ctx, &reservation); err != nil { - klog.Errorf("Error when updating Reservation %s status: %s", req.NamespacedName, err) - return ctrl.Result{}, err - } - return ctrl.Result{}, nil - } - - transactionID := reservation.Status.TransactionID - resPurchase, err := r.Gateway.PurchaseFlavour(ctx, transactionID, reservation.Spec.Seller) - if err != nil { - klog.Errorf("Error when purchasing flavour for Reservation %s: %s", req.NamespacedName, err) - reservation.SetPurchaseStatus(nodecorev1alpha1.PhaseFailed) - reservation.SetPhase(nodecorev1alpha1.PhaseFailed, "Reservation failed: error when purchasing flavour") - if err := r.updateReservationStatus(ctx, &reservation); err != nil { - klog.Errorf("Error when updating Reservation %s status: %s", req.NamespacedName, err) - return ctrl.Result{}, err - } - return ctrl.Result{}, err - } - - klog.Infof("Purchase completed with status %s", resPurchase.Status) - - reservation.SetPurchaseStatus(nodecorev1alpha1.PhaseRunning) - - if err := r.Update(ctx, &reservation); err != nil { - klog.Errorf("Error when updating Reservation %s: %s", reservation.Name, err) - return ctrl.Result{}, err - } - - klog.Infof("Reservation %s updated", reservation.Name) - - // Create a contract CR now that the reservation is solved - contract := resourceforge.ForgeContractFromObj(resPurchase.Contract) - err = r.Create(ctx, contract) - if errors.IsAlreadyExists(err) { - klog.Errorf("Error when creating Contract %s: %s", contract.Name, err) - } else if err != nil { - klog.Errorf("Error when creating Contract %s: %s", contract.Name, err) - return ctrl.Result{}, err - } - klog.Infof("Contract %s created", contract.Name) - - reservation.SetPurchaseStatus(nodecorev1alpha1.PhaseSolved) - reservation.Status.Contract = nodecorev1alpha1.GenericRef{ - Name: contract.Name, - Namespace: contract.Namespace, - } - reservation.SetPhase(nodecorev1alpha1.PhaseSolved, "Reservation solved") - - if err := r.updateReservationStatus(ctx, &reservation); err != nil { - klog.Errorf("Error when updating Reservation %s status: %s", req.NamespacedName, err) - return ctrl.Result{}, err - } - - return ctrl.Result{}, nil - - case nodecorev1alpha1.PhaseFailed: - klog.Infof("Purchase phase for the reservation %s failed", reservation.Name) - return ctrl.Result{}, nil - - case nodecorev1alpha1.PhaseSolved: - klog.Infof("Purchase phase for the reservation %s solved", reservation.Name) - default: - klog.Infof("Purchase phase for the reservation %s unknown", reservation.Name) - reservation.SetPurchaseStatus(nodecorev1alpha1.PhaseIdle) - if err := r.updateReservationStatus(ctx, &reservation); err != nil { - klog.Errorf("Error when updating Reservation %s status: %s", req.NamespacedName, err) - return ctrl.Result{}, err - } - return ctrl.Result{}, nil - } - } - - return ctrl.Result{}, nil -} - -// updateSolverStatus updates the status of the discovery -func (r *ReservationReconciler) updateReservationStatus(ctx context.Context, reservation *reservationv1alpha1.Reservation) error { - return r.Status().Update(ctx, reservation) -} - -// SetupWithManager sets up the controller with the Manager. -func (r *ReservationReconciler) SetupWithManager(mgr ctrl.Manager) error { - return ctrl.NewControllerManagedBy(mgr). - For(&reservationv1alpha1.Reservation{}). - Complete(r) -} diff --git a/pkg/rear-controller/discovery-manager/const.go b/pkg/rear-controller/discovery-manager/const.go deleted file mode 100644 index 5473567..0000000 --- a/pkg/rear-controller/discovery-manager/const.go +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2022-2023 FLUIDOS Project -// -// 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 discoverymanager - -const ( - SERVER_ADDR = "http://localhost:14144/api" - K8S_TYPE = "k8s-fluidos" - DEFAULT_NAMESPACE = "default" - CLIENT_ID = "topix.fluidos.eu" -) - -// We define different server addresses, much more dynamic and less hardcoded -var ( - SERVER_ADDRESSES = []string{"http://localhost:14144/api"} -) diff --git a/pkg/rear-controller/discovery-manager/discovery_controller.go b/pkg/rear-controller/discovery-manager/discovery_controller.go deleted file mode 100644 index 39d7c86..0000000 --- a/pkg/rear-controller/discovery-manager/discovery_controller.go +++ /dev/null @@ -1,172 +0,0 @@ -/* -Copyright 2023. - -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 discoverymanager - -import ( - "context" - - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/klog/v2" - ctrl "sigs.k8s.io/controller-runtime" - "sigs.k8s.io/controller-runtime/pkg/client" - - advertisementv1alpha1 "github.com/fluidos-project/node/apis/advertisement/v1alpha1" - nodecorev1alpha1 "github.com/fluidos-project/node/apis/nodecore/v1alpha1" - gateway "github.com/fluidos-project/node/pkg/rear-controller/gateway" - resourceforge "github.com/fluidos-project/node/pkg/utils/resourceforge" - "github.com/fluidos-project/node/pkg/utils/tools" -) - -// DiscoveryReconciler reconciles a Discovery object -type DiscoveryReconciler struct { - client.Client - Scheme *runtime.Scheme - Gateway *gateway.Gateway -} - -// clusterRole -//+kubebuilder:rbac:groups=advertisement.fluidos.eu,resources=peeringcandidates,verbs=get;list;watch;create;update;patch;delete -//+kubebuilder:rbac:groups=advertisement.fluidos.eu,resources=peeringcandidates/status,verbs=get;update;patch -//+kubebuilder:rbac:groups=advertisement.fluidos.eu,resources=peeringcandidates/finalizers,verbs=update -//+kubebuilder:rbac:groups=advertisement.fluidos.eu,resources=discoveries,verbs=get;list;watch;create;update;patch;delete -//+kubebuilder:rbac:groups=advertisement.fluidos.eu,resources=discoveries/status,verbs=get;update;patch -//+kubebuilder:rbac:groups=advertisement.fluidos.eu,resources=discoveries/finalizers,verbs=update -//+kubebuilder:rbac:groups=core,resources=configmaps,verbs=get;list;watch - -// Reconcile is part of the main kubernetes reconciliation loop which aims to -// move the current state of the cluster closer to the desired state. -// TODO(user): Modify the Reconcile function to compare the state specified by -// the Discovery object against the actual cluster state, and then -// perform operations to make the cluster state reflect the state specified by -// the user. -// -// For more details, check Reconcile and its Result here: -// - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.11.2/pkg/reconcile -func (r *DiscoveryReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { - log := ctrl.LoggerFrom(ctx, "discovery", req.NamespacedName) - ctx = ctrl.LoggerInto(ctx, log) - - var peeringCandidate *advertisementv1alpha1.PeeringCandidate - var peeringCandidateReserved advertisementv1alpha1.PeeringCandidate - - var discovery advertisementv1alpha1.Discovery - if err := r.Get(ctx, req.NamespacedName, &discovery); client.IgnoreNotFound(err) != nil { - klog.Errorf("Error when getting Discovery %s before reconcile: %s", req.NamespacedName, err) - return ctrl.Result{}, err - } else if err != nil { - klog.Infof("Discovery %s not found, probably deleted", req.NamespacedName) - return ctrl.Result{}, nil - } - - klog.Infof("Discovery %s started", discovery.Name) - - if discovery.Status.Phase.Phase != nodecorev1alpha1.PhaseSolved && - discovery.Status.Phase.Phase != nodecorev1alpha1.PhaseTimeout && - discovery.Status.Phase.Phase != nodecorev1alpha1.PhaseFailed && - discovery.Status.Phase.Phase != nodecorev1alpha1.PhaseRunning && - discovery.Status.Phase.Phase != nodecorev1alpha1.PhaseIdle { - - discovery.Status.Phase.StartTime = tools.GetTimeNow() - discovery.SetPhase(nodecorev1alpha1.PhaseRunning, "Discovery started") - - if err := r.updateDiscoveryStatus(ctx, &discovery); err != nil { - klog.Errorf("Error when updating Discovery %s status before reconcile: %s", req.NamespacedName, err) - return ctrl.Result{}, err - } - return ctrl.Result{}, nil - } - - switch discovery.Status.Phase.Phase { - case nodecorev1alpha1.PhaseRunning: - flavours, err := r.Gateway.DiscoverFlavours(discovery.Spec.Selector) - if err != nil { - klog.Errorf("Error when getting Flavour: %s", err) - discovery.SetPhase(nodecorev1alpha1.PhaseFailed, "Error when getting Flavour") - if err := r.updateDiscoveryStatus(ctx, &discovery); err != nil { - klog.Errorf("Error when updating Discovery %s status: %s", req.NamespacedName, err) - return ctrl.Result{}, err - } - return ctrl.Result{}, nil - } - - if len(flavours) == 0 { - klog.Infof("No Flavours found") - discovery.SetPhase(nodecorev1alpha1.PhaseFailed, "No Flavours found") - if err := r.updateDiscoveryStatus(ctx, &discovery); err != nil { - klog.Errorf("Error when updating Discovery %s status: %s", req.NamespacedName, err) - return ctrl.Result{}, err - } - return ctrl.Result{}, nil - } - - klog.Infof("Flavours found: %d", len(flavours)) - - // TODO: check if a corresponding PeeringCandidate already exists!! - var first bool = true - for _, flavour := range flavours { - if first { - // We refer to the first peering candidate as the one that is reserved - peeringCandidate = resourceforge.ForgePeeringCandidate(flavour, discovery.Spec.SolverID, true) - peeringCandidateReserved = *peeringCandidate - first = false - } else { - // the others are created as not reserved - peeringCandidate = resourceforge.ForgePeeringCandidate(flavour, discovery.Spec.SolverID, false) - } - - err = r.Create(context.Background(), peeringCandidate) - if err != nil { - klog.Infof("Discovery %s failed: error while creating Peering Candidate", discovery.Name) - return ctrl.Result{}, err - } - } - - // Update the Discovery with the PeeringCandidate - discovery.Status.PeeringCandidate = nodecorev1alpha1.GenericRef{ - Name: peeringCandidateReserved.Name, - Namespace: peeringCandidateReserved.Namespace, - } - - discovery.SetPhase(nodecorev1alpha1.PhaseSolved, "Discovery Solved: Peering Candidate found") - if err := r.updateDiscoveryStatus(ctx, &discovery); err != nil { - klog.Errorf("Error when updating Discovery %s: %s", discovery.Name, err) - return ctrl.Result{}, err - } - klog.Infof("Discovery %s updated", discovery.Name) - - return ctrl.Result{}, nil - - case nodecorev1alpha1.PhaseSolved: - klog.Infof("Discovery %s solved", discovery.Name) - case nodecorev1alpha1.PhaseFailed: - klog.Infof("Discovery %s failed", discovery.Name) - } - - return ctrl.Result{}, nil -} - -// updateDiscoveryStatus updates the status of the discovery -func (r *DiscoveryReconciler) updateDiscoveryStatus(ctx context.Context, discovery *advertisementv1alpha1.Discovery) error { - return r.Status().Update(ctx, discovery) -} - -// SetupWithManager sets up the controller with the Manager. -func (r *DiscoveryReconciler) SetupWithManager(mgr ctrl.Manager) error { - return ctrl.NewControllerManagedBy(mgr). - For(&advertisementv1alpha1.Discovery{}). - Complete(r) -} diff --git a/pkg/rear-controller/discovery-manager/doc.go b/pkg/rear-controller/discovery-manager/doc.go deleted file mode 100644 index 9b32566..0000000 --- a/pkg/rear-controller/discovery-manager/doc.go +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2022-2023 FLUIDOS Project -// -// 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 discoverymanager implements the utility functions for the discovery manager controller -package discoverymanager diff --git a/pkg/rear-controller/discovery-manager/peeringcandidate_wh.go b/pkg/rear-controller/discovery-manager/peeringcandidate_wh.go deleted file mode 100644 index 94c93c8..0000000 --- a/pkg/rear-controller/discovery-manager/peeringcandidate_wh.go +++ /dev/null @@ -1,118 +0,0 @@ -// Copyright 2022-2023 FLUIDOS Project -// -// 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 discoverymanager - -import ( - "context" - "fmt" - "net/http" - - admissionv1 "k8s.io/api/admission/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/klog/v2" - "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/webhook/admission" - - advertisementv1alpha1 "github.com/fluidos-project/node/apis/advertisement/v1alpha1" -) - -//+kubebuilder:webhook:path=/validate/peeringcandidate,mutating=false,failurePolicy=ignore,groups=advertisement.node.fluidos.io,resources=peeringcandidates,verbs=create;update;delete,versions=v1alpha1,name=pc.validate.fluidos.eu,sideEffects=None,admissionReviewVersions={v1,v1beta1} - -type PCValidator struct { - client client.Client - decoder *admission.Decoder -} - -func NewPCValidator(client client.Client) *PCValidator { - return &PCValidator{client: client, decoder: admission.NewDecoder(runtime.NewScheme())} -} - -func (v *PCValidator) Handle(ctx context.Context, req admission.Request) admission.Response { - - switch req.Operation { - case admissionv1.Create: - return v.HandleCreate(ctx, req) - case admissionv1.Delete: - return v.HandleDelete(ctx, req) - case admissionv1.Update: - return v.HandleUpdate(ctx, req) - default: - return admission.Errored(http.StatusBadRequest, fmt.Errorf("unsupported operation %q", req.Operation)) - } -} - -func (v *PCValidator) HandleCreate(ctx context.Context, req admission.Request) admission.Response { - pc, err := v.DecodePeeringCandidate(req.Object) - if err != nil { - klog.Errorf("Failed to decode peering candidate: %v", err) - return admission.Errored(http.StatusBadRequest, fmt.Errorf("failed to decode peering candidate: %v", err)) - } - - if pc.Spec.Reserved && pc.Spec.SolverID == "" { - return admission.Denied("If peering candidate is reserved, solver ID must be set") - } - - if !pc.Spec.Reserved && pc.Spec.SolverID != "" { - return admission.Denied("If peering candidate is not reserved, solver ID must not be set") - } - - return admission.Allowed("") -} - -func (v *PCValidator) HandleDelete(ctx context.Context, req admission.Request) admission.Response { - // Here we could check if the peering candidate is reserved and if so, we need to check if the solver ID matches the one of the solver that is deleting the peering candidate - // or if the solver ID is empty, we need to check if there is a Contract that is using this peering candidate - // Maybe this is not the right logic but it need to be discussed and implemented - return admission.Allowed("") -} - -func (v *PCValidator) HandleUpdate(ctx context.Context, req admission.Request) admission.Response { - pc, err := v.DecodePeeringCandidate(req.Object) - if err != nil { - klog.Errorf("Failed to decode peering candidate: %v", err) - return admission.Errored(http.StatusBadRequest, fmt.Errorf("failed to decode peering candidate: %v", err)) - } - - pcOld, err := v.DecodePeeringCandidate(req.OldObject) - if err != nil { - klog.Errorf("Failed to decode peering old candidate: %v", err) - return admission.Errored(http.StatusBadRequest, fmt.Errorf("failed to decode peering old candidate: %v", err)) - } - - // PC can be updated only if: - // - both Reserved flag and SolverID are not set (i.e. it is not reserved) - // - both Reserved flag and SolverID are set and you want to clear both in the same time - - if !pcOld.Spec.Reserved && pcOld.Spec.SolverID == "" { - return admission.Allowed("") - } - - if pcOld.Spec.Reserved && pcOld.Spec.SolverID != "" && !pc.Spec.Reserved && pc.Spec.SolverID == "" { - return admission.Allowed("") - } - - return admission.Denied("Peering candidate can be updated only if it is not reserved or if both Reserved flag and SolverID are set and you want to clear both in the same time") -} - -/* func (v *PCValidator) InjectDecoder(d *admission.Decoder) error { - v.decoder = d - return nil -} */ - -func (v *PCValidator) DecodePeeringCandidate(obj runtime.RawExtension) (pc *advertisementv1alpha1.PeeringCandidate, err error) { - pc = &advertisementv1alpha1.PeeringCandidate{} - err = v.decoder.DecodeRaw(obj, pc) - return -} diff --git a/pkg/rear-controller/doc.go b/pkg/rear-controller/doc.go deleted file mode 100644 index 7f4e1c4..0000000 --- a/pkg/rear-controller/doc.go +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2022-2023 FLUIDOS Project -// -// 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 rearcontroller implements the utility functions for the rear controller: contract manager, discovery manager and rear gateway -package rearcontroller diff --git a/pkg/rear-controller/gateway/client.go b/pkg/rear-controller/gateway/client.go deleted file mode 100644 index 88adda5..0000000 --- a/pkg/rear-controller/gateway/client.go +++ /dev/null @@ -1,189 +0,0 @@ -// Copyright 2022-2023 FLUIDOS Project -// -// 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 gateway - -import ( - "bytes" - "context" - "encoding/json" - "fmt" - "net/http" - - "k8s.io/klog/v2" - - nodecorev1alpha1 "github.com/fluidos-project/node/apis/nodecore/v1alpha1" - reservationv1alpha1 "github.com/fluidos-project/node/apis/reservation/v1alpha1" - "github.com/fluidos-project/node/pkg/utils/getters" - "github.com/fluidos-project/node/pkg/utils/models" - "github.com/fluidos-project/node/pkg/utils/parseutil" -) - -// TODO: move this function into the REAR Gateway package -// reserveFlavour reserves a flavour with the given flavourID -func (g *Gateway) ReserveFlavour(ctx context.Context, reservation *reservationv1alpha1.Reservation, flavourID string) (*models.Transaction, error) { - err := checkLiqoReadiness(g.LiqoReady) - if err != nil { - return nil, err - } - - var transaction models.Transaction - - body := models.ReserveRequest{ - FlavourID: flavourID, - Buyer: models.NodeIdentity{ - NodeID: g.ID.NodeID, - IP: g.ID.IP, - Domain: g.ID.Domain, - }, - } - - klog.Infof("Reservation %s for flavour %s", reservation.Name, flavourID) - - if reservation.Spec.Partition != nil { - body.Partition = parseutil.ParsePartition(reservation.Spec.Partition) - } - - selectorBytes, err := json.Marshal(body) - if err != nil { - return nil, err - } - - // TODO: this url should be taken from the nodeIdentity of the flavour - bodyBytes := bytes.NewBuffer(selectorBytes) - url := fmt.Sprintf("http://%s%s%s", reservation.Spec.Seller.IP, RESERVE_FLAVOUR_PATH, flavourID) - - klog.Infof("Sending request to %s", url) - - resp, err := makeRequest("POST", url, bodyBytes) - if err != nil { - return nil, err - } - defer resp.Body.Close() - - // Check if the response status code is 200 (OK) - if resp.StatusCode != http.StatusOK { - klog.Errorf("Received non-OK response status code: %v", resp) - return nil, fmt.Errorf("received non-OK response status code: %d", resp.StatusCode) - } - - if err := json.NewDecoder(resp.Body).Decode(&transaction); err != nil { - return nil, err - } - - // check if transaction is not correctly set - // This behaviuor is a possible bug of the rear-controller - // TODO: check it - if transaction.TransactionID == "" { - klog.Errorf("TransactionID received is empty") - return &transaction, fmt.Errorf("transactionID is empty") - } - - klog.Infof("Flavour %s reserved: transaction ID %s", flavourID, transaction.TransactionID) - - g.addNewTransacion(transaction) - - return &transaction, nil -} - -// PurchaseFlavour purchases a flavour with the given flavourID -func (g *Gateway) PurchaseFlavour(ctx context.Context, transactionID string, seller nodecorev1alpha1.NodeIdentity) (*models.ResponsePurchase, error) { - err := checkLiqoReadiness(g.LiqoReady) - if err != nil { - return nil, err - } - - var purchase models.ResponsePurchase - - // Check if the transaction exists - transaction, err := g.GetTransaction(transactionID) - if err != nil { - return nil, err - } - - body := models.PurchaseRequest{ - TransactionID: transaction.TransactionID, - } - - selectorBytes, err := json.Marshal(body) - if err != nil { - return nil, err - } - - bodyBytes := bytes.NewBuffer(selectorBytes) - // TODO: this url should be taken from the nodeIdentity of the flavour - url := fmt.Sprintf("http://%s%s%s", seller.IP, PURCHASE_FLAVOUR_PATH, transactionID) - - resp, err := makeRequest("POST", url, bodyBytes) - if err != nil { - return nil, err - } - defer resp.Body.Close() - - // Check if the response status code is 200 (OK) - if resp.StatusCode != http.StatusOK { - return nil, fmt.Errorf("received non-OK response status code: %d", resp.StatusCode) - } - - if err := json.NewDecoder(resp.Body).Decode(&purchase); err != nil { - return nil, err - } - - return &purchase, nil -} - -// SearchFlavour is a function that returns an array of Flavour that fit the Selector by performing a get request to an http server -func (g *Gateway) DiscoverFlavours(selector *nodecorev1alpha1.FlavourSelector) ([]*nodecorev1alpha1.Flavour, error) { - err := checkLiqoReadiness(g.LiqoReady) - if err != nil { - return nil, err - } - - var s *models.Selector - var flavoursCR []*nodecorev1alpha1.Flavour - - if selector == nil { - s = parseutil.ParseFlavourSelector(selector) - } - - providers := getters.GetLocalProviders(context.Background(), g.client) - - // Send the POST request to all the servers in the list - for _, provider := range providers { - flavour, err := discover(s, provider) - if err != nil { - klog.Errorf("Error when searching Flavour: %s", err) - return nil, err - } - flavoursCR = append(flavoursCR, flavour) - } - - klog.Infof("Found %d flavours", len(flavoursCR)) - return flavoursCR, nil -} - -func discover(s *models.Selector, provider string) (*nodecorev1alpha1.Flavour, error) { - if s != nil { - return searchFlavourWithSelector(s, provider) - } - return searchFlavour(provider) -} - -func checkLiqoReadiness(b bool) error { - if !b { - klog.Errorf("Liqo is not ready, please check or wait for the Liqo installation") - return fmt.Errorf("Liqo is not ready, please check or wait for the Liqo installation") - } - return nil -} diff --git a/pkg/rear-controller/gateway/doc.go b/pkg/rear-controller/gateway/doc.go deleted file mode 100644 index e695cad..0000000 --- a/pkg/rear-controller/gateway/doc.go +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2022-2023 FLUIDOS Project -// -// 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 gateway contains the HTTP Server and the utility functions for the REAR Gateway -package gateway diff --git a/pkg/rear-controller/gateway/gateway.go b/pkg/rear-controller/gateway/gateway.go deleted file mode 100644 index f100a19..0000000 --- a/pkg/rear-controller/gateway/gateway.go +++ /dev/null @@ -1,191 +0,0 @@ -// Copyright 2022-2023 FLUIDOS Project -// -// 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 gateway - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/gorilla/mux" - corev1 "k8s.io/api/core/v1" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/util/wait" - "k8s.io/klog/v2" - "sigs.k8s.io/controller-runtime/pkg/client" - - nodecorev1alpha1 "github.com/fluidos-project/node/apis/nodecore/v1alpha1" - "github.com/fluidos-project/node/pkg/utils/consts" - "github.com/fluidos-project/node/pkg/utils/flags" - "github.com/fluidos-project/node/pkg/utils/getters" - "github.com/fluidos-project/node/pkg/utils/models" - "github.com/fluidos-project/node/pkg/utils/tools" -) - -// clusterRole -//+kubebuilder:rbac:groups=reservation.fluidos.eu,resources=contracts,verbs=get;list;watch;create;update;patch;delete -//+kubebuilder:rbac:groups=nodecore.fluidos.eu,resources=flavours,verbs=get;list;watch;create;update;patch;delete -//+kubebuilder:rbac:groups=nodecore.fluidos.eu,resources=flavours/status,verbs=get;update;patch -//+kubebuilder:rbac:groups=nodecore.fluidos.eu,resources=flavours/finalizers,verbs=update -//+kubebuilder:rbac:groups=core,resources=configmaps,verbs=get;list;watch -//+kubebuilder:rbac:groups=core,resources=secrets,verbs=get;list;watch - -const ( - LIST_FLAVOURS_PATH = "/api/listflavours" - LIST_FLAVOUR_BY_ID_PATH = "/api/listflavours/" - RESERVE_FLAVOUR_PATH = "/api/reserveflavour/" - PURCHASE_FLAVOUR_PATH = "/api/purchaseflavour/" - LIST_FLAVOURS_BY_SELECTOR_PATH = "/api/listflavours/selector" -) - -type Gateway struct { - // NodeIdentity is the identity of the FLUIDOS Node - ID *nodecorev1alpha1.NodeIdentity - - // Transactions is a map of Transaction - Transactions map[string]models.Transaction - - // client is the Kubernetes client - client client.Client - - // Readyness of the Gateway. It is set when liqo is installed - LiqoReady bool - - // The Liqo ClusterID - ClusterID string -} - -func NewGateway(c client.Client) *Gateway { - return &Gateway{ - client: c, - Transactions: make(map[string]models.Transaction), - LiqoReady: false, - ClusterID: "", - } -} - -// Start starts a new HTTP server -func (g *Gateway) Start(ctx context.Context) error { - klog.Info("Getting FLUIDOS Node identity...") - - nodeIdentity := getters.GetNodeIdentity(ctx, g.client) - if nodeIdentity == nil { - klog.Info("Error getting FLUIDOS Node identity") - return fmt.Errorf("Error getting FLUIDOS Node identity") - } - - g.RegisterNodeIdentity(nodeIdentity) - - router := mux.NewRouter() - - // middleware for debugging purposes - // router.Use(loggingMiddleware) - - // middleware for readiness - router.Use(g.readinessMiddleware) - - // Gateway endpoints - router.HandleFunc(LIST_FLAVOURS_PATH, g.getFlavours).Methods("GET") - //router.HandleFunc(LIST_FLAVOUR_BY_ID_PATH+"{flavourID}", g.getFlavourByID).Methods("GET") - router.HandleFunc(LIST_FLAVOURS_BY_SELECTOR_PATH, g.getFlavoursBySelector).Methods("POST") - router.HandleFunc(RESERVE_FLAVOUR_PATH+"{flavourID}", g.reserveFlavour).Methods("POST") - router.HandleFunc(PURCHASE_FLAVOUR_PATH+"{transactionID}", g.purchaseFlavour).Methods("POST") - - // Configure the HTTP server - srv := &http.Server{ - Handler: router, - Addr: ":" + flags.HTTP_PORT, - } - - // Start server HTTP - klog.Infof("Starting HTTP server on port %s", flags.HTTP_PORT) - return srv.ListenAndServe() -} - -func (g *Gateway) RegisterNodeIdentity(nodeIdentity *nodecorev1alpha1.NodeIdentity) { - g.ID = nodeIdentity -} - -// Only for debugging purposes -/* func loggingMiddleware(next http.Handler) http.Handler { - return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - klog.Infof("Received request: %s %s %v", r.Method, r.URL.Path, r) - next.ServeHTTP(w, r) - }) -} */ - -func (g *Gateway) readinessMiddleware(next http.Handler) http.Handler { - return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - if !g.LiqoReady { - klog.Infof("Liqo not ready yet") - w.WriteHeader(http.StatusServiceUnavailable) - return - } - next.ServeHTTP(w, r) - }) -} - -func (g *Gateway) CacheRefresher(interval time.Duration) func(ctx context.Context) error { - return func(ctx context.Context) error { - return wait.PollUntilContextCancel(ctx, interval, false, g.refreshCache) - } -} - -// check expired transactions and remove them from the cache -func (g *Gateway) refreshCache(ctx context.Context) (bool, error) { - klog.Infof("Refreshing cache") - for transactionID, transaction := range g.Transactions { - if tools.CheckExpiration(transaction.StartTime, flags.EXPIRATION_TRANSACTION) { - klog.Infof("Transaction %s expired, removing it from cache...", transactionID) - g.removeTransaction(transactionID) - return false, nil - } - } - return false, nil -} - -func (g *Gateway) LiqoChecker(interval time.Duration) func(ctx context.Context) error { - return func(ctx context.Context) error { - return wait.PollUntilContextCancel(ctx, interval, false, g.checkLiqoReadiness) - } -} - -func (g *Gateway) checkLiqoReadiness(ctx context.Context) (bool, error) { - klog.Infof("Checking Liqo readiness") - if g.LiqoReady && g.ClusterID != "" { - return true, nil - } - - var cm corev1.ConfigMap - err := g.client.Get(ctx, types.NamespacedName{Name: consts.LIQO_CLUSTERID_CONFIGMAP_NAME, Namespace: consts.LIQO_NAMESPACE}, &cm) - if err != nil { - if client.IgnoreNotFound(err) != nil { - klog.Errorf("Error when retrieving Liqo ConfigMap: %s", err) - } - klog.Infof("Liqo not ready yet. ConfigMap not found") - return false, nil - } - - if cm.Data["CLUSTER_ID"] != "" && cm.Data["CLUSTER_NAME"] != "" { - klog.Infof("Liqo is ready") - g.LiqoReady = true - g.ClusterID = cm.Data["CLUSTER_ID"] - return true, nil - } - - klog.Infof("Liqo not ready yet") - return false, nil -} diff --git a/pkg/rear-controller/gateway/provider.go b/pkg/rear-controller/gateway/provider.go deleted file mode 100644 index 917123e..0000000 --- a/pkg/rear-controller/gateway/provider.go +++ /dev/null @@ -1,362 +0,0 @@ -// Copyright 2022-2023 FLUIDOS Project -// -// 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 gateway - -import ( - "context" - "encoding/json" - "io" - "net/http" - - "github.com/gorilla/mux" - "k8s.io/apimachinery/pkg/api/resource" - "k8s.io/klog/v2" - "sigs.k8s.io/controller-runtime/pkg/client" - - nodecorev1alpha1 "github.com/fluidos-project/node/apis/nodecore/v1alpha1" - reservationv1alpha1 "github.com/fluidos-project/node/apis/reservation/v1alpha1" - "github.com/fluidos-project/node/pkg/utils/common" - "github.com/fluidos-project/node/pkg/utils/flags" - "github.com/fluidos-project/node/pkg/utils/models" - "github.com/fluidos-project/node/pkg/utils/namings" - "github.com/fluidos-project/node/pkg/utils/parseutil" - "github.com/fluidos-project/node/pkg/utils/resourceforge" - "github.com/fluidos-project/node/pkg/utils/services" - "github.com/fluidos-project/node/pkg/utils/tools" -) - -// TODO: all these functions should be moved into the REAR Gateway package - -// getFlavours gets all the flavours CRs from the cluster -func (g *Gateway) getFlavours(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Content-Type", "application/json") - - klog.Infof("Processing request for getting all Flavours...") - - flavours, err := services.GetAllFlavours(g.client) - if err != nil { - klog.Errorf("Error getting all the Flavour CRs: %s", err) - http.Error(w, "Error getting all the Flavour CRs", http.StatusInternalServerError) - return - } - - klog.Infof("Found %d Flavours in the cluster", len(flavours)) - - // Filtering only the available flavours - for i, f := range flavours { - if !f.Spec.OptionalFields.Availability { - flavours = append(flavours[:i], flavours[i+1:]...) - } - } - - klog.Infof("Available Flavours: %d", len(flavours)) - if len(flavours) == 0 { - klog.Infof("No available Flavours found") - http.Error(w, "No Flavours found", http.StatusNotFound) - return - } - - // Select the flavour with the max CPU - max := resource.MustParse("0") - var selected nodecorev1alpha1.Flavour - for _, f := range flavours { - if f.Spec.Characteristics.Cpu.Cmp(max) == 1 { - max = f.Spec.Characteristics.Cpu - selected = f - } - } - - klog.Infof("Flavour %s selected - Parsing...", selected.Name) - parsed := parseutil.ParseFlavour(selected) - - klog.Infof("Flavour parsed: %v", parsed) - - // Encode the Flavour as JSON and write it to the response writer - encodeResponse(w, parsed) -} - -// getFlavourByID gets the flavour CR from the cluster that matches the flavourID -/* func (g *Gateway) getFlavourByID(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Content-Type", "application/json") - - // Get the flavourID from the URL - params := mux.Vars(r) - flavourID := params["flavourID"] - - // Get the Flavour that matches the flavourID - flavour, err := services.GetFlavourByID(flavourID, g.client) - if err != nil { - http.Error(w, "Error getting the Flavour by ID", http.StatusInternalServerError) - return - } - - if flavour == nil { - http.Error(w, "No Flavour found", http.StatusNotFound) - return - } - - flavourParsed := parseutil.ParseFlavour(*flavour) - - klog.Infof("Flavour found is: %s", flavourParsed.FlavourID) - - // Encode the FlavourList as JSON and write it to the response writer - encodeResponse(w, flavourParsed) - -} */ - -// getFlavourBySelectorHandler gets the flavour CRs from the cluster that match the selector -func (g *Gateway) getFlavoursBySelector(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Content-Type", "application/json") - - klog.Infof("Processing request for getting Flavours by selector...") - - // Read the request body - body, err := io.ReadAll(r.Body) - if err != nil { - http.Error(w, err.Error(), http.StatusInternalServerError) - return - } - - // build the selector from the request body - selector, err := buildSelector(body) - if err != nil { - klog.Errorf("Error building the selector: %s", err) - http.Error(w, err.Error(), http.StatusBadRequest) - return - } - - flavours, err := services.GetAllFlavours(g.client) - if err != nil { - klog.Errorf("Error getting all the Flavour CRs: %s", err) - http.Error(w, "Error getting all the Flavour CRs", http.StatusInternalServerError) - return - } - - klog.Infof("Found %d Flavours in the cluster", len(flavours)) - - // Filtering only the available flavours - for i, f := range flavours { - if !f.Spec.OptionalFields.Availability { - flavours = append(flavours[:i], flavours[i+1:]...) - } - } - - klog.Infof("Available Flavours: %d", len(flavours)) - if len(flavours) == 0 { - klog.Infof("No available Flavours found") - http.Error(w, "No Flavours found", http.StatusNotFound) - return - } - - klog.Infof("Checking selector syntax...") - if err := common.CheckSelector(selector); err != nil { - klog.Errorf("Error checking the selector syntax: %s", err) - http.Error(w, err.Error(), http.StatusBadRequest) - return - } - - klog.Infof("Filtering Flavours by selector...") - flavoursSelected, err := common.FilterFlavoursBySelector(flavours, selector) - if err != nil { - http.Error(w, "Error getting the Flavours by selector", http.StatusInternalServerError) - return - } - - klog.Infof("Flavours found that match the selector are: %d", len(flavoursSelected)) - - if len(flavoursSelected) == 0 { - klog.Infof("No matching Flavours found") - http.Error(w, "No Flavours found", http.StatusNotFound) - return - } - - // Select the flavour with the max CPU - max := resource.MustParse("0") - var selected nodecorev1alpha1.Flavour - for _, f := range flavoursSelected { - if f.Spec.Characteristics.Cpu.Cmp(max) == 1 { - max = f.Spec.Characteristics.Cpu - selected = f - } - } - - klog.Infof("Flavour %s selected - Parsing...", selected.Name) - parsed := parseutil.ParseFlavour(selected) - - klog.Infof("Flavour parsed: %v", parsed) - - // Encode the Flavour as JSON and write it to the response writer - encodeResponse(w, parsed) -} - -// reserveFlavour reserves a Flavour by its flavourID -func (g *Gateway) reserveFlavour(w http.ResponseWriter, r *http.Request) { - // Get the flavourID value from the URL parameters - params := mux.Vars(r) - flavourID := params["flavourID"] - var transaction models.Transaction - var request models.ReserveRequest - - if err := json.NewDecoder(r.Body).Decode(&request); err != nil { - klog.Errorf("Error decoding the ReserveRequest: %s", err) - http.Error(w, err.Error(), http.StatusBadRequest) - return - } - - if flavourID != request.FlavourID { - klog.Infof("Mismatch body & param: %s != %s", flavourID, request.FlavourID) - http.Error(w, "Mismatch body & param", http.StatusConflict) - return - } - - // Check if the Transaction already exists - t, found := g.SearchTransaction(request.Buyer.NodeID, flavourID) - if found { - t.StartTime = tools.GetTimeNow() - transaction = t - g.addNewTransacion(t) - } - - if !found { - klog.Infof("Reserving flavour %s started", flavourID) - - flavour, _ := services.GetFlavourByID(flavourID, g.client) - if flavour == nil { - http.Error(w, "Flavour not found", http.StatusNotFound) - return - } - - // Create a new transaction ID - transactionID, err := namings.ForgeTransactionID() - if err != nil { - http.Error(w, "Error generating transaction ID", http.StatusInternalServerError) - return - } - - // Create a new transaction - transaction := resourceforge.ForgeTransactionObj(transactionID, request) - - // Add the transaction to the transactions map - g.addNewTransacion(transaction) - } - - klog.Infof("Transaction %s reserved", transaction.TransactionID) - - encodeResponse(w, transaction) -} - -// purchaseFlavour is an handler for purchasing a Flavour -func (g *Gateway) purchaseFlavour(w http.ResponseWriter, r *http.Request) { - // Get the flavourID value from the URL parameters - params := mux.Vars(r) - transactionID := params["transactionID"] - var purchase models.PurchaseRequest - - if err := json.NewDecoder(r.Body).Decode(&purchase); err != nil { - http.Error(w, err.Error(), http.StatusBadRequest) - return - } - - if transactionID != purchase.TransactionID { - klog.Infof("Mismatch body & param") - http.Error(w, "Mismatch body & param", http.StatusConflict) - return - } - - klog.Infof("Purchasing request for transaction %s", purchase.TransactionID) - - // Retrieve the transaction from the transactions map - transaction, err := g.GetTransaction(purchase.TransactionID) - if err != nil { - klog.Errorf("Error getting the Transaction: %s", err) - http.Error(w, "Error getting the Transaction", http.StatusInternalServerError) - return - } - - klog.Infof("Flavour requested: %s", transaction.FlavourID) - - if tools.CheckExpiration(transaction.StartTime, flags.EXPIRATION_TRANSACTION) { - klog.Infof("Transaction %s expired", transaction.TransactionID) - http.Error(w, "Error: transaction Timeout", http.StatusRequestTimeout) - g.removeTransaction(transaction.TransactionID) - return - } - - var contractList reservationv1alpha1.ContractList - var contract reservationv1alpha1.Contract - - // Check if the Contract with the same TransactionID already exists - if err := g.client.List(context.Background(), &contractList, client.MatchingFields{"spec.transactionID": purchase.TransactionID}); err != nil { - if client.IgnoreNotFound(err) != nil { - klog.Errorf("Error when listing Contracts: %s", err) - http.Error(w, "Error when listing Contracts", http.StatusInternalServerError) - return - } - } - - if len(contractList.Items) > 0 { - klog.Infof("Contract already exists for transaction %s", purchase.TransactionID) - contract = contractList.Items[0] - // Create a contract object to be returned with the response - contractObject := parseutil.ParseContract(&contract) - // create a response purchase - responsePurchase := resourceforge.ForgeResponsePurchaseObj(contractObject) - // Respond with the response purchase as JSON - encodeResponse(w, responsePurchase) - return - } - - klog.Infof("Performing purchase of flavour %s...", transaction.FlavourID) - - // Remove the transaction from the transactions map - g.removeTransaction(transaction.TransactionID) - - klog.Infof("Flavour %s successfully purchased!", transaction.FlavourID) - - // Get the flavour sold for creating the contract - flavourSold, err := services.GetFlavourByID(transaction.FlavourID, g.client) - if err != nil { - klog.Errorf("Error getting the Flavour by ID: %s", err) - http.Error(w, "Error getting the Flavour by ID", http.StatusInternalServerError) - return - } - - liqoCredentials, err := GetLiqoCredentials(context.Background(), g.client) - if err != nil { - klog.Errorf("Error getting Liqo Credentials: %s", err) - http.Error(w, "Error getting Liqo Credentials", http.StatusInternalServerError) - return - } - - // Create a new contract - klog.Infof("Creating a new contract...") - contract = *resourceforge.ForgeContract(*flavourSold, transaction, liqoCredentials) - err = g.client.Create(context.Background(), &contract) - if err != nil { - klog.Errorf("Error creating the Contract: %s", err) - http.Error(w, "Error creating the Contract: "+err.Error(), http.StatusInternalServerError) - return - } - - klog.Infof("Contract created!") - - // Create a contract object to be returned with the response - contractObject := parseutil.ParseContract(&contract) - // create a response purchase - responsePurchase := resourceforge.ForgeResponsePurchaseObj(contractObject) - - // Respond with the response purchase as JSON - encodeResponse(w, responsePurchase) -} diff --git a/pkg/rear-controller/gateway/services.go b/pkg/rear-controller/gateway/services.go deleted file mode 100644 index 4dbe5a0..0000000 --- a/pkg/rear-controller/gateway/services.go +++ /dev/null @@ -1,113 +0,0 @@ -// Copyright 2022-2023 FLUIDOS Project -// -// 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 gateway - -import ( - "bytes" - "encoding/json" - "fmt" - "net/http" - - "k8s.io/klog/v2" - - nodecorev1alpha1 "github.com/fluidos-project/node/apis/nodecore/v1alpha1" - "github.com/fluidos-project/node/pkg/utils/models" - "github.com/fluidos-project/node/pkg/utils/resourceforge" -) - -func searchFlavourWithSelector(selector *models.Selector, addr string) (*nodecorev1alpha1.Flavour, error) { - var flavour models.Flavour - - // Marshal the selector into JSON bytes - selectorBytes, err := json.Marshal(selector) - if err != nil { - return nil, err - } - - body := bytes.NewBuffer(selectorBytes) - url := fmt.Sprintf("http://%s%s", addr, LIST_FLAVOURS_BY_SELECTOR_PATH) - - resp, err := makeRequest("POST", url, body) - if err != nil { - return nil, err - } - - // Check if the response status code is 200 (OK) - if resp.StatusCode != http.StatusOK { - return nil, fmt.Errorf("received non-OK response status code: %d", resp.StatusCode) - } - - if err := json.NewDecoder(resp.Body).Decode(&flavour); err != nil { - klog.Errorf("Error decoding the response body: %s", err) - return nil, err - } - - flavourCR := resourceforge.ForgeFlavourFromObj(flavour) - - return flavourCR, nil -} - -func searchFlavour(addr string) (*nodecorev1alpha1.Flavour, error) { - var flavour models.Flavour - - url := fmt.Sprintf("http://%s%s", addr, LIST_FLAVOURS_PATH) - - resp, err := makeRequest("GET", url, nil) - if err != nil { - return nil, err - } - - // Check if the response status code is 200 (OK) - if resp.StatusCode != http.StatusOK { - return nil, fmt.Errorf("received non-OK response status code: %d", resp.StatusCode) - } - - if err := json.NewDecoder(resp.Body).Decode(&flavour); err != nil { - klog.Errorf("Error decoding the response body: %s", err) - return nil, err - } - - flavourCR := resourceforge.ForgeFlavourFromObj(flavour) - - return flavourCR, nil -} - -func makeRequest(method, url string, body *bytes.Buffer) (*http.Response, error) { - - httpClient := &http.Client{} - - if body == nil { - body = bytes.NewBuffer([]byte{}) - } - - req, err := http.NewRequest(method, url, body) - if err != nil { - klog.Errorf("Error creating the request: %s", err) - return nil, err - } - req.Close = true - - if method == "POST" { - req.Header.Set("Content-Type", "application/json") - } - - resp, err := httpClient.Do(req) - if err != nil { - klog.Errorf("Error sending the request: %s", err.Error()) - return nil, err - } - - return resp, nil -} diff --git a/pkg/rear-controller/gateway/utils.go b/pkg/rear-controller/gateway/utils.go deleted file mode 100644 index c96b8b0..0000000 --- a/pkg/rear-controller/gateway/utils.go +++ /dev/null @@ -1,127 +0,0 @@ -// Copyright 2022-2023 FLUIDOS Project -// -// 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 gateway - -import ( - "context" - "encoding/json" - "fmt" - "net/http" - - "sigs.k8s.io/controller-runtime/pkg/client" - - reservationsv1alpha1 "github.com/fluidos-project/node/apis/reservation/v1alpha1" - "github.com/fluidos-project/node/pkg/utils/models" - - "github.com/liqotech/liqo/pkg/auth" - "github.com/liqotech/liqo/pkg/utils" - foreigncluster "github.com/liqotech/liqo/pkg/utils/foreignCluster" -) - -// buildSelector builds a selector from a request body -func buildSelector(body []byte) (*models.Selector, error) { - // Parse the request body into the APIRequest struct - var selector models.Selector - err := json.Unmarshal(body, &selector) - if err != nil { - return &models.Selector{}, err - } - return &selector, nil -} - -// getTransaction returns a transaction from the transactions map -func (g *Gateway) GetTransaction(transactionID string) (models.Transaction, error) { - transaction, exists := g.Transactions[transactionID] - if !exists { - return models.Transaction{}, fmt.Errorf("Transaction not found") - } - return transaction, nil -} - -// SearchTransaction returns a transaction from the transactions map -func (g *Gateway) SearchTransaction(buyerID string, flavourID string) (models.Transaction, bool) { - for _, t := range g.Transactions { - if t.Buyer.NodeID == buyerID && t.FlavourID == flavourID { - return t, true - } - } - return models.Transaction{}, false -} - -// addNewTransacion add a new transaction to the transactions map -func (g *Gateway) addNewTransacion(transaction models.Transaction) { - g.Transactions[transaction.TransactionID] = transaction -} - -// removeTransaction removes a transaction from the transactions map -func (g *Gateway) removeTransaction(transactionID string) { - delete(g.Transactions, transactionID) -} - -// handleError handles errors by sending an error response -func handleError(w http.ResponseWriter, err error, statusCode int) { - http.Error(w, err.Error(), statusCode) -} - -// encodeResponse encodes the response as JSON and writes it to the response writer -func encodeResponse(w http.ResponseWriter, data interface{}) { - - resp, err := json.Marshal(data) - if err != nil { - handleError(w, err, http.StatusInternalServerError) - } - - w.Header().Set("Content-Type", "application/json") - w.WriteHeader(http.StatusOK) - w.Write(resp) -} - -const ( - //authTokenSecretNamePrefix = "remote-token-" - - //tokenKey = "token" - - liqoNamespace = "liqo" -) - -func GetLiqoCredentials(ctx context.Context, cl client.Client) (*reservationsv1alpha1.LiqoCredentials, error) { - localToken, err := auth.GetToken(ctx, cl, liqoNamespace) - if err != nil { - return nil, err - } - - clusterIdentity, err := utils.GetClusterIdentityWithControllerClient(ctx, cl, liqoNamespace) - if err != nil { - return nil, err - } - - authEP, err := foreigncluster.GetHomeAuthURL(ctx, cl, liqoNamespace) - if err != nil { - return nil, err - } - - // If the local cluster has not a cluster name, we print the use the local clusterID to not leave this field empty. - // This can be changed by the user when pasting this value in a remote cluster. - if clusterIdentity.ClusterName == "" { - clusterIdentity.ClusterName = clusterIdentity.ClusterID - } - - return &reservationsv1alpha1.LiqoCredentials{ - ClusterName: clusterIdentity.ClusterName, - ClusterID: clusterIdentity.ClusterID, - Endpoint: authEP, - Token: localToken, - }, nil -} diff --git a/pkg/rear-controller/grpc/liqo-resource-manager.go b/pkg/rear-controller/grpc/liqo-resource-manager.go deleted file mode 100644 index 0d9e206..0000000 --- a/pkg/rear-controller/grpc/liqo-resource-manager.go +++ /dev/null @@ -1,132 +0,0 @@ -// Copyright 2022-2023 FLUIDOS Project -// -// 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 grpc - -import ( - context "context" - "fmt" - "log" - "net" - - grpc "google.golang.org/grpc" - corev1 "k8s.io/api/core/v1" - "k8s.io/apimachinery/pkg/api/resource" - "k8s.io/klog/v2" - "sigs.k8s.io/controller-runtime/pkg/client" - - resourcemonitors "github.com/liqotech/liqo/pkg/liqo-controller-manager/resource-request-controller/resource-monitors" - - "github.com/fluidos-project/node/pkg/utils/flags" -) - -type grpcServer struct { - Server *grpc.Server - client client.Client - //contractHandler connector.ContractHandler - stream resourcemonitors.ResourceReader_SubscribeServer - resourcemonitors.ResourceReaderServer -} - -func NewGrpcServer(cl client.Client) *grpcServer { - return &grpcServer{ - Server: grpc.NewServer(), - client: cl, - } -} - -func (s *grpcServer) Start(ctx context.Context) error { - grpcUrl := ":" + flags.GRPC_PORT - - // gRPC Configuration - klog.Info("Configuring gRPC Server") - lis, err := net.Listen("tcp", grpcUrl) - if err != nil { - klog.Infof("gRPC failed to listen: %v", err) - return fmt.Errorf("gRPC failed to listen: %v", err) - } - - klog.Infof("gRPC Server Listening on %s", grpcUrl) - // gRPC Server start listener - return s.Server.Serve(lis) -} - -/* func (s *grpcServer) RegisterContractHandler(ch connector.ContractHandler) { - s.contractHandler = ch -} */ - -func (s *grpcServer) ReadResources(ctx context.Context, req *resourcemonitors.ClusterIdentity) (*resourcemonitors.ResourceList, error) { - readResponse := &resourcemonitors.ResourceList{Resources: map[string]*resource.Quantity{}} - - log.Printf("ReadResource for clusterID %s", req.ClusterID) - resources, err := s.GetOfferResourcesByClusterID(req.ClusterID) - if err != nil { - // TODO: maybe should be resurned an empty resource list - return nil, err - } - - log.Printf("Retrieved resources for clusterID %s: %v", req.ClusterID, resources) - for key, value := range *resources { - readResponse.Resources[key.String()] = &value - } - - return readResponse, nil -} - -func (s *grpcServer) Subscribe(req *resourcemonitors.Empty, srv resourcemonitors.ResourceReader_SubscribeServer) error { - // Implement here your logic - s.stream = srv - ctx := srv.Context() - - fmt.Println("Subscribe") - - _ = s.NotifyChange(context.Background(), &resourcemonitors.ClusterIdentity{ClusterID: resourcemonitors.AllClusterIDs}) - - for { - select { - case <-ctx.Done(): - klog.Info("liqo controller manager disconnected") - return nil - } - } - -} - -func (s *grpcServer) NotifyChange(ctx context.Context, req *resourcemonitors.ClusterIdentity) error { - // Implement here your logic - if s.stream == nil { - return fmt.Errorf("you must first subscribe a controller manager to notify a change") - } else { - _ = s.stream.Send(req) - } - return nil -} - -func (s *grpcServer) RemoveCluster(ctx context.Context, req *resourcemonitors.ClusterIdentity) (*resourcemonitors.Empty, error) { - // Implement here your logic - return nil, fmt.Errorf("Not implemented") -} - -func (s *grpcServer) GetOfferResourcesByClusterID(clusterID string) (*corev1.ResourceList, error) { - log.Printf("Getting resources for cluster ID: %s", clusterID) - resources, err := getContractResourcesByClusterID(s.client, clusterID) - if err != nil { - return nil, err - } - return resources, nil -} - -func (s *grpcServer) UpdatePeeringOffer(clusterID string) { - _ = s.NotifyChange(context.Background(), &resourcemonitors.ClusterIdentity{ClusterID: clusterID}) -} diff --git a/pkg/rear-controller/grpc/service.go b/pkg/rear-controller/grpc/service.go deleted file mode 100644 index 0179aa9..0000000 --- a/pkg/rear-controller/grpc/service.go +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright 2022-2023 FLUIDOS Project -// -// 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 grpc - -import ( - "context" - "fmt" - - corev1 "k8s.io/api/core/v1" - "k8s.io/klog/v2" - "sigs.k8s.io/controller-runtime/pkg/client" - - reservationv1alpha1 "github.com/fluidos-project/node/apis/reservation/v1alpha1" -) - -func getContractResourcesByClusterID(cl client.Client, clusterID string) (*corev1.ResourceList, error) { - var contracts reservationv1alpha1.ContractList - - if err := cl.List(context.Background(), &contracts, client.MatchingFields{"spec.clusterID": clusterID}); err != nil { - if client.IgnoreNotFound(err) != nil { - klog.Errorf("Error when listing Contracts: %s", err) - return nil, err - } - } - - if len(contracts.Items) == 0 { - klog.Errorf("No contracts found for cluster %s", clusterID) - return nil, fmt.Errorf("No contracts found for cluster %s", clusterID) - } - - if len(contracts.Items) > 1 { - resources := multipleContractLogic(contracts.Items) - return resources, nil - } - - contract := contracts.Items[0] - - return mapQuantityToResourceList(contract.Spec.Partition), nil -} - -func multipleContractLogic(contracts []reservationv1alpha1.Contract) *corev1.ResourceList { - resources := &corev1.ResourceList{} - for _, contract := range contracts { - resources = addResources(*resources, contract.Spec.Partition) - } - return resources -} - -// This function adds the resources of a contract to the existing resourceList -func addResources(resources corev1.ResourceList, partition *reservationv1alpha1.Partition) *corev1.ResourceList { - for key, value := range *mapQuantityToResourceList(partition) { - if prevRes, ok := resources[key]; !ok { - resources[key] = value - } else { - prevRes.Add(value) - resources[key] = prevRes - } - } - return &resources -} - -func mapQuantityToResourceList(partition *reservationv1alpha1.Partition) *corev1.ResourceList { - return &corev1.ResourceList{ - corev1.ResourceCPU: partition.Cpu, - corev1.ResourceMemory: partition.Memory, - corev1.ResourceEphemeralStorage: partition.EphemeralStorage, - corev1.ResourceStorage: partition.Storage, - } -} diff --git a/pkg/rear-manager/allocation_controller.go b/pkg/rear-manager/allocation_controller.go deleted file mode 100644 index 17fed20..0000000 --- a/pkg/rear-manager/allocation_controller.go +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright 2022-2023 FLUIDOS Project -// -// 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 rearmanager - -import ( - "context" - - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/klog/v2" - ctrl "sigs.k8s.io/controller-runtime" - "sigs.k8s.io/controller-runtime/pkg/client" - - nodecorev1alpha1 "github.com/fluidos-project/node/apis/nodecore/v1alpha1" -) - -// +kubebuilder:rbac:groups=nodecore.fluidos.eu,resources=allocations,verbs=get;list;watch;create;update;patch;delete -// +kubebuilder:rbac:groups=nodecore.fluidos.eu,resources=allocations/status,verbs=get;update;patch -// +kubebuilder:rbac:groups=nodecore.fluidos.eu,resources=allocations/finalizers,verbs=update - -// AllocationReconciler reconciles a Allocation object -type AllocationReconciler struct { - client.Client - Scheme *runtime.Scheme -} - -func (r *AllocationReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { - log := ctrl.LoggerFrom(ctx, "allocation", req.NamespacedName) - ctx = ctrl.LoggerInto(ctx, log) - - var allocation nodecorev1alpha1.Allocation - if err := r.Get(ctx, req.NamespacedName, &allocation); client.IgnoreNotFound(err) != nil { - klog.Errorf("Error when getting Allocation %s before reconcile: %v", req.NamespacedName, err) - return ctrl.Result{}, err - } else if err != nil { - klog.Infof("Allocation %s not found, probably deleted", req.NamespacedName) - return ctrl.Result{}, nil - } - - return ctrl.Result{}, nil -} - -func (r *AllocationReconciler) SetupWithManager(mgr ctrl.Manager) error { - return ctrl.NewControllerManagedBy(mgr). - For(&nodecorev1alpha1.Allocation{}). - Complete(r) -} diff --git a/pkg/rear-manager/allocation_wh.go b/pkg/rear-manager/allocation_wh.go deleted file mode 100644 index 50d35c8..0000000 --- a/pkg/rear-manager/allocation_wh.go +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022-2023 FLUIDOS Project -// -// 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 rearmanager - -import ( - "context" - - //admissionv1 "k8s.io/api/admission/v1" - "k8s.io/apimachinery/pkg/runtime" - "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/webhook/admission" - - nodecorev1alpha1 "github.com/fluidos-project/node/apis/nodecore/v1alpha1" -) - -type Validator struct { - client client.Client - decoder *admission.Decoder -} - -func NewValidator(client client.Client) *Validator { - return &Validator{client: client, decoder: admission.NewDecoder(runtime.NewScheme())} -} - -func (v *Validator) Handle(ctx context.Context, req admission.Request) admission.Response { - - return admission.Allowed("allowed") -} - -func (v *Validator) HandleCreate(ctx context.Context, req admission.Request) admission.Response { - return admission.Allowed("allowed") -} - -func (v *Validator) HandleDelete(ctx context.Context, req admission.Request) admission.Response { - return admission.Allowed("allowed") -} - -func (v *Validator) HandleUpdate(ctx context.Context, req admission.Request) admission.Response { - return admission.Allowed("allowed") -} - -/* func (v *Validator) InjectDecoder(d *admission.Decoder) error { - v.decoder = d - return nil -} */ - -func (v *Validator) DecodeAllocation(obj runtime.RawExtension) (pc *nodecorev1alpha1.Allocation, err error) { - pc = &nodecorev1alpha1.Allocation{} - err = v.decoder.DecodeRaw(obj, pc) - return -} diff --git a/pkg/rear-manager/doc.go b/pkg/rear-manager/doc.go deleted file mode 100644 index e68026a..0000000 --- a/pkg/rear-manager/doc.go +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2022-2023 FLUIDOS Project -// -// 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 rearmanager implements the utility functions for the rear manager controller -package rearmanager diff --git a/pkg/rear-manager/solver_controller.go b/pkg/rear-manager/solver_controller.go deleted file mode 100644 index 3dc666a..0000000 --- a/pkg/rear-manager/solver_controller.go +++ /dev/null @@ -1,492 +0,0 @@ -/* -Copyright 2023. - -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 rearmanager - -import ( - "context" - - "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/klog/v2" - ctrl "sigs.k8s.io/controller-runtime" - "sigs.k8s.io/controller-runtime/pkg/builder" - "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/event" - "sigs.k8s.io/controller-runtime/pkg/handler" - "sigs.k8s.io/controller-runtime/pkg/reconcile" - - "sigs.k8s.io/controller-runtime/pkg/predicate" - - advertisementv1alpha1 "github.com/fluidos-project/node/apis/advertisement/v1alpha1" - nodecorev1alpha1 "github.com/fluidos-project/node/apis/nodecore/v1alpha1" - reservationv1alpha1 "github.com/fluidos-project/node/apis/reservation/v1alpha1" - "github.com/fluidos-project/node/pkg/utils/common" - "github.com/fluidos-project/node/pkg/utils/flags" - "github.com/fluidos-project/node/pkg/utils/getters" - "github.com/fluidos-project/node/pkg/utils/namings" - "github.com/fluidos-project/node/pkg/utils/resourceforge" - "github.com/fluidos-project/node/pkg/utils/tools" -) - -// SolverReconciler reconciles a Solver object -type SolverReconciler struct { - client.Client - Scheme *runtime.Scheme -} - -// clusterRole -//+kubebuilder:rbac:groups=nodecore.fluidos.eu,resources=solvers,verbs=get;list;watch;create;update;patch;delete -//+kubebuilder:rbac:groups=nodecore.fluidos.eu,resources=solvers/status,verbs=get;update;patch -//+kubebuilder:rbac:groups=nodecore.fluidos.eu,resources=solvers/finalizers,verbs=update -//+kubebuilder:rbac:groups=nodecore.fluidos.eu,resources=flavours,verbs=get;list;watch;create;update;patch;delete -//+kubebuilder:rbac:groups=nodecore.fluidos.eu,resources=flavours/status,verbs=get;update;patch -//+kubebuilder:rbac:groups=nodecore.fluidos.eu,resources=flavours/finalizers,verbs=update -//+kubebuilder:rbac:groups=advertisement.fluidos.eu,resources=peeringcandidates,verbs=get;list;watch;create;update;patch;delete -//+kubebuilder:rbac:groups=advertisement.fluidos.eu,resources=peeringcandidates/status,verbs=get;update;patch -//+kubebuilder:rbac:groups=advertisement.fluidos.eu,resources=peeringcandidates/finalizers,verbs=update -//+kubebuilder:rbac:groups=advertisement.fluidos.eu,resources=discoveries,verbs=get;list;watch;create;update;patch;delete -//+kubebuilder:rbac:groups=advertisement.fluidos.eu,resources=discoveries/status,verbs=get;update;patch -//+kubebuilder:rbac:groups=advertisement.fluidos.eu,resources=discoveries/finalizers,verbs=update -//+kubebuilder:rbac:groups=reservation.fluidos.eu,resources=reservations,verbs=get;list;watch;create;update;patch;delete -//+kubebuilder:rbac:groups=reservation.fluidos.eu,resources=reservations/status,verbs=get;update;patch -//+kubebuilder:rbac:groups=reservation.fluidos.eu,resources=reservations/finalizers,verbs=update -//+kubebuilder:rbac:groups=reservation.fluidos.eu,resources=contracts,verbs=get;list;watch;create;update;patch;delete -//+kubebuilder:rbac:groups=reservation.fluidos.eu,resources=contracts/status,verbs=get;update;patch -//+kubebuilder:rbac:groups=reservation.fluidos.eu,resources=contracts/finalizers,verbs=update -//+kubebuilder:rbac:groups=core,resources=configmaps,verbs=get;list;watch - -func (r *SolverReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { - log := ctrl.LoggerFrom(ctx, "solver", req.NamespacedName) - ctx = ctrl.LoggerInto(ctx, log) - //_ = log.FromContext(ctx) - - var solver nodecorev1alpha1.Solver - if err := r.Get(ctx, req.NamespacedName, &solver); client.IgnoreNotFound(err) != nil { - klog.Errorf("Error when getting Solver %s before reconcile: %s", req.NamespacedName, err) - return ctrl.Result{}, err - } else if err != nil { - klog.Infof("Solver %s not found, probably deleted", req.NamespacedName) - return ctrl.Result{}, nil - } - - if solver.Status.SolverPhase.Phase != nodecorev1alpha1.PhaseSolved && - solver.Status.SolverPhase.Phase != nodecorev1alpha1.PhaseTimeout && - solver.Status.SolverPhase.Phase != nodecorev1alpha1.PhaseFailed && - solver.Status.SolverPhase.Phase != nodecorev1alpha1.PhaseRunning && - solver.Status.SolverPhase.Phase != nodecorev1alpha1.PhaseIdle { - - solver.SetPhase(nodecorev1alpha1.PhaseIdle, "Solver initialized") - - if err := r.updateSolverStatus(ctx, &solver); err != nil { - klog.Errorf("Error when updating Solver %s status before reconcile: %s", req.NamespacedName, err) - return ctrl.Result{}, err - } - return ctrl.Result{}, nil - } - - klog.Infof("Reconciling Solver %s", req.NamespacedName) - - findCandidateStatus := solver.Status.FindCandidate - reserveAndBuyStatus := solver.Status.ReserveAndBuy - - // Check if the Solver has expired or failed, in this case do nothing and return - if solver.Status.SolverPhase.Phase == nodecorev1alpha1.PhaseFailed || - solver.Status.SolverPhase.Phase == nodecorev1alpha1.PhaseTimeout || - solver.Status.SolverPhase.Phase == nodecorev1alpha1.PhaseSolved { - return ctrl.Result{}, nil - } - - if solver.Spec.FindCandidate { - switch findCandidateStatus { - case nodecorev1alpha1.PhaseIdle: - // Search a matching PeeringCandidate if available - pc, err := r.searchPeeringCandidates(ctx, &solver) - if client.IgnoreNotFound(err) != nil { - klog.Errorf("Error when searching and booking a candidate for Solver %s: %s", req.NamespacedName.Name, err) - return ctrl.Result{}, err - } - - // If some PeeringCandidates are available, select one and book it - if len(pc) > 0 { - // If some PeeringCandidates are available, select one and book it - selectedPc, err := r.selectAndBookPeeringCandidate(ctx, &solver, pc) - if err != nil { - klog.Errorf("Error when selecting and booking a candidate for Solver %s: %s", req.NamespacedName.Name, err) - return ctrl.Result{}, err - } - klog.Infof("Solver %s has selected and booked candidate %s", req.NamespacedName.Name, selectedPc.Name) - solver.SetFindCandidateStatus(nodecorev1alpha1.PhaseSolved) - solver.SetPhase(nodecorev1alpha1.PhaseRunning, "Solver has found a candidate") - if err := r.updateSolverStatus(ctx, &solver); err != nil { - klog.Errorf("Error when updating Solver %s status: %s", req.NamespacedName, err) - return ctrl.Result{}, err - } - return ctrl.Result{}, nil - } - - // If no PeeringCandidate is available, Create a Discovery - klog.Infof("Solver %s has not found any candidate. Trying a Discovery", req.NamespacedName.Name) - solver.SetFindCandidateStatus(nodecorev1alpha1.PhaseRunning) - solver.SetPhase(nodecorev1alpha1.PhaseRunning, "Solver is trying a Discovery") - - // Update the Solver status - if err := r.updateSolverStatus(ctx, &solver); err != nil { - klog.Errorf("Error when updating Solver %s status: %s", req.NamespacedName, err) - return ctrl.Result{}, err - } - return ctrl.Result{}, nil - case nodecorev1alpha1.PhaseRunning: - // Check solver expiration - if tools.CheckExpiration(solver.Status.SolverPhase.LastChangeTime, flags.EXPIRATION_PHASE_RUNNING) { - klog.Infof("Solver %s has expired", req.NamespacedName.Name) - - solver.SetPhase(nodecorev1alpha1.PhaseTimeout, "Solver has expired before finding a candidate") - - if err := r.updateSolverStatus(ctx, &solver); err != nil { - klog.Errorf("Error when updating Solver %s status: %s", req.NamespacedName, err) - return ctrl.Result{}, err - } - return ctrl.Result{}, nil - } - - klog.Infof("Getting or creating Discovery for Solver %s", req.NamespacedName.Name) - discovery, err := r.createOrGetDiscovery(ctx, &solver) - if err != nil { - klog.Errorf("Error when creating or getting Discovery for Solver %s: %s", req.NamespacedName.Name, err) - return ctrl.Result{}, err - } - - common.DiscoveryStatusCheck(&solver, discovery) - - if err := r.updateSolverStatus(ctx, &solver); err != nil { - klog.Errorf("Error when updating Solver %s status: %s", req.NamespacedName, err) - return ctrl.Result{}, err - } - return ctrl.Result{}, nil - case nodecorev1alpha1.PhaseFailed: - klog.Infof("Solver %s has not found any candidate", req.NamespacedName.Name) - solver.SetPhase(nodecorev1alpha1.PhaseFailed, "Solver has not found any candidate") - if err := r.updateSolverStatus(ctx, &solver); err != nil { - klog.Errorf("Error when updating Solver %s status: %s", req.NamespacedName, err) - return ctrl.Result{}, err - } - return ctrl.Result{}, nil - case nodecorev1alpha1.PhaseSolved: - klog.Infof("Solver %s has found a candidate", req.NamespacedName.Name) - default: - solver.SetFindCandidateStatus(nodecorev1alpha1.PhaseIdle) - solver.SetPhase(nodecorev1alpha1.PhaseRunning, "Solver is running") - // Update the Solver status - if err := r.updateSolverStatus(ctx, &solver); err != nil { - klog.Errorf("Error when updating Solver %s status: %s", req.NamespacedName, err) - return ctrl.Result{}, err - } - return ctrl.Result{}, nil - } - } else { - klog.Infof("Solver %s Solved : No need to find a candidate", req.NamespacedName.Name) - solver.SetPhase(nodecorev1alpha1.PhaseSolved, "No need to find a candidate") - err := r.updateSolverStatus(ctx, &solver) - if err != nil { - klog.Errorf("Error when updating Solver %s status: %s", req.NamespacedName, err) - return ctrl.Result{}, err - } - return ctrl.Result{}, nil - } - - if solver.Spec.ReserveAndBuy { - if findCandidateStatus == nodecorev1alpha1.PhaseSolved { - klog.Infof("ReserveAndBuy %s", reserveAndBuyStatus) - switch reserveAndBuyStatus { - case nodecorev1alpha1.PhaseIdle: - var partition *reservationv1alpha1.Partition - klog.Infof("Creating the Reservation %s", req.NamespacedName.Name) - // Create the Reservation - var pc advertisementv1alpha1.PeeringCandidate - pcNamespaceName := types.NamespacedName{Name: solver.Status.PeeringCandidate.Name, Namespace: solver.Status.PeeringCandidate.Namespace} - - // Get the PeeringCandidate from the Solver - if err := r.Get(ctx, pcNamespaceName, &pc); err != nil { - klog.Errorf("Error when getting PeeringCandidate %s: %s", solver.Status.PeeringCandidate.Name, err) - return ctrl.Result{}, err - } - - if solver.Spec.Selector == nil { - // Forge the Partition - partition = resourceforge.ForgePartition(solver.Spec.Selector) - } - - // Get the NodeIdentity - nodeIdentity := getters.GetNodeIdentity(ctx, r.Client) - - // Forge the Reservation - reservation := resourceforge.ForgeReservation(pc, partition, *nodeIdentity) - if err := r.Client.Create(ctx, reservation); err != nil { - klog.Errorf("Error when creating Reservation for Solver %s: %s", solver.Name, err) - return ctrl.Result{}, err - } - - klog.Infof("Reservation %s created", reservation.Name) - - solver.SetReserveAndBuyStatus(nodecorev1alpha1.PhaseRunning) - solver.SetPhase(nodecorev1alpha1.PhaseRunning, "Reservation created") - if err := r.updateSolverStatus(ctx, &solver); err != nil { - klog.Errorf("Error when updating Solver %s status: %s", req.NamespacedName, err) - return ctrl.Result{}, err - } - return ctrl.Result{}, nil - case nodecorev1alpha1.PhaseRunning: - // Check solver expiration - if tools.CheckExpiration(solver.Status.SolverPhase.LastChangeTime, flags.EXPIRATION_PHASE_RUNNING) { - klog.Infof("Solver %s has expired", req.NamespacedName.Name) - solver.SetPhase(nodecorev1alpha1.PhaseTimeout, "Solver has expired before reserving the resources") - - if err := r.updateSolverStatus(ctx, &solver); err != nil { - klog.Errorf("Error when updating Solver %s status: %s", req.NamespacedName, err) - return ctrl.Result{}, err - } - return ctrl.Result{}, nil - } - - reservation := &reservationv1alpha1.Reservation{} - resNamespaceName := types.NamespacedName{Name: namings.ForgeReservationName(solver.Name), Namespace: flags.FLUIDOS_NAMESPACE} - - // Get the Reservation - err := r.Get(ctx, resNamespaceName, reservation) - if client.IgnoreNotFound(err) != nil { - klog.Errorf("Error when getting Reservation for Solver %s: %s", solver.Name, err) - return ctrl.Result{}, err - } - - common.ReservationStatusCheck(&solver, reservation) - - if err := r.updateSolverStatus(ctx, &solver); err != nil { - klog.Errorf("Error when updating Solver %s status: %s", req.NamespacedName, err) - return ctrl.Result{}, err - } - return ctrl.Result{}, nil - - case nodecorev1alpha1.PhaseFailed: - klog.Infof("Solver %s has failed to reserve and buy the resources", req.NamespacedName.Name) - solver.SetPhase(nodecorev1alpha1.PhaseFailed, "Solver has failed to reserve the resources") - if err := r.updateSolverStatus(ctx, &solver); err != nil { - klog.Errorf("Error when updating Solver %s status: %s", req.NamespacedName, err) - return ctrl.Result{}, err - } - return ctrl.Result{}, nil - case nodecorev1alpha1.PhaseSolved: - klog.Infof("Solver %s has reserved and purchased the resources", req.NamespacedName.Name) - default: - solver.SetReserveAndBuyStatus(nodecorev1alpha1.PhaseIdle) - // Update the Solver status - if err := r.updateSolverStatus(ctx, &solver); err != nil { - klog.Errorf("Error when updating Solver %s status: %s", req.NamespacedName, err) - return ctrl.Result{}, err - } - return ctrl.Result{}, nil - } - } - } else { - klog.Infof("Solver %s Solved : No need to reserve and buy the resources", req.NamespacedName.Name) - solver.SetPhase(nodecorev1alpha1.PhaseSolved, "No need to reserve and buy the resources") - err := r.updateSolverStatus(ctx, &solver) - if err != nil { - klog.Errorf("Error when updating Solver %s status: %s", req.NamespacedName, err) - return ctrl.Result{}, err - } - return ctrl.Result{}, nil - } - - if solver.Spec.EnstablishPeering { - if reserveAndBuyStatus == nodecorev1alpha1.PhaseSolved { - // Peering phase to be implemented - klog.Infof("Solver %s Solved : Peering phase to be implemented", req.NamespacedName.Name) - } - } else { - klog.Infof("Solver %s Solved : No need to enstablish a peering", req.NamespacedName.Name) - solver.SetPhase(nodecorev1alpha1.PhaseSolved, "No need to enstablish a peering") - err := r.updateSolverStatus(ctx, &solver) - if err != nil { - klog.Errorf("Error when updating Solver %s status: %s", req.NamespacedName, err) - return ctrl.Result{}, err - } - return ctrl.Result{}, nil - } - - return ctrl.Result{}, nil -} - -func (r *SolverReconciler) searchPeeringCandidates(ctx context.Context, solver *nodecorev1alpha1.Solver) ([]advertisementv1alpha1.PeeringCandidate, error) { - pc := advertisementv1alpha1.PeeringCandidateList{} - result := []advertisementv1alpha1.PeeringCandidate{} - - // Get the Flavour Selector from the Solver - selector := solver.Spec.Selector - - // Get the list of PeeringCandidates - if err := r.List(ctx, &pc); err != nil { - klog.Errorf("Error when listing PeeringCandidates: %s", err) - return nil, err - } - - // TODO: Maybe not needed - if len(pc.Items) == 0 { - klog.Infof("No PeeringCandidates found") - return nil, errors.NewNotFound(schema.GroupResource{Group: "advertisement", Resource: "PeeringCandidate"}, "PeeringCandidate") - } - - // Filter the reserved PeeringCandidates - filtered := []advertisementv1alpha1.PeeringCandidate{} - for _, p := range pc.Items { - if !p.Spec.Reserved && p.Spec.SolverID == "" { - filtered = append(filtered, p) - } - } - - // Filter the list of PeeringCandidates based on the Flavour Selector - for _, p := range filtered { - res := common.FilterPeeringCandidate(selector, &p) - if res { - result = append(result, p) - } - } - - return result, nil -} - -// TODO: unify this logic with the one of the discovery controller -func (r *SolverReconciler) selectAndBookPeeringCandidate(ctx context.Context, solver *nodecorev1alpha1.Solver, pcList []advertisementv1alpha1.PeeringCandidate) (*advertisementv1alpha1.PeeringCandidate, error) { - // Select the first PeeringCandidate - - var selected *advertisementv1alpha1.PeeringCandidate - - for _, pc := range pcList { - // Select the first PeeringCandidate that is not reserved - if !pc.Spec.Reserved && pc.Spec.SolverID == "" { - // Book the PeeringCandidate - pc.Spec.Reserved = true - pc.Spec.SolverID = solver.Name - - // Update the PeeringCandidate - if err := r.Update(ctx, &pc); err != nil { - klog.Errorf("Error when updating PeeringCandidate %s: %s", selected.Name, err) - continue - } - - // Getting the just updated PeeringCandidate - if err := r.Get(ctx, types.NamespacedName{Name: pc.Name, Namespace: pc.Namespace}, selected); err != nil { - klog.Errorf("Error when getting the reserved PeeringCandidate %s: %s", selected.Name, err) - continue - } - - // Check if the PeeringCandidate has been reserved correctly - if !pc.Spec.Reserved || pc.Spec.SolverID != solver.Name { - klog.Errorf("Error when reserving PeeringCandidate %s. Trying with another one", selected.Name) - continue - } - - break - } - } - - // check if a PeeringCandidate has been selected - if selected == nil || selected.Name == "" { - klog.Infof("No PeeringCandidate selected") - return nil, errors.NewNotFound(schema.GroupResource{Group: "advertisement", Resource: "PeeringCandidate"}, "PeeringCandidate") - } - - return selected, nil -} - -func (r *SolverReconciler) createOrGetDiscovery(ctx context.Context, solver *nodecorev1alpha1.Solver) (*advertisementv1alpha1.Discovery, error) { - discovery := &advertisementv1alpha1.Discovery{} - - // Get the Discovery - if err := r.Get(ctx, types.NamespacedName{Name: namings.ForgeDiscoveryName(solver.Name), Namespace: flags.FLUIDOS_NAMESPACE}, discovery); client.IgnoreNotFound(err) != nil { - klog.Errorf("Error when getting Discovery for Solver %s: %s", solver.Name, err) - return nil, err - } else if err != nil { - // Create the Discovery - discovery := resourceforge.ForgeDiscovery(solver.Spec.Selector, solver.Name) - if err := r.Client.Create(ctx, discovery); err != nil { - klog.Errorf("Error when creating Discovery for Solver %s: %s", solver.Name, err) - return nil, err - } - } - return discovery, nil -} - -func (r *SolverReconciler) updateSolverStatus(ctx context.Context, solver *nodecorev1alpha1.Solver) error { - return r.Status().Update(ctx, solver) -} - -// SetupWithManager sets up the controller with the Manager. -func (r *SolverReconciler) SetupWithManager(mgr ctrl.Manager) error { - return ctrl.NewControllerManagedBy(mgr). - For(&nodecorev1alpha1.Solver{}). - Watches(&advertisementv1alpha1.Discovery{}, handler.EnqueueRequestsFromMapFunc( - r.discoveryToSolver, - ), builder.WithPredicates(discoveryPredicate())). - Watches(&reservationv1alpha1.Reservation{}, handler.EnqueueRequestsFromMapFunc( - r.reservationToSolver, - ), builder.WithPredicates(reservationPredicate())). - Complete(r) -} - -func discoveryPredicate() predicate.Predicate { - return predicate.Funcs{ - UpdateFunc: func(e event.UpdateEvent) bool { - return e.ObjectNew.(*advertisementv1alpha1.Discovery).Status.Phase.Phase == nodecorev1alpha1.PhaseSolved || - e.ObjectNew.(*advertisementv1alpha1.Discovery).Status.Phase.Phase == nodecorev1alpha1.PhaseFailed - }, - } -} - -func reservationPredicate() predicate.Predicate { - return predicate.Funcs{ - UpdateFunc: func(e event.UpdateEvent) bool { - return e.ObjectNew.(*reservationv1alpha1.Reservation).Status.Phase.Phase == nodecorev1alpha1.PhaseSolved || - e.ObjectNew.(*reservationv1alpha1.Reservation).Status.Phase.Phase == nodecorev1alpha1.PhaseFailed - }, - } -} - -func (r *SolverReconciler) discoveryToSolver(ctx context.Context, o client.Object) []reconcile.Request { - solverName := namings.RetrieveSolverNameFromDiscovery(o.GetName()) - return []reconcile.Request{ - { - NamespacedName: types.NamespacedName{ - Name: solverName, - Namespace: flags.FLUIDOS_NAMESPACE, - }, - }, - } -} - -func (r *SolverReconciler) reservationToSolver(ctx context.Context, o client.Object) []reconcile.Request { - solverName := namings.RetrieveSolverNameFromReservation(o.GetName()) - return []reconcile.Request{ - { - NamespacedName: types.NamespacedName{ - Name: solverName, - Namespace: flags.FLUIDOS_NAMESPACE, - }, - }, - } -} diff --git a/pkg/rear-manager/utils.go b/pkg/rear-manager/utils.go deleted file mode 100644 index f84f396..0000000 --- a/pkg/rear-manager/utils.go +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2022-2023 FLUIDOS Project -// -// 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 rearmanager diff --git a/pkg/utils/common/common.go b/pkg/utils/common/common.go deleted file mode 100644 index d10f540..0000000 --- a/pkg/utils/common/common.go +++ /dev/null @@ -1,211 +0,0 @@ -// Copyright 2022-2023 FLUIDOS Project -// -// 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 common - -import ( - "fmt" - - "k8s.io/klog/v2" - - advertisementv1alpha1 "github.com/fluidos-project/node/apis/advertisement/v1alpha1" - nodecorev1alpha1 "github.com/fluidos-project/node/apis/nodecore/v1alpha1" - reservationv1alpha1 "github.com/fluidos-project/node/apis/reservation/v1alpha1" - "github.com/fluidos-project/node/pkg/utils/models" - "github.com/fluidos-project/node/pkg/utils/namings" - "github.com/fluidos-project/node/pkg/utils/parseutil" -) - -// FilterFlavoursBySelector returns the Flavour CRs in the cluster that match the selector -func FilterFlavoursBySelector(flavours []nodecorev1alpha1.Flavour, selector *models.Selector) ([]nodecorev1alpha1.Flavour, error) { - var flavoursSelected []nodecorev1alpha1.Flavour - - // Get the Flavours that match the selector - for _, f := range flavours { - if string(f.Spec.Type) == selector.FlavourType { - // filter function - if FilterFlavour(selector, f) { - flavoursSelected = append(flavoursSelected, f) - } - - } - } - - return flavoursSelected, nil -} - -// filterFlavour filters the Flavour CRs in the cluster that match the selector -func FilterFlavour(selector *models.Selector, f nodecorev1alpha1.Flavour) bool { - - if f.Spec.Characteristics.Architecture != selector.Architecture { - klog.Infof("Flavour %s has different architecture: %s - Selector: %s", f.Name, f.Spec.Characteristics.Architecture, selector.Architecture) - return false - } - - if selector.MatchSelector != nil { - if selector.MatchSelector.Cpu.CmpInt64(0) == 0 && f.Spec.Characteristics.Cpu.Cmp(selector.MatchSelector.Cpu) != 0 { - klog.Infof("MatchSelector Cpu: %d - Flavour Cpu: %d", selector.MatchSelector.Cpu, f.Spec.Characteristics.Cpu) - return false - } - - if selector.MatchSelector.Memory.CmpInt64(0) == 0 && f.Spec.Characteristics.Memory.Cmp(selector.MatchSelector.Memory) != 0 { - klog.Infof("MatchSelector Memory: %d - Flavour Memory: %d", selector.MatchSelector.Memory, f.Spec.Characteristics.Memory) - return false - } - - if selector.MatchSelector.EphemeralStorage.CmpInt64(0) == 0 && f.Spec.Characteristics.EphemeralStorage.Cmp(selector.MatchSelector.EphemeralStorage) != 0 { - klog.Infof("MatchSelector EphemeralStorage: %d - Flavour EphemeralStorage: %d", selector.MatchSelector.EphemeralStorage, f.Spec.Characteristics.EphemeralStorage) - return false - } - - if selector.MatchSelector.Storage.CmpInt64(0) == 0 && f.Spec.Characteristics.PersistentStorage.Cmp(selector.MatchSelector.Storage) != 0 { - klog.Infof("MatchSelector Storage: %d - Flavour Storage: %d", selector.MatchSelector.Storage, f.Spec.Characteristics.PersistentStorage) - return false - } - - if selector.MatchSelector.Gpu.CmpInt64(0) == 0 && f.Spec.Characteristics.Gpu.Cmp(selector.MatchSelector.Gpu) != 0 { - klog.Infof("MatchSelector GPU: %d - Flavour GPU: %d", selector.MatchSelector.Gpu, f.Spec.Characteristics.Gpu) - return false - } - } - - if selector.RangeSelector != nil && selector.MatchSelector == nil { - - if selector.RangeSelector.MinCpu.CmpInt64(0) != 0 && f.Spec.Characteristics.Cpu.Cmp(selector.RangeSelector.MinCpu) < 0 { - klog.Infof("RangeSelector MinCpu: %d - Flavour Cpu: %d", selector.RangeSelector.MinCpu, f.Spec.Characteristics.Cpu) - return false - } - - if selector.RangeSelector.MinMemory.CmpInt64(0) != 0 && f.Spec.Characteristics.Memory.Cmp(selector.RangeSelector.MinMemory) < 0 { - klog.Infof("RangeSelector MinMemory: %d - Flavour Memory: %d", selector.RangeSelector.MinMemory, f.Spec.Characteristics.Memory) - return false - } - - if selector.RangeSelector.MinEph.CmpInt64(0) != 0 && f.Spec.Characteristics.EphemeralStorage.Cmp(selector.RangeSelector.MinEph) < 0 { - klog.Infof("RangeSelector MinEph: %d - Flavour EphemeralStorage: %d", selector.RangeSelector.MinEph, f.Spec.Characteristics.EphemeralStorage) - return false - } - - if selector.RangeSelector.MinStorage.CmpInt64(0) != 0 && f.Spec.Characteristics.PersistentStorage.Cmp(selector.RangeSelector.MinStorage) < 0 { - klog.Infof("RangeSelector MinStorage: %d - Flavour Storage: %d", selector.RangeSelector.MinStorage, f.Spec.Characteristics.PersistentStorage) - return false - } - - if selector.RangeSelector.MinGpu.CmpInt64(0) != 0 && f.Spec.Characteristics.Gpu.Cmp(selector.RangeSelector.MinGpu) < 0 { - return false - } - - if selector.RangeSelector.MaxCpu.CmpInt64(0) != 0 && f.Spec.Characteristics.Cpu.Cmp(selector.RangeSelector.MaxCpu) > 0 { - return false - } - - if selector.RangeSelector.MaxMemory.CmpInt64(0) != 0 && f.Spec.Characteristics.Memory.Cmp(selector.RangeSelector.MaxMemory) > 0 { - return false - } - - if selector.RangeSelector.MaxEph.CmpInt64(0) != 0 && f.Spec.Characteristics.EphemeralStorage.Cmp(selector.RangeSelector.MaxEph) > 0 { - return false - } - - if selector.RangeSelector.MaxStorage.CmpInt64(0) != 0 && f.Spec.Characteristics.PersistentStorage.Cmp(selector.RangeSelector.MaxStorage) > 0 { - return false - } - - if selector.RangeSelector.MaxGpu.CmpInt64(0) != 0 && f.Spec.Characteristics.Gpu.Cmp(selector.RangeSelector.MaxGpu) > 0 { - return false - } - } - - return true -} - -// FilterPeeringCandidate filters the peering candidate based on the solver's flavour selector -func FilterPeeringCandidate(selector *nodecorev1alpha1.FlavourSelector, pc *advertisementv1alpha1.PeeringCandidate) bool { - s := parseutil.ParseFlavourSelector(selector) - return FilterFlavour(s, pc.Spec.Flavour) -} - -// CheckSelector ia a func to check if the syntax of the Selector is right. -// Strict and range syntax cannot be used together -func CheckSelector(selector *models.Selector) error { - - if selector.MatchSelector != nil && selector.RangeSelector != nil { - return fmt.Errorf("selector syntax error: strict and range syntax cannot be used together") - } - return nil -} - -// SOLVER PHASE SETTERS - -// DiscoveryStatusCheck checks the status of the discovery -func DiscoveryStatusCheck(solver *nodecorev1alpha1.Solver, discovery *advertisementv1alpha1.Discovery) { - if discovery.Status.Phase.Phase == nodecorev1alpha1.PhaseSolved { - klog.Infof("Discovery %s has found a candidate: %s", discovery.Name, discovery.Status.PeeringCandidate) - solver.Status.FindCandidate = nodecorev1alpha1.PhaseSolved - solver.Status.PeeringCandidate = discovery.Status.PeeringCandidate - solver.Status.DiscoveryPhase = nodecorev1alpha1.PhaseSolved - solver.SetPhase(nodecorev1alpha1.PhaseRunning, "Solver has found a candidate") - } - if discovery.Status.Phase.Phase == nodecorev1alpha1.PhaseFailed { - klog.Infof("Discovery %s has failed. Reason: %s", discovery.Name, discovery.Status.Phase.Message) - klog.Infof("Peering candidate not found, Solver %s failed", solver.Name) - solver.Status.FindCandidate = nodecorev1alpha1.PhaseFailed - solver.Status.DiscoveryPhase = nodecorev1alpha1.PhaseFailed - } - if discovery.Status.Phase.Phase == nodecorev1alpha1.PhaseTimeout { - klog.Infof("Discovery %s has timed out", discovery.Name) - solver.Status.FindCandidate = nodecorev1alpha1.PhaseTimeout - solver.Status.DiscoveryPhase = nodecorev1alpha1.PhaseTimeout - solver.SetPhase(nodecorev1alpha1.PhaseTimeout, "Discovery has expired before finding a candidate") - } - if discovery.Status.Phase.Phase == nodecorev1alpha1.PhaseRunning { - klog.Infof("Discovery %s is running", discovery.Name) - solver.SetDiscoveryStatus(nodecorev1alpha1.PhaseRunning) - } - if discovery.Status.Phase.Phase == nodecorev1alpha1.PhaseIdle { - klog.Infof("Discovery %s is idle", discovery.Name) - solver.SetDiscoveryStatus(nodecorev1alpha1.PhaseIdle) - } -} - -func ReservationStatusCheck(solver *nodecorev1alpha1.Solver, reservation *reservationv1alpha1.Reservation) { - klog.Infof("Reservation %s is in phase %s", reservation.Name, reservation.Status.Phase.Phase) - flavourName := namings.RetrieveFlavourNameFromPC(reservation.Spec.PeeringCandidate.Name) - if reservation.Status.Phase.Phase == nodecorev1alpha1.PhaseSolved { - klog.Infof("Reservation %s has reserved and purchase the flavour %s", reservation.Name, flavourName) - solver.Status.ReservationPhase = nodecorev1alpha1.PhaseSolved - solver.Status.ReserveAndBuy = nodecorev1alpha1.PhaseSolved - solver.SetPhase(nodecorev1alpha1.PhaseRunning, "Reservation: Flavour reserved and purchased") - } - if reservation.Status.Phase.Phase == nodecorev1alpha1.PhaseFailed { - klog.Infof("Reservation %s has failed. Reason: %s", reservation.Name, reservation.Status.Phase.Message) - solver.Status.ReservationPhase = nodecorev1alpha1.PhaseFailed - solver.Status.ReserveAndBuy = nodecorev1alpha1.PhaseFailed - solver.SetPhase(nodecorev1alpha1.PhaseFailed, "Reservation: Flavour reservation and purchase failed") - } - if reservation.Status.Phase.Phase == nodecorev1alpha1.PhaseRunning { - if reservation.Status.ReservePhase == nodecorev1alpha1.PhaseRunning { - klog.Infof("Reservation %s is running", reservation.Name) - solver.SetPhase(nodecorev1alpha1.PhaseRunning, "Reservation: Reserve is running") - } - if reservation.Status.PurchasePhase == nodecorev1alpha1.PhaseRunning { - klog.Infof("Purchasing %s is running", reservation.Name) - solver.SetPhase(nodecorev1alpha1.PhaseRunning, "Reservation: Purchase is running") - } - } - if reservation.Status.Phase.Phase == nodecorev1alpha1.PhaseIdle { - klog.Infof("Reservation %s is idle", reservation.Name) - solver.SetReservationStatus(nodecorev1alpha1.PhaseIdle) - } -} diff --git a/pkg/utils/common/doc.go b/pkg/utils/common/doc.go deleted file mode 100644 index c2ad6de..0000000 --- a/pkg/utils/common/doc.go +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2022-2023 FLUIDOS Project -// -// 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 common contains common functions used by other packagess -package common diff --git a/pkg/utils/consts/consts.go b/pkg/utils/consts/consts.go deleted file mode 100644 index 99fd8bb..0000000 --- a/pkg/utils/consts/consts.go +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2022-2023 FLUIDOS Project -// -// 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 consts - -const ( - NETWORK_CONFIG_MAP_NAME = "fluidos-network-manager-config" - NODE_IDENTITY_CONFIG_MAP_NAME = "fluidos-network-manager-identity" - LIQO_CLUSTERID_CONFIGMAP_NAME = "liqo-clusterid-configmap" - LIQO_NAMESPACE = "liqo" -) diff --git a/pkg/utils/consts/doc.go b/pkg/utils/consts/doc.go deleted file mode 100644 index e8a786b..0000000 --- a/pkg/utils/consts/doc.go +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2022-2023 FLUIDOS Project -// -// 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 consts contains the constants used in the FLUIDOS and some miscellaneous ones. -package consts diff --git a/pkg/utils/doc.go b/pkg/utils/doc.go deleted file mode 100644 index 42eeac0..0000000 --- a/pkg/utils/doc.go +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2022-2023 FLUIDOS Project -// -// 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 utils contains shared utility methods for the FLUIDOS environment. -package utils diff --git a/pkg/utils/flags/doc.go b/pkg/utils/flags/doc.go deleted file mode 100644 index d86d7fb..0000000 --- a/pkg/utils/flags/doc.go +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2022-2023 FLUIDOS Project -// -// 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 flags provides a set of flags used by the FLUIDOS node. -package flags diff --git a/pkg/utils/flags/flags.go b/pkg/utils/flags/flags.go deleted file mode 100644 index 32eddd6..0000000 --- a/pkg/utils/flags/flags.go +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2022-2023 FLUIDOS Project -// -// 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 flags - -import "time" - -// NAMESPACES flags -var ( - FLUIDOS_NAMESPACE string = "fluidos" -) - -// EXPIRATION flags -var ( - EXPIRATION_PHASE_RUNNING = 2 * time.Minute - EXPIRATION_SOLVER = 5 * time.Minute - EXPIRATION_TRANSACTION = 20 * time.Second - EXPIRATION_CONTRACT = 365 * 24 * time.Hour - REFRESH_CACHE_INTERVAL = 20 * time.Second - LIQO_CHECK_INTERVAL = 20 * time.Second -) - -var ( - HTTP_PORT string - GRPC_PORT string - RESOURCE_NODE_LABEL string -) - -var ( - RESOURCE_TYPE string - AMOUNT string - CURRENCY string - PERIOD string - CPU_MIN string - MEMORY_MIN string - CPU_STEP string - MEMORY_STEP string - MIN_COUNT int64 - MAX_COUNT int64 -) diff --git a/pkg/utils/getters/getters.go b/pkg/utils/getters/getters.go deleted file mode 100644 index 6e8f121..0000000 --- a/pkg/utils/getters/getters.go +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright 2022-2023 FLUIDOS Project -// -// 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 getters - -import ( - "context" - "strings" - - corev1 "k8s.io/api/core/v1" - "k8s.io/klog/v2" - "sigs.k8s.io/controller-runtime/pkg/client" - - nodecorev1alpha1 "github.com/fluidos-project/node/apis/nodecore/v1alpha1" - "github.com/fluidos-project/node/pkg/utils/consts" - "github.com/fluidos-project/node/pkg/utils/flags" - "k8s.io/apimachinery/pkg/types" -) - -func GetNodeIdentity(ctx context.Context, cl client.Client) *nodecorev1alpha1.NodeIdentity { - - cm := &corev1.ConfigMap{} - - // Get the node identity - err := cl.Get(ctx, types.NamespacedName{ - Name: consts.NODE_IDENTITY_CONFIG_MAP_NAME, - Namespace: flags.FLUIDOS_NAMESPACE, - }, cm) - if err != nil { - klog.Errorf("Error getting the configmap: %s", err) - return nil - } - - return &nodecorev1alpha1.NodeIdentity{ - NodeID: cm.Data["nodeID"], - Domain: cm.Data["domain"], - IP: cm.Data["ip"], - } -} - -// This function retrieves the list of local providers ip addresses from the Network Manager configMap -func GetLocalProviders(ctx context.Context, cl client.Client) []string { - cm := &corev1.ConfigMap{} - - // Get the configmap - err := cl.Get(ctx, types.NamespacedName{ - Name: consts.NETWORK_CONFIG_MAP_NAME, - Namespace: flags.FLUIDOS_NAMESPACE, - }, cm) - if err != nil { - klog.Errorf("Error getting the configmap: %s", err) - return nil - } - return strings.Split(cm.Data["local"], ",") -} diff --git a/pkg/utils/models/doc.go b/pkg/utils/models/doc.go deleted file mode 100644 index 3c61a24..0000000 --- a/pkg/utils/models/doc.go +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2022-2023 FLUIDOS Project -// -// 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 models contains shared models for the FLUIDOS environment. -package models diff --git a/pkg/utils/models/gateway.go b/pkg/utils/models/gateway.go deleted file mode 100644 index 364a03b..0000000 --- a/pkg/utils/models/gateway.go +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2022-2023 FLUIDOS Project -// -// 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 models - -// PurchaseRequest is the request model for purchasing a Flavour -type PurchaseRequest struct { - TransactionID string `json:"transactionID"` -} - -// ResponsePurchase contain information after purchase a Flavour -type ResponsePurchase struct { - Contract Contract `json:"contract"` - Status string `json:"status"` -} - -// ReserveRequest is the request model for reserving a Flavour -type ReserveRequest struct { - FlavourID string `json:"flavourID"` - Buyer NodeIdentity `json:"buyerID"` - ClusterID string `json:"clusterID"` - Partition *Partition `json:"partition,omitempty"` -} diff --git a/pkg/utils/models/local-resource-manager.go b/pkg/utils/models/local-resource-manager.go deleted file mode 100644 index ac78cc2..0000000 --- a/pkg/utils/models/local-resource-manager.go +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2022-2023 FLUIDOS Project -// -// 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 models - -import ( - "k8s.io/apimachinery/pkg/api/resource" -) - -// NodeInfo represents a node and its resources -type NodeInfo struct { - UID string `json:"uid"` - Name string `json:"name"` - Architecture string `json:"architecture"` - OperatingSystem string `json:"os"` - ResourceMetrics ResourceMetrics `json:"resources"` -} - -// ResourceMetrics represents resources of a certain node -type ResourceMetrics struct { - CPUTotal resource.Quantity `json:"totalCPU"` - CPUAvailable resource.Quantity `json:"availableCPU"` - MemoryTotal resource.Quantity `json:"totalMemory"` - MemoryAvailable resource.Quantity `json:"availableMemory"` - EphemeralStorage resource.Quantity `json:"ephemeralStorage"` -} diff --git a/pkg/utils/models/models.go b/pkg/utils/models/models.go deleted file mode 100644 index a741faf..0000000 --- a/pkg/utils/models/models.go +++ /dev/null @@ -1,114 +0,0 @@ -// Copyright 2022-2023 FLUIDOS Project -// -// 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 models - -import ( - "time" - - "k8s.io/apimachinery/pkg/api/resource" -) - -// Flavour represents a Flavour object with its characteristics and policies. -type Flavour struct { - FlavourID string `json:"flavourID"` - ProviderID string `json:"providerID"` - Type string `json:"type"` - Characteristics Characteristics `json:"characteristics"` - Policy Policy `json:"policy"` - Owner NodeIdentity `json:"owner"` - Price Price `json:"price"` - ExpirationTime time.Time `json:"expirationTime"` - OptionalFields OptionalFields `json:"optionalFields"` -} - -// Characteristics represents the characteristics of a Flavour, such as CPU and RAM. -type Characteristics struct { - CPU resource.Quantity `json:"cpu,omitempty"` - Memory resource.Quantity `json:"memory,omitempty"` - PersistentStorage resource.Quantity `json:"storage,omitempty"` - EphemeralStorage resource.Quantity `json:"ephemeralStorage,omitempty"` - Gpu resource.Quantity `json:"gpu,omitempty"` - Architecture string `json:"architecture,omitempty"` -} - -// Policy represents the policy associated with a Flavour, which can be either Partitionable or Aggregatable. -type Policy struct { - Partitionable *Partitionable `json:"partitionable,omitempty"` - Aggregatable *Aggregatable `json:"aggregatable,omitempty"` -} - -// Partitionable represents the partitioning properties of a Flavour, such as the minimum and incremental values of CPU and RAM. -type Partitionable struct { - CPUMinimum resource.Quantity `json:"cpuMinimum"` - MemoryMinimum resource.Quantity `json:"memoryMinimum"` - CPUStep resource.Quantity `json:"cpuStep"` - MemoryStep resource.Quantity `json:"memoryStep"` -} - -// Aggregatable represents the aggregation properties of a Flavour, such as the minimum instance count. -type Aggregatable struct { - MinCount int `json:"minCount"` - MaxCount int `json:"maxCount"` -} - -// NodeIdentity represents the owner of a Flavour, with associated ID, IP, and domain name. -type NodeIdentity struct { - NodeID string `json:"ID"` - IP string `json:"IP"` - Domain string `json:"domain"` -} - -// Price represents the price of a Flavour, with the amount, currency, and period associated. -type Price struct { - Amount string `json:"amount"` - Currency string `json:"currency"` - Period string `json:"period"` -} - -// OptionalFields represents the optional fields of a Flavour, such as availability. -type OptionalFields struct { - Availability bool `json:"availability,omitempty"` - WorkerID string `json:"workerID"` -} - -type Selector struct { - FlavourType string `json:"type,omitempty"` - Architecture string `json:"architecture,omitempty"` - RangeSelector *RangeSelector `json:"rangeSelector,omitempty"` - MatchSelector *MatchSelector `json:"matchSelector,omitempty"` -} - -// MatchSelector represents the criteria for selecting Flavours through a strict match. -type MatchSelector struct { - Cpu resource.Quantity `json:"cpu,omitempty"` - Memory resource.Quantity `json:"memory,omitempty"` - Storage resource.Quantity `json:"storage,omitempty"` - EphemeralStorage resource.Quantity `json:"ephemeralStorage,omitempty"` - Gpu resource.Quantity `json:"gpu,omitempty"` -} - -// RangeSelector represents the criteria for selecting Flavours through a range. -type RangeSelector struct { - MinCpu resource.Quantity `json:"minCpu,omitempty"` - MinMemory resource.Quantity `json:"minMemory,omitempty"` - MinStorage resource.Quantity `json:"minStorage,omitempty"` - MinEph resource.Quantity `json:"minEph,omitempty"` - MinGpu resource.Quantity `json:"minGpu,omitempty"` - MaxCpu resource.Quantity `json:"maxCpu,omitempty"` - MaxMemory resource.Quantity `json:"maxMemory,omitempty"` - MaxStorage resource.Quantity `json:"maxStorage,omitempty"` - MaxEph resource.Quantity `json:"maxEph,omitempty"` - MaxGpu resource.Quantity `json:"maxGpu,omitempty"` -} diff --git a/pkg/utils/models/reservation.go b/pkg/utils/models/reservation.go deleted file mode 100644 index 7b7e5af..0000000 --- a/pkg/utils/models/reservation.go +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2022-2023 FLUIDOS Project -// -// 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 models - -import "k8s.io/apimachinery/pkg/api/resource" - -// Partition represents the partitioning properties of a Flavour -type Partition struct { - Architecture string `json:"architecture"` - Cpu resource.Quantity `json:"cpu"` - Memory resource.Quantity `json:"memory"` - EphemeralStorage resource.Quantity `json:"ephemeral-storage,omitempty"` - Gpu resource.Quantity `json:"gpu,omitempty"` - Storage resource.Quantity `json:"storage,omitempty"` -} - -// Transaction contains information regarding the transaction for a flavour -type Transaction struct { - TransactionID string `json:"transactionID"` - FlavourID string `json:"flavourID"` - Partition *Partition `json:"partition,omitempty"` - Buyer NodeIdentity `json:"buyer"` - ClusterID string `json:"clusterID"` - StartTime string `json:"startTime"` -} - -// Contract represents a Contract object with its characteristics -type Contract struct { - ContractID string `json:"contractID"` - TransactionID string `json:"transactionID"` - Flavour Flavour `json:"flavour"` - Buyer NodeIdentity `json:"buyerID"` - BuyerClusterID string `json:"buyerClusterID"` - Seller NodeIdentity `json:"seller"` - SellerCredentials LiqoCredentials `json:"sellerCredentials"` - ExpirationTime string `json:"expirationTime,omitempty"` - ExtraInformation map[string]string `json:"extraInformation,omitempty"` - Partition *Partition `json:"partition,omitempty"` -} - -// LiqoCredentials contains the credentials of a Liqo cluster to enstablish a peering. -type LiqoCredentials struct { - ClusterID string `json:"clusterID"` - ClusterName string `json:"clusterName"` - Token string `json:"token"` - Endpoint string `json:"endpoint"` -} diff --git a/pkg/utils/namings/doc.go b/pkg/utils/namings/doc.go deleted file mode 100644 index c53c480..0000000 --- a/pkg/utils/namings/doc.go +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2022-2023 FLUIDOS Project -// -// 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 namings contains different naming functions -// used into the FLUIDOS environment. -package namings diff --git a/pkg/utils/namings/namings.go b/pkg/utils/namings/namings.go deleted file mode 100644 index 3586ad7..0000000 --- a/pkg/utils/namings/namings.go +++ /dev/null @@ -1,106 +0,0 @@ -// Copyright 2022-2023 FLUIDOS Project -// -// 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 namings - -import ( - "crypto/rand" - "crypto/sha256" - "encoding/hex" - "fmt" - "strings" - "time" - - "github.com/fluidos-project/node/pkg/utils/flags" - "k8s.io/klog/v2" -) - -// ForgeContractName creates a name for the Contract CR -func ForgeContractName(flavourID string) string { - hash := ForgeHashString(flavourID, 4) - return fmt.Sprintf("contract-%s-%s", flavourID, hash) -} - -// ForgePeeringCandidateName generates a name for the PeeringCandidate -func ForgePeeringCandidateName(flavourID string) string { - return fmt.Sprintf("peeringcandidate-%s", flavourID) -} - -// ForgeReservationName generates a name for the Reservation -func ForgeReservationName(solverID string) string { - return fmt.Sprintf("reservation-%s", solverID) -} - -// ForgeFlavourName returns the name of the flavour following the pattern Domain-Type-rand(4) -func ForgeFlavourName(WorkerID, domain string) string { - rand, err := ForgeRandomString() - if err != nil { - klog.Errorf("Error when generating random string: %s", err) - } - - return domain + "-" + flags.RESOURCE_TYPE + "-" + ForgeHashString(WorkerID+rand, 8) -} - -// ForgeDiscoveryName returns the name of the discovery following the pattern solverID-discovery -func ForgeDiscoveryName(solverID string) string { - return fmt.Sprintf("discovery-%s", solverID) -} - -func RetrieveSolverNameFromDiscovery(discoveryName string) string { - return strings.TrimPrefix(discoveryName, "discovery-") -} - -func RetrieveSolverNameFromReservation(reservationName string) string { - return strings.TrimPrefix(reservationName, "reservation-") -} - -// ForgeTransactionID Generates a unique transaction ID using the current timestamp -func ForgeTransactionID() (string, error) { - // Convert the random bytes to a hexadecimal string - transactionID, err := ForgeRandomString() - if err != nil { - return "", err - } - - // Add a timestamp to ensure uniqueness - transactionID = fmt.Sprintf("%s-%d", transactionID, time.Now().UnixNano()) - - return transactionID, nil -} - -// RetrieveFlavourNameFromPC generates a name for the Flavour from the PeeringCandidate -func RetrieveFlavourNameFromPC(pcName string) string { - return strings.TrimPrefix(pcName, "peeringcandidate-") -} - -// ForgePrefixClientID generates a prefix for the client ID -func ForgeRandomString() (string, error) { - randomBytes := make([]byte, 16) - _, err := rand.Read(randomBytes) - if err != nil { - return "", err - } - randomString := hex.EncodeToString(randomBytes) - - return randomString, nil -} - -// ForgeHashString computes SHA-256 Hash of the NodeUID -func ForgeHashString(input string, lenght int) string { - hash := sha256.Sum256([]byte(input)) - hashString := hex.EncodeToString(hash[:]) - uniqueString := hashString[:lenght] - - return uniqueString -} diff --git a/pkg/utils/parseutil/doc.go b/pkg/utils/parseutil/doc.go deleted file mode 100644 index 91a9c80..0000000 --- a/pkg/utils/parseutil/doc.go +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2022-2023 FLUIDOS Project -// -// 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 parseutil provides utility functions for parsing operations. -package parseutil diff --git a/pkg/utils/parseutil/parseutil.go b/pkg/utils/parseutil/parseutil.go deleted file mode 100644 index 9d46037..0000000 --- a/pkg/utils/parseutil/parseutil.go +++ /dev/null @@ -1,160 +0,0 @@ -// Copyright 2022-2023 FLUIDOS Project -// -// 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 parseutil - -import ( - nodecorev1alpha1 "github.com/fluidos-project/node/apis/nodecore/v1alpha1" - reservationv1alpha1 "github.com/fluidos-project/node/apis/reservation/v1alpha1" - "github.com/fluidos-project/node/pkg/utils/models" - "k8s.io/apimachinery/pkg/api/resource" -) - -// ParseFlavourSelector parses FlavourSelector into a Selector -func ParseFlavourSelector(selector *nodecorev1alpha1.FlavourSelector) (s *models.Selector) { - - s.Architecture = selector.Architecture - s.FlavourType = string(selector.FlavourType) - - if selector.MatchSelector != nil { - s.MatchSelector = &models.MatchSelector{ - Cpu: selector.MatchSelector.Cpu, - Memory: selector.MatchSelector.Memory, - EphemeralStorage: selector.MatchSelector.EphemeralStorage, - Storage: selector.MatchSelector.Storage, - Gpu: selector.MatchSelector.Gpu, - } - } - - if selector.RangeSelector != nil { - s.RangeSelector = &models.RangeSelector{ - MinCpu: selector.RangeSelector.MinCpu, - MinMemory: selector.RangeSelector.MinMemory, - MinEph: selector.RangeSelector.MinEph, - MinStorage: selector.RangeSelector.MinStorage, - MinGpu: selector.RangeSelector.MinGpu, - MaxCpu: selector.RangeSelector.MaxCpu, - MaxMemory: selector.RangeSelector.MaxMemory, - MaxEph: selector.RangeSelector.MaxEph, - MaxStorage: selector.RangeSelector.MaxStorage, - MaxGpu: selector.RangeSelector.MaxGpu, - } - } - - return -} - -func ParsePartition(partition *reservationv1alpha1.Partition) *models.Partition { - return &models.Partition{ - Cpu: partition.Cpu, - Memory: partition.Memory, - EphemeralStorage: partition.EphemeralStorage, - Storage: partition.Storage, - Gpu: partition.Gpu, - } -} - -func ParsePartitionFromObj(partition *models.Partition) *reservationv1alpha1.Partition { - return &reservationv1alpha1.Partition{ - Architecture: partition.Architecture, - Cpu: partition.Cpu, - Memory: partition.Memory, - Gpu: partition.Gpu, - Storage: partition.Storage, - EphemeralStorage: partition.EphemeralStorage, - } -} - -func ParseNodeIdentity(node nodecorev1alpha1.NodeIdentity) models.NodeIdentity { - return models.NodeIdentity{ - NodeID: node.NodeID, - IP: node.IP, - Domain: node.Domain, - } -} - -// ParseFlavourObject creates a Flavour Object from a Flavour CR -func ParseFlavour(flavour nodecorev1alpha1.Flavour) models.Flavour { - return models.Flavour{ - FlavourID: flavour.Name, - Type: string(flavour.Spec.Type), - ProviderID: flavour.Spec.ProviderID, - Characteristics: models.Characteristics{ - CPU: flavour.Spec.Characteristics.Cpu, - Memory: flavour.Spec.Characteristics.Memory, - PersistentStorage: flavour.Spec.Characteristics.PersistentStorage, - EphemeralStorage: flavour.Spec.Characteristics.EphemeralStorage, - Gpu: flavour.Spec.Characteristics.Gpu, - }, - Owner: ParseNodeIdentity(flavour.Spec.Owner), - Policy: models.Policy{ - Partitionable: func() *models.Partitionable { - if flavour.Spec.Policy.Partitionable != nil { - return &models.Partitionable{ - CPUMinimum: flavour.Spec.Policy.Partitionable.CpuMin, - MemoryMinimum: flavour.Spec.Policy.Partitionable.MemoryMin, - CPUStep: flavour.Spec.Policy.Partitionable.CpuStep, - MemoryStep: flavour.Spec.Policy.Partitionable.MemoryStep, - } - } - return nil - }(), - Aggregatable: func() *models.Aggregatable { - if flavour.Spec.Policy.Aggregatable != nil { - return &models.Aggregatable{ - MinCount: flavour.Spec.Policy.Aggregatable.MinCount, - MaxCount: flavour.Spec.Policy.Aggregatable.MaxCount, - } - } - return nil - }(), - }, - Price: models.Price{ - Amount: flavour.Spec.Price.Amount, - Currency: flavour.Spec.Price.Currency, - Period: flavour.Spec.Price.Period, - }, - OptionalFields: models.OptionalFields{ - Availability: flavour.Spec.OptionalFields.Availability, - WorkerID: flavour.Spec.OptionalFields.WorkerID, - }, - } -} - -// ForgeContractObject creates a Contract Object -func ParseContract(contract *reservationv1alpha1.Contract) models.Contract { - return models.Contract{ - ContractID: contract.Name, - Flavour: ParseFlavour(contract.Spec.Flavour), - Buyer: ParseNodeIdentity(contract.Spec.Buyer), - BuyerClusterID: contract.Spec.BuyerClusterID, - TransactionID: contract.Spec.TransactionID, - Partition: ParsePartition(contract.Spec.Partition), - Seller: ParseNodeIdentity(contract.Spec.Seller), - SellerCredentials: models.LiqoCredentials{ - ClusterID: contract.Spec.SellerCredentials.ClusterID, - ClusterName: contract.Spec.SellerCredentials.ClusterName, - Token: contract.Spec.SellerCredentials.Token, - Endpoint: contract.Spec.SellerCredentials.Endpoint, - }, - } -} - -func ParseQuantityFromString(s string) resource.Quantity { - i, err := resource.ParseQuantity(s) - if err != nil { - return *resource.NewQuantity(0, resource.DecimalSI) - } - return i -} diff --git a/pkg/utils/resourceforge/doc.go b/pkg/utils/resourceforge/doc.go deleted file mode 100644 index c66df1d..0000000 --- a/pkg/utils/resourceforge/doc.go +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2022-2023 FLUIDOS Project -// -// 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 resourceforge contains different functions used -// to forge the different resources used into the FLUIDOS environment. -package resourceforge diff --git a/pkg/utils/resourceforge/forge.go b/pkg/utils/resourceforge/forge.go deleted file mode 100644 index 5defe30..0000000 --- a/pkg/utils/resourceforge/forge.go +++ /dev/null @@ -1,380 +0,0 @@ -// Copyright 2022-2023 FLUIDOS Project -// -// 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 resourceforge - -import ( - "time" - - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - - advertisementv1alpha1 "github.com/fluidos-project/node/apis/advertisement/v1alpha1" - nodecorev1alpha1 "github.com/fluidos-project/node/apis/nodecore/v1alpha1" - reservationv1alpha1 "github.com/fluidos-project/node/apis/reservation/v1alpha1" - "github.com/fluidos-project/node/pkg/utils/flags" - "github.com/fluidos-project/node/pkg/utils/models" - "github.com/fluidos-project/node/pkg/utils/namings" - "github.com/fluidos-project/node/pkg/utils/parseutil" - "github.com/fluidos-project/node/pkg/utils/tools" -) - -// ForgeDiscovery creates a Discovery CR from a FlavourSelector and a solverID -func ForgeDiscovery(selector *nodecorev1alpha1.FlavourSelector, solverID string) *advertisementv1alpha1.Discovery { - return &advertisementv1alpha1.Discovery{ - ObjectMeta: metav1.ObjectMeta{ - Name: namings.ForgeDiscoveryName(solverID), - Namespace: flags.FLUIDOS_NAMESPACE, - }, - Spec: advertisementv1alpha1.DiscoverySpec{ - Selector: func() *nodecorev1alpha1.FlavourSelector { - if selector != nil { - return selector - } - return nil - }(), - SolverID: solverID, - Subscribe: false, - }, - } -} - -// ForgePeeringCandidate creates a PeeringCandidate CR from a Flavour and a Discovery -func ForgePeeringCandidate(flavourPeeringCandidate *nodecorev1alpha1.Flavour, solverID string, reserved bool) (pc *advertisementv1alpha1.PeeringCandidate) { - pc = &advertisementv1alpha1.PeeringCandidate{ - ObjectMeta: metav1.ObjectMeta{ - Name: namings.ForgePeeringCandidateName(flavourPeeringCandidate.Name), - Namespace: flags.FLUIDOS_NAMESPACE, - }, - Spec: advertisementv1alpha1.PeeringCandidateSpec{ - Flavour: nodecorev1alpha1.Flavour{ - ObjectMeta: metav1.ObjectMeta{ - Name: flavourPeeringCandidate.Name, - Namespace: flavourPeeringCandidate.Namespace, - }, - Spec: flavourPeeringCandidate.Spec, - }, - }, - } - - if reserved { - pc.Spec.SolverID = solverID - pc.Spec.Reserved = true - } - - return -} - -// ForgeReservation creates a Reservation CR from a PeeringCandidate -func ForgeReservation(peeringCandidate advertisementv1alpha1.PeeringCandidate, partition *reservationv1alpha1.Partition, ni nodecorev1alpha1.NodeIdentity) *reservationv1alpha1.Reservation { - solverID := peeringCandidate.Spec.SolverID - reservation := &reservationv1alpha1.Reservation{ - ObjectMeta: metav1.ObjectMeta{ - Name: namings.ForgeReservationName(solverID), - Namespace: flags.FLUIDOS_NAMESPACE, - }, - Spec: reservationv1alpha1.ReservationSpec{ - SolverID: solverID, - Buyer: ni, - Seller: nodecorev1alpha1.NodeIdentity{ - Domain: peeringCandidate.Spec.Flavour.Spec.Owner.Domain, - NodeID: peeringCandidate.Spec.Flavour.Spec.Owner.NodeID, - IP: peeringCandidate.Spec.Flavour.Spec.Owner.IP, - }, - PeeringCandidate: nodecorev1alpha1.GenericRef{ - Name: peeringCandidate.Name, - Namespace: peeringCandidate.Namespace, - }, - Reserve: true, - Purchase: true, - }, - } - if partition != nil { - reservation.Spec.Partition = partition - } - return reservation -} - -// ForgeContract creates a Contract CR -func ForgeContract(flavour nodecorev1alpha1.Flavour, transaction models.Transaction, lc *reservationv1alpha1.LiqoCredentials) *reservationv1alpha1.Contract { - return &reservationv1alpha1.Contract{ - ObjectMeta: metav1.ObjectMeta{ - Name: namings.ForgeContractName(flavour.Name), - Namespace: flags.FLUIDOS_NAMESPACE, - }, - Spec: reservationv1alpha1.ContractSpec{ - Flavour: flavour, - Buyer: nodecorev1alpha1.NodeIdentity{ - Domain: transaction.Buyer.Domain, - IP: transaction.Buyer.IP, - NodeID: transaction.Buyer.NodeID, - }, - BuyerClusterID: transaction.ClusterID, - Seller: flavour.Spec.Owner, - SellerCredentials: *lc, - TransactionID: transaction.TransactionID, - Partition: func() *reservationv1alpha1.Partition { - if transaction.Partition != nil { - return parseutil.ParsePartitionFromObj(transaction.Partition) - } - return nil - }(), - ExpirationTime: time.Now().Add(flags.EXPIRATION_CONTRACT).Format(time.RFC3339), - }, - Status: reservationv1alpha1.ContractStatus{ - Phase: nodecorev1alpha1.PhaseStatus{ - Phase: nodecorev1alpha1.PhaseActive, - StartTime: tools.GetTimeNow(), - }, - }, - } -} - -// ForgeFlavourFromMetrics creates a new flavour custom resource from the metrics of the node -func ForgeFlavourFromMetrics(node models.NodeInfo, ni nodecorev1alpha1.NodeIdentity) (flavour *nodecorev1alpha1.Flavour) { - return &nodecorev1alpha1.Flavour{ - ObjectMeta: metav1.ObjectMeta{ - Name: namings.ForgeFlavourName(node.UID, ni.Domain), - Namespace: flags.FLUIDOS_NAMESPACE, - }, - Spec: nodecorev1alpha1.FlavourSpec{ - ProviderID: ni.NodeID, - Type: nodecorev1alpha1.K8S, - Characteristics: nodecorev1alpha1.Characteristics{ - Architecture: node.Architecture, - Cpu: node.ResourceMetrics.CPUAvailable, - Memory: node.ResourceMetrics.MemoryAvailable, - EphemeralStorage: node.ResourceMetrics.EphemeralStorage, - PersistentStorage: parseutil.ParseQuantityFromString("0"), - Gpu: parseutil.ParseQuantityFromString("0"), - }, - Policy: nodecorev1alpha1.Policy{ - Partitionable: &nodecorev1alpha1.Partitionable{ - CpuMin: parseutil.ParseQuantityFromString(flags.CPU_MIN), - MemoryMin: parseutil.ParseQuantityFromString(flags.MEMORY_MIN), - CpuStep: parseutil.ParseQuantityFromString(flags.CPU_STEP), - MemoryStep: parseutil.ParseQuantityFromString(flags.MEMORY_STEP), - }, - Aggregatable: &nodecorev1alpha1.Aggregatable{ - MinCount: int(flags.MIN_COUNT), - MaxCount: int(flags.MAX_COUNT), - }, - }, - Owner: ni, - Price: nodecorev1alpha1.Price{ - Amount: flags.AMOUNT, - Currency: flags.CURRENCY, - Period: flags.PERIOD, - }, - OptionalFields: nodecorev1alpha1.OptionalFields{ - Availability: true, - WorkerID: node.UID, - }, - }, - } -} - -// FORGER FUNCTIONS FROM OBJECTS - -// ForgeTransaction creates a new transaction -func ForgeTransactionObj(ID string, req models.ReserveRequest) models.Transaction { - return models.Transaction{ - TransactionID: ID, - Buyer: req.Buyer, - ClusterID: req.ClusterID, - FlavourID: req.FlavourID, - Partition: req.Partition, - StartTime: tools.GetTimeNow(), - } -} - -func ForgeContractObj(contract *reservationv1alpha1.Contract) models.Contract { - return models.Contract{ - ContractID: contract.Name, - Flavour: parseutil.ParseFlavour(contract.Spec.Flavour), - Buyer: parseutil.ParseNodeIdentity(contract.Spec.Buyer), - BuyerClusterID: contract.Spec.BuyerClusterID, - Seller: parseutil.ParseNodeIdentity(contract.Spec.Seller), - SellerCredentials: models.LiqoCredentials{ - ClusterID: contract.Spec.SellerCredentials.ClusterID, - ClusterName: contract.Spec.SellerCredentials.ClusterName, - Token: contract.Spec.SellerCredentials.Token, - Endpoint: contract.Spec.SellerCredentials.Endpoint, - }, - Partition: func() *models.Partition { - if contract.Spec.Partition != nil { - return parseutil.ParsePartition(contract.Spec.Partition) - } - return nil - }(), - TransactionID: contract.Spec.TransactionID, - ExpirationTime: contract.Spec.ExpirationTime, - ExtraInformation: func() map[string]string { - if contract.Spec.ExtraInformation != nil { - return contract.Spec.ExtraInformation - } - return nil - }(), - } -} - -// ForgeResponsePurchaseObj creates a new response purchase -func ForgeResponsePurchaseObj(contract models.Contract) models.ResponsePurchase { - return models.ResponsePurchase{ - Contract: contract, - Status: "Completed", - } -} - -// ForgeContractFromObj creates a Contract from a reservation -func ForgeContractFromObj(contract models.Contract) *reservationv1alpha1.Contract { - return &reservationv1alpha1.Contract{ - ObjectMeta: metav1.ObjectMeta{ - Name: contract.ContractID, - Namespace: flags.FLUIDOS_NAMESPACE, - }, - Spec: reservationv1alpha1.ContractSpec{ - Flavour: *ForgeFlavourFromObj(contract.Flavour), - Buyer: nodecorev1alpha1.NodeIdentity{ - Domain: contract.Buyer.Domain, - IP: contract.Buyer.IP, - NodeID: contract.Buyer.NodeID, - }, - BuyerClusterID: contract.BuyerClusterID, - Seller: nodecorev1alpha1.NodeIdentity{ - NodeID: contract.Seller.NodeID, - IP: contract.Seller.IP, - Domain: contract.Seller.Domain, - }, - SellerCredentials: reservationv1alpha1.LiqoCredentials{ - ClusterID: contract.SellerCredentials.ClusterID, - ClusterName: contract.SellerCredentials.ClusterName, - Token: contract.SellerCredentials.Token, - Endpoint: contract.SellerCredentials.Endpoint, - }, - TransactionID: contract.TransactionID, - Partition: func() *reservationv1alpha1.Partition { - if contract.Partition != nil { - return parseutil.ParsePartitionFromObj(contract.Partition) - } - return nil - }(), - ExpirationTime: contract.ExpirationTime, - ExtraInformation: func() map[string]string { - if contract.ExtraInformation != nil { - return contract.ExtraInformation - } - return nil - }(), - }, - Status: reservationv1alpha1.ContractStatus{ - Phase: nodecorev1alpha1.PhaseStatus{ - Phase: nodecorev1alpha1.PhaseActive, - StartTime: tools.GetTimeNow(), - }, - }, - } -} - -// ForgeTransactionFromObj creates a transaction from a Transaction object -func ForgeTransactionFromObj(reservation *models.Transaction) *reservationv1alpha1.Transaction { - return &reservationv1alpha1.Transaction{ - ObjectMeta: metav1.ObjectMeta{ - Name: reservation.TransactionID, - Namespace: flags.FLUIDOS_NAMESPACE, - }, - Spec: reservationv1alpha1.TransactionSpec{ - FlavourID: reservation.FlavourID, - StartTime: reservation.StartTime, - Buyer: nodecorev1alpha1.NodeIdentity{ - Domain: reservation.Buyer.Domain, - IP: reservation.Buyer.IP, - NodeID: reservation.Buyer.NodeID, - }, - ClusterID: reservation.ClusterID, - Partition: func() *reservationv1alpha1.Partition { - if reservation.Partition != nil { - return parseutil.ParsePartitionFromObj(reservation.Partition) - } - return nil - }(), - }, - } -} - -// ForgeFlavourFromObj creates a Flavour CR from a Flavour Object (REAR) -func ForgeFlavourFromObj(flavour models.Flavour) *nodecorev1alpha1.Flavour { - f := &nodecorev1alpha1.Flavour{ - ObjectMeta: metav1.ObjectMeta{ - Name: flavour.FlavourID, - Namespace: flags.FLUIDOS_NAMESPACE, - }, - Spec: nodecorev1alpha1.FlavourSpec{ - ProviderID: flavour.Owner.NodeID, - Type: nodecorev1alpha1.K8S, - Characteristics: nodecorev1alpha1.Characteristics{ - Cpu: flavour.Characteristics.CPU, - Memory: flavour.Characteristics.Memory, - Architecture: flavour.Characteristics.Architecture, - EphemeralStorage: flavour.Characteristics.EphemeralStorage, - PersistentStorage: flavour.Characteristics.PersistentStorage, - Gpu: flavour.Characteristics.Gpu, - }, - Policy: nodecorev1alpha1.Policy{ - // Check if flavour.Partitionable is not nil before setting Partitionable - Partitionable: func() *nodecorev1alpha1.Partitionable { - if flavour.Policy.Partitionable != nil { - return &nodecorev1alpha1.Partitionable{ - CpuMin: flavour.Policy.Partitionable.CPUMinimum, - MemoryMin: flavour.Policy.Partitionable.MemoryMinimum, - CpuStep: flavour.Policy.Partitionable.CPUStep, - MemoryStep: flavour.Policy.Partitionable.MemoryStep, - } - } - return nil - }(), - Aggregatable: func() *nodecorev1alpha1.Aggregatable { - if flavour.Policy.Aggregatable != nil { - return &nodecorev1alpha1.Aggregatable{ - MinCount: flavour.Policy.Aggregatable.MinCount, - MaxCount: flavour.Policy.Aggregatable.MaxCount, - } - } - return nil - }(), - }, - Owner: nodecorev1alpha1.NodeIdentity{ - Domain: flavour.Owner.Domain, - IP: flavour.Owner.IP, - NodeID: flavour.Owner.NodeID, - }, - Price: nodecorev1alpha1.Price{ - Amount: flavour.Price.Amount, - Currency: flavour.Price.Currency, - Period: flavour.Price.Period, - }, - }, - } - return f -} - -func ForgePartition(selector *nodecorev1alpha1.FlavourSelector) *reservationv1alpha1.Partition { - return &reservationv1alpha1.Partition{ - Architecture: selector.Architecture, - Cpu: selector.RangeSelector.MinCpu, - Memory: selector.RangeSelector.MinMemory, - EphemeralStorage: selector.RangeSelector.MinEph, - Storage: selector.RangeSelector.MinStorage, - Gpu: selector.RangeSelector.MinGpu, - } -} diff --git a/pkg/utils/services/doc.go b/pkg/utils/services/doc.go deleted file mode 100644 index eb33da9..0000000 --- a/pkg/utils/services/doc.go +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2022-2023 FLUIDOS Project -// -// 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 services contains different functions and -// services used into the FLUIDOS environment. -package services diff --git a/pkg/utils/services/flavours_services.go b/pkg/utils/services/flavours_services.go deleted file mode 100644 index 62044f8..0000000 --- a/pkg/utils/services/flavours_services.go +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright 2022-2023 FLUIDOS Project -// -// 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 services - -import ( - "context" - - nodecorev1alpha1 "github.com/fluidos-project/node/apis/nodecore/v1alpha1" - "github.com/fluidos-project/node/pkg/utils/flags" - "k8s.io/klog/v2" - "sigs.k8s.io/controller-runtime/pkg/client" -) - -// GetAllFlavours returns all the Flavours in the cluster -func GetAllFlavours(cl client.Client) ([]nodecorev1alpha1.Flavour, error) { - - var flavourList nodecorev1alpha1.FlavourList - - // List all Flavour CRs - err := cl.List(context.Background(), &flavourList) - if err != nil { - klog.Errorf("Error when listing Flavours: %s", err) - return nil, err - } - - return flavourList.Items, nil -} - -// GetFlavourByID returns the entire Flavour CR (not only spec) in the cluster that matches the flavourID -func GetFlavourByID(flavourID string, cl client.Client) (*nodecorev1alpha1.Flavour, error) { - - // Get the flavour with the given ID (that is the name of the CR) - flavour := &nodecorev1alpha1.Flavour{} - err := cl.Get(context.Background(), client.ObjectKey{ - Namespace: flags.FLUIDOS_NAMESPACE, - Name: flavourID, - }, flavour) - if err != nil { - klog.Errorf("Error when getting Flavour %s: %s", flavourID, err) - return nil, err - } - - return flavour, nil -} diff --git a/pkg/utils/tools/tools.go b/pkg/utils/tools/tools.go deleted file mode 100644 index b2a18c8..0000000 --- a/pkg/utils/tools/tools.go +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2022-2023 FLUIDOS Project -// -// 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 tools - -import ( - "time" - - "k8s.io/klog/v2" -) - -// GetTimeNow returns the current time in RFC3339 format -func GetTimeNow() string { - return time.Now().Format(time.RFC3339) -} - -// CheckExpiration checks if the timestamp has expired -func CheckExpiration(timestamp string, expTime time.Duration) bool { - t, err := time.Parse(time.RFC3339, timestamp) - if err != nil { - klog.Errorf("Error parsing the transaction start time: %s", err) - return false - } - return time.Since(t) > expTime -}