Skip to content

Commit

Permalink
feat(metrics-operator): add Analysis CRD
Browse files Browse the repository at this point in the history
Signed-off-by: realanna <anna.reale@dynatrace.com>

feat(metrics-operator): fix ref

Signed-off-by: realanna <anna.reale@dynatrace.com>

Update lifecycle-operator/apis/lifecycle/v1alpha1/common/phases.go

Co-authored-by: odubajDT <93584209+odubajDT@users.noreply.github.com>
Signed-off-by: RealAnna <89971034+RealAnna@users.noreply.github.com>

feat(metrics-operator): make Ondrej happy

Signed-off-by: realanna <anna.reale@dynatrace.com>

feat(metrics-operator): sample times

Signed-off-by: realanna <anna.reale@dynatrace.com>

feat(metrics-operator): sample times

Signed-off-by: realanna <anna.reale@dynatrace.com>

feat(metrics-operator): sample times

Signed-off-by: realanna <anna.reale@dynatrace.com>

feat(metrics-operator): sample times

Signed-off-by: realanna <anna.reale@dynatrace.com>

Update lifecycle-operator/apis/lifecycle/v1alpha1/common/phases.go

Co-authored-by: Florian Bacher <florian.bacher@dynatrace.com>
Signed-off-by: RealAnna <89971034+RealAnna@users.noreply.github.com>

feat(metrics-operator): integrwtion test

Signed-off-by: realanna <anna.reale@dynatrace.com>

feat(metrics-operator): fix ref to Def

Signed-off-by: realanna <anna.reale@dynatrace.com>

feat(metrics-operator): fix review

Signed-off-by: realanna <anna.reale@dynatrace.com>

feat(metrics-operator): fix review

Signed-off-by: realanna <anna.reale@dynatrace.com>

Update docs/content/en/docs/crd-ref/metrics/v1alpha3/_index.md

Co-authored-by: Meg McRoberts <meg.mcroberts@dynatrace.com>
Signed-off-by: RealAnna <89971034+RealAnna@users.noreply.github.com>

Update metrics-operator/config/crd/bases/metrics.keptn.sh_analyses.yaml

Co-authored-by: Meg McRoberts <meg.mcroberts@dynatrace.com>
Signed-off-by: RealAnna <89971034+RealAnna@users.noreply.github.com>

Update docs/content/en/docs/crd-ref/metrics/v1alpha3/_index.md

Co-authored-by: Meg McRoberts <meg.mcroberts@dynatrace.com>
Signed-off-by: RealAnna <89971034+RealAnna@users.noreply.github.com>

Update docs/content/en/docs/crd-ref/metrics/v1alpha3/_index.md

Co-authored-by: Meg McRoberts <meg.mcroberts@dynatrace.com>
Signed-off-by: RealAnna <89971034+RealAnna@users.noreply.github.com>

Update metrics-operator/api/v1alpha3/analysis_types.go

Co-authored-by: Giovanni Liva <giovanni.liva@dynatrace.com>
Signed-off-by: RealAnna <89971034+RealAnna@users.noreply.github.com>

feat(metrics-operator): fix error

Signed-off-by: realanna <anna.reale@dynatrace.com>

feat(metrics-operator): fix error

Signed-off-by: realanna <anna.reale@dynatrace.com>

feat(metrics-operator): fix error

Signed-off-by: realanna <anna.reale@dynatrace.com>

feat(metrics-operator): regenerate crd md files

Signed-off-by: realanna <anna.reale@dynatrace.com>

feat(metrics-operator): regenerate crd md files

Signed-off-by: realanna <anna.reale@dynatrace.com>

feat(metrics-operator): remove wrong makefi;le change

Signed-off-by: realanna <anna.reale@dynatrace.com>

feat(metrics-operator): review

Signed-off-by: realanna <anna.reale@dynatrace.com>

feat(metrics-operator): review

Signed-off-by: realanna <anna.reale@dynatrace.com>

feat(metrics-operator): fix lint

Signed-off-by: realanna <anna.reale@dynatrace.com>

feat(metrics-operator): fix lint

Signed-off-by: realanna <anna.reale@dynatrace.com>

feat(metrics-operator): fix lint

Signed-off-by: realanna <anna.reale@dynatrace.com>

feat(metrics-operator): fix failing pipelines

Signed-off-by: realanna <anna.reale@dynatrace.com>

feat(metrics-operator): add integration test

Signed-off-by: realanna <anna.reale@dynatrace.com>

feat(metrics-operator): add example analysis CRD

Signed-off-by: realanna <anna.reale@dynatrace.com>

feat(metrics-operator): add analysis CRD

Signed-off-by: realanna <anna.reale@dynatrace.com>
  • Loading branch information
RealAnna committed Aug 8, 2023
1 parent adf4621 commit d436c91
Show file tree
Hide file tree
Showing 16 changed files with 482 additions and 274 deletions.
147 changes: 1 addition & 146 deletions docs/content/en/docs/crd-ref/metrics/v1alpha3/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,64 +13,13 @@ description: Reference information for metrics.keptn.sh/v1alpha3
Package v1alpha3 contains API Schema definitions for the metrics v1alpha3 API group

