From 9521a16ce4946d3169993780f2d2a4f3a75d0445 Mon Sep 17 00:00:00 2001 From: RealAnna <89971034+RealAnna@users.noreply.github.com> Date: Wed, 9 Aug 2023 11:24:12 +0200 Subject: [PATCH] feat(metrics-operator): add Analysis CRD (#1839) Signed-off-by: realanna --- .../docs/crd-ref/metrics/v1alpha3/_index.md | 68 +++++++++++++ helm/chart/templates/analysis-crd.yaml | 93 +++++++++++++++++ .../apis/lifecycle/v1alpha1/common/phases.go | 1 + .../lifecycle.keptn.sh_keptnappversions.yaml | 2 + ...cycle.keptn.sh_keptnworkloadinstances.yaml | 2 + metrics-operator/PROJECT | 8 ++ .../api/v1alpha3/analysis_types.go | 64 ++++++++++++ .../api/v1alpha3/zz_generated.deepcopy.go | 99 +++++++++++++++++++ .../crd/bases/metrics.keptn.sh_analyses.yaml | 91 +++++++++++++++++ .../config/crd/kustomization.yaml | 3 + .../crd/patches/webhook_in_analyses.yaml | 16 +++ .../config/rbac/analysis_editor_role.yaml | 31 ++++++ .../config/rbac/analysis_viewer_role.yaml | 27 +++++ .../samples/metrics_v1alpha3_analysis.yaml | 21 ++++ test/integration/analysis/00-assert.yaml | 21 ++++ test/integration/analysis/00-install.yaml | 21 ++++ 16 files changed, 568 insertions(+) create mode 100644 helm/chart/templates/analysis-crd.yaml create mode 100644 metrics-operator/api/v1alpha3/analysis_types.go create mode 100644 metrics-operator/config/crd/bases/metrics.keptn.sh_analyses.yaml create mode 100644 metrics-operator/config/crd/patches/webhook_in_analyses.yaml create mode 100644 metrics-operator/config/rbac/analysis_editor_role.yaml create mode 100644 metrics-operator/config/rbac/analysis_viewer_role.yaml create mode 100644 metrics-operator/config/samples/metrics_v1alpha3_analysis.yaml create mode 100644 test/integration/analysis/00-assert.yaml create mode 100644 test/integration/analysis/00-install.yaml diff --git a/docs/content/en/docs/crd-ref/metrics/v1alpha3/_index.md b/docs/content/en/docs/crd-ref/metrics/v1alpha3/_index.md index 42fabb0d24..a6a00d70f0 100644 --- a/docs/content/en/docs/crd-ref/metrics/v1alpha3/_index.md +++ b/docs/content/en/docs/crd-ref/metrics/v1alpha3/_index.md @@ -13,8 +13,10 @@ description: Reference information for metrics.keptn.sh/v1alpha3 Package v1alpha3 contains API Schema definitions for the metrics v1alpha3 API group ### Resource Types +- [Analysis](#analysis) - [AnalysisDefinition](#analysisdefinition) - [AnalysisDefinitionList](#analysisdefinitionlist) +- [AnalysisList](#analysislist) - [KeptnMetric](#keptnmetric) - [KeptnMetricList](#keptnmetriclist) - [KeptnMetricsProvider](#keptnmetricsprovider) @@ -22,6 +24,24 @@ Package v1alpha3 contains API Schema definitions for the metrics v1alpha3 API gr +#### Analysis + + + +Analysis is the Schema for the analyses API + +_Appears in:_ +- [AnalysisList](#analysislist) + +| Field | Description | +| --- | --- | +| `apiVersion` _string_ | `metrics.keptn.sh/v1alpha3` +| `kind` _string_ | `Analysis` +| `metadata` _[ObjectMeta](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.24/#objectmeta-v1-meta)_ | Refer to Kubernetes API documentation for fields of `metadata`. | +| `spec` _[AnalysisSpec](#analysisspec)_ | | +| `status` _string_ | | + + #### AnalysisDefinition @@ -71,6 +91,38 @@ _Appears in:_ | `totalScore` _[TotalScore](#totalscore)_ | TotalScore defines the required score for an analysis to be successful | +#### AnalysisList + + + +AnalysisList contains a list of Analysis + + + +| Field | Description | +| --- | --- | +| `apiVersion` _string_ | `metrics.keptn.sh/v1alpha3` +| `kind` _string_ | `AnalysisList` +| `metadata` _[ListMeta](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.24/#listmeta-v1-meta)_ | Refer to Kubernetes API documentation for fields of `metadata`. | +| `items` _[Analysis](#analysis) array_ | | + + +#### AnalysisSpec + + + +AnalysisSpec defines the desired state of Analysis + +_Appears in:_ +- [Analysis](#analysis) + +| Field | Description | +| --- | --- | +| `timeframe` _[Timeframe](#timeframe)_ | Timeframe specifies the range for the corresponding query in the AnalysisValueTemplate | +| `args` _object (keys:string, values:string)_ | Args corresponds to a map of key/value pairs that can be used to substitute placeholders in the AnalysisValueTemplate query. The placeholder must be the capitalized version of the key; i.e. for args foo:bar the query could be "query:percentile(95)?scope=tag(my_foo_label:{{.Foo}})". | +| `analysisDefinition` _[ObjectReference](#objectreference)_ | AnalysisDefinition refers to the AnalysisDefinition, a CRD that stores the AnalysisValuesTemplates | + + #### KeptnMetric @@ -196,6 +248,7 @@ _Appears in:_ _Appears in:_ +- [AnalysisSpec](#analysisspec) - [Objective](#objective) | Field | Description | @@ -298,6 +351,21 @@ _Appears in:_ | `warning` _[Operator](#operator)_ | Warning defines limits where the result does not pass or fail | +#### Timeframe + + + + + +_Appears in:_ +- [AnalysisSpec](#analysisspec) + +| Field | Description | +| --- | --- | +| `from` _[Time](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.24/#time-v1-meta)_ | From is the time of start for the query, this field follows RFC3339 time format | +| `to` _[Time](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.24/#time-v1-meta)_ | To is the time of end for the query, this field follows RFC3339 time format | + + #### TotalScore diff --git a/helm/chart/templates/analysis-crd.yaml b/helm/chart/templates/analysis-crd.yaml new file mode 100644 index 0000000000..46ae7e6a67 --- /dev/null +++ b/helm/chart/templates/analysis-crd.yaml @@ -0,0 +1,93 @@ +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + name: analyses.metrics.keptn.sh + annotations: + controller-gen.kubebuilder.io/version: v0.12.1 + labels: + app.kubernetes.io/part-of: keptn-lifecycle-toolkit + crdGroup: metrics.keptn.sh + keptn.sh/inject-cert: "true" + {{- include "chart.labels" . | nindent 4 }} +spec: + group: metrics.keptn.sh + names: + kind: Analysis + listKind: AnalysisList + plural: analyses + singular: analysis + scope: Namespaced + versions: + - name: v1alpha3 + schema: + openAPIV3Schema: + description: Analysis is the Schema for the analyses 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: AnalysisSpec defines the desired state of Analysis + properties: + analysisDefinition: + description: AnalysisDefinition refers to the AnalysisDefinition, a + CRD that stores the AnalysisValuesTemplates + properties: + name: + description: Name of the AnalysisDefinition + type: string + required: + - name + type: object + args: + additionalProperties: + type: string + description: Args corresponds to a map of key/value pairs that can be + used to substitute placeholders in the AnalysisValueTemplate query. + The placeholder must be the capitalized version of the key; i.e. for + args foo:bar the query could be "query:percentile(95)?scope=tag(my_foo_label:{{.Foo}})". + type: object + timeframe: + description: Timeframe specifies the range for the corresponding query + in the AnalysisValueTemplate + properties: + from: + description: From is the time of start for the query, this field + follows RFC3339 time format + format: date-time + type: string + to: + description: To is the time of end for the query, this field follows + RFC3339 time format + format: date-time + type: string + required: + - from + - to + type: object + required: + - analysisDefinition + - timeframe + type: object + status: + type: string + type: object + served: true + storage: true + subresources: + status: {} +status: + acceptedNames: + kind: "" + plural: "" + conditions: [] + storedVersions: [] diff --git a/lifecycle-operator/apis/lifecycle/v1alpha1/common/phases.go b/lifecycle-operator/apis/lifecycle/v1alpha1/common/phases.go index 179a7e31fe..b8c8fec5b0 100644 --- a/lifecycle-operator/apis/lifecycle/v1alpha1/common/phases.go +++ b/lifecycle-operator/apis/lifecycle/v1alpha1/common/phases.go @@ -85,6 +85,7 @@ var ( PhaseCancelled = KeptnPhaseType{LongName: "Cancelled", ShortName: "Cancelled"} ) +// PhaseTraceID is a map storing TraceIDs of OpenTelemetry spans in lifecycle phases type PhaseTraceID map[string]propagation.MapCarrier func (pid PhaseTraceID) SetPhaseTraceID(phase string, carrier propagation.MapCarrier) { diff --git a/lifecycle-operator/config/crd/bases/lifecycle.keptn.sh_keptnappversions.yaml b/lifecycle-operator/config/crd/bases/lifecycle.keptn.sh_keptnappversions.yaml index 67754f1d2b..dd5a401fe2 100644 --- a/lifecycle-operator/config/crd/bases/lifecycle.keptn.sh_keptnappversions.yaml +++ b/lifecycle-operator/config/crd/bases/lifecycle.keptn.sh_keptnappversions.yaml @@ -123,6 +123,8 @@ spec: description: MapCarrier is a TextMapCarrier that uses a map held in memory as a storage medium for propagated key-value pairs. type: object + description: PhaseTraceID is a map storing TraceIDs of OpenTelemetry + spans in lifecycle phases type: object postDeploymentEvaluationStatus: default: Pending diff --git a/lifecycle-operator/config/crd/bases/lifecycle.keptn.sh_keptnworkloadinstances.yaml b/lifecycle-operator/config/crd/bases/lifecycle.keptn.sh_keptnworkloadinstances.yaml index e26f6bc42d..e1eb94cb13 100644 --- a/lifecycle-operator/config/crd/bases/lifecycle.keptn.sh_keptnworkloadinstances.yaml +++ b/lifecycle-operator/config/crd/bases/lifecycle.keptn.sh_keptnworkloadinstances.yaml @@ -140,6 +140,8 @@ spec: description: MapCarrier is a TextMapCarrier that uses a map held in memory as a storage medium for propagated key-value pairs. type: object + description: PhaseTraceID is a map storing TraceIDs of OpenTelemetry + spans in lifecycle phases type: object postDeploymentEvaluationStatus: default: Pending diff --git a/metrics-operator/PROJECT b/metrics-operator/PROJECT index 12af78e4fd..0accda4a10 100644 --- a/metrics-operator/PROJECT +++ b/metrics-operator/PROJECT @@ -64,4 +64,12 @@ resources: webhooks: validation: true webhookVersion: v1 +- api: + crdVersion: v1 + namespaced: true + domain: keptn.sh + group: metrics + kind: Analysis + path: github.com/keptn/lifecycle-toolkit/metrics-operator/api/v1alpha3 + version: v1alpha3 version: "3" diff --git a/metrics-operator/api/v1alpha3/analysis_types.go b/metrics-operator/api/v1alpha3/analysis_types.go new file mode 100644 index 0000000000..e5e5985d85 --- /dev/null +++ b/metrics-operator/api/v1alpha3/analysis_types.go @@ -0,0 +1,64 @@ +/* +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 v1alpha3 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// AnalysisSpec defines the desired state of Analysis +type AnalysisSpec struct { + //Timeframe specifies the range for the corresponding query in the AnalysisValueTemplate + Timeframe `json:"timeframe"` + // Args corresponds to a map of key/value pairs that can be used to substitute placeholders in the AnalysisValueTemplate query. The placeholder must be the capitalized version of the key; i.e. for args foo:bar the query could be "query:percentile(95)?scope=tag(my_foo_label:{{.Foo}})". + Args map[string]string `json:"args,omitempty"` + // AnalysisDefinition refers to the AnalysisDefinition, a CRD that stores the AnalysisValuesTemplates + AnalysisDefinition ObjectReference `json:"analysisDefinition"` +} + +//+kubebuilder:object:root=true +//+kubebuilder:subresource:status +//+kubebuilder:printcolumn:name="AnalysisDefinition",type=string,JSONPath=.spec.analysisDefinition.name + +// Analysis is the Schema for the analyses API +type Analysis struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec AnalysisSpec `json:"spec,omitempty"` + Status string `json:"status,omitempty"` +} + +//+kubebuilder:object:root=true + +// AnalysisList contains a list of Analysis +type AnalysisList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []Analysis `json:"items"` +} + +type Timeframe struct { + // From is the time of start for the query, this field follows RFC3339 time format + From metav1.Time `json:"from"` + // To is the time of end for the query, this field follows RFC3339 time format + To metav1.Time `json:"to"` +} + +func init() { + SchemeBuilder.Register(&Analysis{}, &AnalysisList{}) +} diff --git a/metrics-operator/api/v1alpha3/zz_generated.deepcopy.go b/metrics-operator/api/v1alpha3/zz_generated.deepcopy.go index ea277610c9..a0bbc15960 100644 --- a/metrics-operator/api/v1alpha3/zz_generated.deepcopy.go +++ b/metrics-operator/api/v1alpha3/zz_generated.deepcopy.go @@ -25,6 +25,32 @@ import ( "k8s.io/apimachinery/pkg/runtime" ) +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Analysis) DeepCopyInto(out *Analysis) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Analysis. +func (in *Analysis) DeepCopy() *Analysis { + if in == nil { + return nil + } + out := new(Analysis) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Analysis) 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 *AnalysisDefinition) DeepCopyInto(out *AnalysisDefinition) { *out = *in @@ -106,6 +132,62 @@ func (in *AnalysisDefinitionSpec) DeepCopy() *AnalysisDefinitionSpec { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AnalysisList) DeepCopyInto(out *AnalysisList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Analysis, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AnalysisList. +func (in *AnalysisList) DeepCopy() *AnalysisList { + if in == nil { + return nil + } + out := new(AnalysisList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *AnalysisList) 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 *AnalysisSpec) DeepCopyInto(out *AnalysisSpec) { + *out = *in + in.Timeframe.DeepCopyInto(&out.Timeframe) + if in.Args != nil { + in, out := &in.Args, &out.Args + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + out.AnalysisDefinition = in.AnalysisDefinition +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AnalysisSpec. +func (in *AnalysisSpec) DeepCopy() *AnalysisSpec { + if in == nil { + return nil + } + out := new(AnalysisSpec) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *KeptnMetric) DeepCopyInto(out *KeptnMetric) { *out = *in @@ -424,6 +506,23 @@ func (in *Target) DeepCopy() *Target { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Timeframe) DeepCopyInto(out *Timeframe) { + *out = *in + in.From.DeepCopyInto(&out.From) + in.To.DeepCopyInto(&out.To) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Timeframe. +func (in *Timeframe) DeepCopy() *Timeframe { + if in == nil { + return nil + } + out := new(Timeframe) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *TotalScore) DeepCopyInto(out *TotalScore) { *out = *in diff --git a/metrics-operator/config/crd/bases/metrics.keptn.sh_analyses.yaml b/metrics-operator/config/crd/bases/metrics.keptn.sh_analyses.yaml new file mode 100644 index 0000000000..13e4e91103 --- /dev/null +++ b/metrics-operator/config/crd/bases/metrics.keptn.sh_analyses.yaml @@ -0,0 +1,91 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.12.1 + name: analyses.metrics.keptn.sh +spec: + group: metrics.keptn.sh + names: + kind: Analysis + listKind: AnalysisList + plural: analyses + singular: analysis + scope: Namespaced + versions: + - additionalPrinterColumns: + - jsonPath: .spec.analysisDefinition.name + name: AnalysisDefinition + type: string + name: v1alpha3 + schema: + openAPIV3Schema: + description: Analysis is the Schema for the analyses 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: AnalysisSpec defines the desired state of Analysis + properties: + analysisDefinition: + description: AnalysisDefinition refers to the AnalysisDefinition, + a CRD that stores the AnalysisValuesTemplates + properties: + name: + description: Name defines the name of the referenced object + type: string + namespace: + description: Namespace defines the namespace of the referenced + object + type: string + required: + - name + type: object + args: + additionalProperties: + type: string + description: Args corresponds to a map of key/value pairs that can + be used to substitute placeholders in the AnalysisValueTemplate + query. The placeholder must be the capitalized version of the key; + i.e. for args foo:bar the query could be "query:percentile(95)?scope=tag(my_foo_label:{{.Foo}})". + type: object + timeframe: + description: Timeframe specifies the range for the corresponding query + in the AnalysisValueTemplate + properties: + from: + description: From is the time of start for the query, this field + follows RFC3339 time format + format: date-time + type: string + to: + description: To is the time of end for the query, this field follows + RFC3339 time format + format: date-time + type: string + required: + - from + - to + type: object + required: + - analysisDefinition + - timeframe + type: object + status: + type: string + type: object + served: true + storage: true + subresources: + status: {} diff --git a/metrics-operator/config/crd/kustomization.yaml b/metrics-operator/config/crd/kustomization.yaml index e32b655345..474932803b 100644 --- a/metrics-operator/config/crd/kustomization.yaml +++ b/metrics-operator/config/crd/kustomization.yaml @@ -4,6 +4,7 @@ resources: - bases/metrics.keptn.sh_keptnmetricsproviders.yaml - bases/metrics.keptn.sh_keptnmetrics.yaml + - bases/metrics.keptn.sh_analyses.yaml - bases/metrics.keptn.sh_analysisdefinitions.yaml # +kubebuilder:scaffold:crdkustomizeresource @@ -12,6 +13,7 @@ patchesStrategicMerge: # patches here are for enabling the conversion webhook for each CRD # - patches/webhook_in_keptnmetricsproviders.yaml - patches/webhook_in_keptnmetrics.yaml +#- patches/webhook_in_analyses.yaml # - patches/webhook_in_analysisdefinitions.yaml # +kubebuilder:scaffold:crdkustomizewebhookpatch @@ -19,6 +21,7 @@ patchesStrategicMerge: # patches here are for enabling the CA injection for each CRD # - patches/cainjection_in_keptnmetricsproviders.yaml # - patches/cainjection_in_keptnmetrics.yaml +#- patches/cainjection_in_analyses.yaml # - patches/cainjection_in_analysisdefinitions.yaml # +kubebuilder:scaffold:crdkustomizecainjectionpatch diff --git a/metrics-operator/config/crd/patches/webhook_in_analyses.yaml b/metrics-operator/config/crd/patches/webhook_in_analyses.yaml new file mode 100644 index 0000000000..cc2fd29d8a --- /dev/null +++ b/metrics-operator/config/crd/patches/webhook_in_analyses.yaml @@ -0,0 +1,16 @@ +# The following patch enables a conversion webhook for the CRD +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + name: analyses.metrics.keptn.sh +spec: + conversion: + strategy: Webhook + webhook: + clientConfig: + service: + namespace: system + name: webhook-service + path: /convert + conversionReviewVersions: + - v1 diff --git a/metrics-operator/config/rbac/analysis_editor_role.yaml b/metrics-operator/config/rbac/analysis_editor_role.yaml new file mode 100644 index 0000000000..4c87c2cbbe --- /dev/null +++ b/metrics-operator/config/rbac/analysis_editor_role.yaml @@ -0,0 +1,31 @@ +# permissions for end users to edit analyses. +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + labels: + app.kubernetes.io/name: clusterrole + app.kubernetes.io/instance: analysis-editor-role + app.kubernetes.io/component: rbac + app.kubernetes.io/created-by: metrics-operator + app.kubernetes.io/part-of: metrics-operator + app.kubernetes.io/managed-by: kustomize + name: analysis-editor-role +rules: + - apiGroups: + - metrics.keptn.sh + resources: + - analyses + verbs: + - create + - delete + - get + - list + - patch + - update + - watch + - apiGroups: + - metrics.keptn.sh + resources: + - analyses/status + verbs: + - get diff --git a/metrics-operator/config/rbac/analysis_viewer_role.yaml b/metrics-operator/config/rbac/analysis_viewer_role.yaml new file mode 100644 index 0000000000..2d7243c872 --- /dev/null +++ b/metrics-operator/config/rbac/analysis_viewer_role.yaml @@ -0,0 +1,27 @@ +# permissions for end users to view analyses. +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + labels: + app.kubernetes.io/name: clusterrole + app.kubernetes.io/instance: analysis-viewer-role + app.kubernetes.io/component: rbac + app.kubernetes.io/created-by: metrics-operator + app.kubernetes.io/part-of: metrics-operator + app.kubernetes.io/managed-by: kustomize + name: analysis-viewer-role +rules: + - apiGroups: + - metrics.keptn.sh + resources: + - analyses + verbs: + - get + - list + - watch + - apiGroups: + - metrics.keptn.sh + resources: + - analyses/status + verbs: + - get diff --git a/metrics-operator/config/samples/metrics_v1alpha3_analysis.yaml b/metrics-operator/config/samples/metrics_v1alpha3_analysis.yaml new file mode 100644 index 0000000000..a58ee8466b --- /dev/null +++ b/metrics-operator/config/samples/metrics_v1alpha3_analysis.yaml @@ -0,0 +1,21 @@ +apiVersion: metrics.keptn.sh/v1alpha3 +kind: Analysis +metadata: + labels: + app.kubernetes.io/name: analysis + app.kubernetes.io/instance: analysis-sample + app.kubernetes.io/part-of: metrics-operator + app.kuberentes.io/managed-by: kustomize + app.kubernetes.io/created-by: metrics-operator + name: analysis-sample +spec: + timeframe: + from: 2023-05-05T05:05:05Z + to: 2023-05-05T10:10:10Z + args: + project: my-project + stage: dev + service: svc1 + foo: bar # can be any key/value pair; NOT only project/stage/service + analysisDefinition: + name: ed-my-proj-dev-svc1 diff --git a/test/integration/analysis/00-assert.yaml b/test/integration/analysis/00-assert.yaml new file mode 100644 index 0000000000..a58ee8466b --- /dev/null +++ b/test/integration/analysis/00-assert.yaml @@ -0,0 +1,21 @@ +apiVersion: metrics.keptn.sh/v1alpha3 +kind: Analysis +metadata: + labels: + app.kubernetes.io/name: analysis + app.kubernetes.io/instance: analysis-sample + app.kubernetes.io/part-of: metrics-operator + app.kuberentes.io/managed-by: kustomize + app.kubernetes.io/created-by: metrics-operator + name: analysis-sample +spec: + timeframe: + from: 2023-05-05T05:05:05Z + to: 2023-05-05T10:10:10Z + args: + project: my-project + stage: dev + service: svc1 + foo: bar # can be any key/value pair; NOT only project/stage/service + analysisDefinition: + name: ed-my-proj-dev-svc1 diff --git a/test/integration/analysis/00-install.yaml b/test/integration/analysis/00-install.yaml new file mode 100644 index 0000000000..a58ee8466b --- /dev/null +++ b/test/integration/analysis/00-install.yaml @@ -0,0 +1,21 @@ +apiVersion: metrics.keptn.sh/v1alpha3 +kind: Analysis +metadata: + labels: + app.kubernetes.io/name: analysis + app.kubernetes.io/instance: analysis-sample + app.kubernetes.io/part-of: metrics-operator + app.kuberentes.io/managed-by: kustomize + app.kubernetes.io/created-by: metrics-operator + name: analysis-sample +spec: + timeframe: + from: 2023-05-05T05:05:05Z + to: 2023-05-05T10:10:10Z + args: + project: my-project + stage: dev + service: svc1 + foo: bar # can be any key/value pair; NOT only project/stage/service + analysisDefinition: + name: ed-my-proj-dev-svc1