diff --git a/api/v1alpha1/codecoapp_types.go b/api/v1alpha1/codecoapp_types.go index cc9bc51073b0ba0dfcbf1e4b4ef94eea24930a00..50afdbe3eb08f9295478e87349421252ed4559c9 100644 --- a/api/v1alpha1/codecoapp_types.go +++ b/api/v1alpha1/codecoapp_types.go @@ -47,6 +47,40 @@ const ( // 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. +// CodecoAppResource defines the resource consumption of CodecoApp +type CodecoAppResource struct { + //+kubebuilder:validation:Minimum=0 + //+kubebuilder:validation:default=100 + CpuUsagePct uint64 `json:"cpu-usage-pct,omitempty"` + + //+kubebuilder:validation:Minimum=0 + //+kubebuilder:validation:default=8 + MemUsageGB uint64 `json:"mem-usage-GB,omitempty"` + + //+kubebuilder:validation:Minimum=0 + //+kubebuilder:validation:default=25 + NWBandwidthMbs uint64 `json:"nwbandwidth-Mbs,omitempty"` + + //+kubebuilder:validation:Minimum=0 + //+kubebuilder:validation:default=10 + NWLatencyMs uint64 `json:"nwlatency-ms,omitempty"` +} + +// CodecoAppMSSpec defines the desired state of CodecoApp micro service +type CodecoAppMSSpec struct { + // INSERT ADDITIONAL SPEC FIELDS - desired state of cluster + // Important: Run "make" to regenerate code after modifying this file + + // Name is an used to identify the CODECO micro service. Edit codecoapp_types.go to remove/update + Name string `json:"name"` + + // A reference to the PodSpec of the microservice. Edit codecoapp_types.go to remove/update + PodSpecName string `json:"podspecname"` + + // RequiredResources is used to identify the CODECO micro service required resources. Edit codecoapp_types.go to remove/update + RequiredResources CodecoAppResource `json:"required-resources,omitempty"` +} + // CodecoAppSpec defines the desired state of CodecoApp type CodecoAppSpec struct { // INSERT ADDITIONAL SPEC FIELDS - desired state of cluster @@ -60,6 +94,10 @@ type CodecoAppSpec struct { // QosClass is used to identify the CODECO application QoS. Edit codecoapp_types.go to remove/update QosClass CodecoQosClass `json:"qosclass,omitempty"` + //+kubebuilder:validation:MinItems=1 + // MCSpecs is used to identify the CODECO micro services which compose the application. Edit codecoapp_types.go to remove/update + MCSpecs []CodecoAppMSSpec `json:"codecoapp-msspec,omitempty"` + //+kubebuilder:validation:Enum=Gold;Silver;BestEffort // SecurityClass is used to identify the CODECO application security class. Edit codecoapp_types.go to remove/update diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index 4ec708ba4bec7007c300133e220f424cc0660475..414bd56d32497ec771ed2ec6f4932d8136d6ed2b 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -30,7 +30,7 @@ func (in *CodecoApp) DeepCopyInto(out *CodecoApp) { *out = *in out.TypeMeta = in.TypeMeta in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - out.Spec = in.Spec + in.Spec.DeepCopyInto(&out.Spec) out.Status = in.Status } @@ -84,9 +84,45 @@ func (in *CodecoAppList) DeepCopyObject() runtime.Object { return nil } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CodecoAppMSSpec) DeepCopyInto(out *CodecoAppMSSpec) { + *out = *in + out.RequiredResources = in.RequiredResources +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CodecoAppMSSpec. +func (in *CodecoAppMSSpec) DeepCopy() *CodecoAppMSSpec { + if in == nil { + return nil + } + out := new(CodecoAppMSSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CodecoAppResource) DeepCopyInto(out *CodecoAppResource) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CodecoAppResource. +func (in *CodecoAppResource) DeepCopy() *CodecoAppResource { + if in == nil { + return nil + } + out := new(CodecoAppResource) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *CodecoAppSpec) DeepCopyInto(out *CodecoAppSpec) { *out = *in + if in.MCSpecs != nil { + in, out := &in.MCSpecs, &out.MCSpecs + *out = make([]CodecoAppMSSpec, len(*in)) + copy(*out, *in) + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CodecoAppSpec. diff --git a/config/crd/bases/codeco.he-codeco.eu_codecoapps.yaml b/config/crd/bases/codeco.he-codeco.eu_codecoapps.yaml index 6e20c672b76f807d9c7178156eae7e9f10e75a9a..0cbe415a703b454eccdd7e0541763317f0790194 100644 --- a/config/crd/bases/codeco.he-codeco.eu_codecoapps.yaml +++ b/config/crd/bases/codeco.he-codeco.eu_codecoapps.yaml @@ -35,6 +35,49 @@ spec: spec: description: CodecoAppSpec defines the desired state of CodecoApp properties: + codecoapp-msspec: + description: MCSpecs is used to identify the CODECO micro services + which compose the application. Edit codecoapp_types.go to remove/update + items: + description: CodecoAppMSSpec defines the desired state of CodecoApp + micro service + properties: + name: + description: Name is an used to identify the CODECO micro service. + Edit codecoapp_types.go to remove/update + type: string + podspecname: + description: A reference to the PodSpec of the microservice. + Edit codecoapp_types.go to remove/update + type: string + required-resources: + description: RequiredResources is used to identify the CODECO + micro service required resources. Edit codecoapp_types.go + to remove/update + properties: + cpu-usage-pct: + format: int64 + minimum: 0 + type: integer + mem-usage-GB: + format: int64 + minimum: 0 + type: integer + nwbandwidth-Mbs: + format: int64 + minimum: 0 + type: integer + nwlatency-ms: + format: int64 + minimum: 0 + type: integer + type: object + required: + - name + - podspecname + type: object + minItems: 1 + type: array name: description: Name is an used to identify the CODECO application. Edit codecoapp_types.go to remove/update diff --git a/config/manager/kustomization.yaml b/config/manager/kustomization.yaml index 9d70969325a31a3d3834228ade0d5a90877aefe2..6beebd8d87eaa4e7bda7d8840d1b50901000442b 100644 --- a/config/manager/kustomization.yaml +++ b/config/manager/kustomization.yaml @@ -5,4 +5,4 @@ kind: Kustomization images: - name: controller newName: quay.io/jsalomon/codecoapp-test - newTag: v0.0.2 + newTag: v0.0.4 diff --git a/config/samples/codeco_v1alpha1_codecoapp.yaml b/config/samples/codeco_v1alpha1_codecoapp.yaml index aa6e7e0c10bf41682cf7528fe0e7d127f2f499ba..18f2b4990a33d52d00246a33a90818cfaf786b91 100644 --- a/config/samples/codeco_v1alpha1_codecoapp.yaml +++ b/config/samples/codeco_v1alpha1_codecoapp.yaml @@ -11,5 +11,24 @@ metadata: spec: name: My CODECO App qosclass: Dev - + codecoapp-msspec: [ + { + name: "CODECO micro service 1", + podspecname: "MicroService1", + required-resources: { + cpu-usage-pct: 200, + mem-usage-GB: 120, + nwbandwidth-Mbs: 10 + } + }, + { + name: "CODECO micro service 2", + podspecname: "MicroService2", + required-resources: { + cpu-usage-pct: 150, + mem-usage-GB: 80, + nwbandwidth-Mbs: 20 + } + }, + ] # TODO(user): Add fields here