### Resource Types
- [AnalysisDefinition](#analysisdefinition)
- [AnalysisDefinitionList](#analysisdefinitionlist)
- [KeptnMetric](#keptnmetric)
- [KeptnMetricList](#keptnmetriclist)
- [KeptnMetricsProvider](#keptnmetricsprovider)
- [KeptnMetricsProviderList](#keptnmetricsproviderlist)



#### AnalysisDefinition



AnalysisDefinition is the Schema for the analysisdefinitions APIs

_Appears in:_
- [AnalysisDefinitionList](#analysisdefinitionlist)

| Field | Description |
| --- | --- |
| `apiVersion` _string_ | `metrics.keptn.sh/v1alpha3`
| `kind` _string_ | `AnalysisDefinition`
| `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` _[AnalysisDefinitionSpec](#analysisdefinitionspec)_ | |
| `status` _string_ | unused field |


#### AnalysisDefinitionList



AnalysisDefinitionList contains a list of AnalysisDefinition



| Field | Description |
| --- | --- |
| `apiVersion` _string_ | `metrics.keptn.sh/v1alpha3`
| `kind` _string_ | `AnalysisDefinitionList`
| `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` _[AnalysisDefinition](#analysisdefinition) array_ | |


#### AnalysisDefinitionSpec



AnalysisDefinitionSpec defines the desired state of AnalysisDefinition

_Appears in:_
- [AnalysisDefinition](#analysisdefinition)

| Field | Description |
| --- | --- |
| `objectives` _[Objective](#objective) array_ | Objectives defines a list of objectives to evaluate for an analysis |
| `totalScore` _[TotalScore](#totalscore)_ | TotalScore defines the required score for an analysis to be successful |


#### KeptnMetric


Expand Down Expand Up @@ -189,70 +138,6 @@ _Appears in:_
| `secretKeyRef` _[SecretKeySelector](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.24/#secretkeyselector-v1-core)_ | SecretKeyRef defines an optional secret for access credentials to the metrics provider. |


#### ObjectReference





_Appears in:_
- [Objective](#objective)

| Field | Description |
| --- | --- |
| `name` _string_ | Name defines the name of the referenced object |
| `namespace` _string_ | Namespace defines the namespace of the referenced object |


#### Objective



Objective defines an objective for analysis

_Appears in:_
- [AnalysisDefinitionSpec](#analysisdefinitionspec)

| Field | Description |
| --- | --- |
| `analysisValueTemplateRef` _[ObjectReference](#objectreference)_ | AnalysisValueTemplateRef refers to the appropriate AnalysisValueTemplate |
| `target` _[Target](#target)_ | Target defines failure or warning criteria |
| `weight` _integer_ | Weight can be used to emphasize the importance of one Objective over the others |
| `keyObjective` _boolean_ | KeyObjective defines whether the whole analysis fails when this objective's target is not met |


#### Operator



Operator specifies the supported operators for value comparisons

_Appears in:_
- [Target](#target)

| Field | Description |
| --- | --- |
| `lessThanOrEqual` _[OperatorValue](#operatorvalue)_ | LessThanOrEqual represents '<=' operator |
| `lessThan` _[OperatorValue](#operatorvalue)_ | LessThan represents '<' operator |
| `greaterThan` _[OperatorValue](#operatorvalue)_ | GreaterThan represents '>' operator |
| `greaterThanOrEqual` _[OperatorValue](#operatorvalue)_ | GreaterThanOrEqual represents '>=' operator |
| `equalTo` _[OperatorValue](#operatorvalue)_ | EqualTo represents '==' operator |


#### OperatorValue



OperatorValue represents the value to which the result is compared

_Appears in:_
- [Operator](#operator)

| Field | Description |
| --- | --- |
| `fixedValue` _Quantity_ | FixedValue defines the value for comparison |


#### ProviderRef


Expand Down Expand Up @@ -280,36 +165,6 @@ _Appears in:_
| --- | --- |
| `interval` _string_ | Interval specifies the duration of the time interval for the data query |
| `step` _string_ | Step represents the query resolution step width for the data query |
| `aggregation` _string_ | Aggregation defines the type of aggregation function to be applied on the data. Accepted values: p90, p95, p99, max, min, avg, median |


#### Target



Target defines the failure and warning criteria

_Appears in:_
- [Objective](#objective)

| Field | Description |
| --- | --- |
| `failure` _[Operator](#operator)_ | Failure defines limits up to which an analysis fails |
| `warning` _[Operator](#operator)_ | Warning defines limits where the result does not pass or fail |


#### TotalScore



TotalScore defines the required score for an analysis to be successful

_Appears in:_
- [AnalysisDefinitionSpec](#analysisdefinitionspec)

| Field | Description |
| --- | --- |
| `passPercentage` _integer_ | PassPercentage defines the threshold to reach for an analysis to pass |
| `warningPercentage` _integer_ | WarningPercentage defines the threshold to reach for an analysis to pass with a 'warning' status |
| `aggregation` _string_ | Aggregation defines as the type of aggregation function to be applied on the data. Accepted values: p90, p95, p99, max, min, avg, median |


93 changes: 93 additions & 0 deletions helm/chart/templates/analysis-crd.yaml
Original file line number Diff line number Diff line change
@@ -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: []
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 using OpenTelemetry propagation
MapCarrier type
type: object
postDeploymentEvaluationStatus:
default: Pending
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 using OpenTelemetry propagation
MapCarrier type
type: object
postDeploymentEvaluationStatus:
default: Pending
Expand Down
8 changes: 8 additions & 0 deletions metrics-operator/PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -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"
64 changes: 64 additions & 0 deletions metrics-operator/api/v1alpha3/analysis_types.go
Original file line number Diff line number Diff line change
@@ -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{})
}
Loading

0 comments on commit d436c91

Please sign in to comment.