-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(operator): introduce KeptnMetrics CRD and controller (#643)
Signed-off-by: odubajDT <ondrej.dubaj@dynatrace.com> Signed-off-by: odubajDT <93584209+odubajDT@users.noreply.github.com> Co-authored-by: Moritz Wiesinger <moritz.wiesinger@dynatrace.com>
- Loading branch information
Showing
19 changed files
with
663 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
Copyright 2022. | ||
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 metrics v1alpha1 API group | ||
// +kubebuilder:object:generate=true | ||
// +groupName=metrics.keptn.sh | ||
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: "metrics.keptn.sh", 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 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/* | ||
Copyright 2022. | ||
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" | ||
) | ||
|
||
// 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. | ||
|
||
// KeptnMetricSpec defines the desired state of KeptnMetric | ||
type KeptnMetricSpec struct { | ||
// Provider represents the provider object | ||
Provider ProviderRef `json:"provider"` | ||
// Query represents the query to be run | ||
Query string `json:"query"` | ||
// FetchIntervalSeconds represents the update frequency in seconds that is used to update the metric | ||
FetchIntervalSeconds uint `json:"fetchIntervalSeconds"` | ||
} | ||
|
||
// KeptnMetricStatus defines the observed state of KeptnMetric | ||
type KeptnMetricStatus struct { | ||
// Value represents the resulting value | ||
Value string `json:"value"` | ||
// RawValue represents the resulting value in raw format | ||
RawValue []byte `json:"rawValue"` | ||
// LastUpdated represents the time when the status data was last updated | ||
LastUpdated metav1.Time `json:"lastUpdated"` | ||
} | ||
|
||
// ProviderRef represents the provider object | ||
type ProviderRef struct { | ||
// Name of the provider | ||
Name string `json:"name"` | ||
} | ||
|
||
//+kubebuilder:object:root=true | ||
//+kubebuilder:subresource:status | ||
//+kubebuilder:printcolumn:name="Provider",type=string,JSONPath=`.spec.provider.name` | ||
//+kubebuilder:printcolumn:name="Query",type=string,JSONPath=`.spec.query` | ||
//+kubebuilder:printcolumn:name="Value",type=string,JSONPath=`.status.value` | ||
|
||
// KeptnMetric is the Schema for the keptnmetrics API | ||
type KeptnMetric struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
Spec KeptnMetricSpec `json:"spec,omitempty"` | ||
Status KeptnMetricStatus `json:"status,omitempty"` | ||
} | ||
|
||
//+kubebuilder:object:root=true | ||
|
||
// KeptnMetricList contains a list of KeptnMetric | ||
type KeptnMetricList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata,omitempty"` | ||
Items []KeptnMetric `json:"items"` | ||
} | ||
|
||
func init() { | ||
SchemeBuilder.Register(&KeptnMetric{}, &KeptnMetricList{}) | ||
} |
137 changes: 137 additions & 0 deletions
137
operator/apis/metrics/v1alpha1/zz_generated.deepcopy.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
93 changes: 93 additions & 0 deletions
93
operator/config/crd/bases/metrics.keptn.sh_keptnmetrics.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
--- | ||
apiVersion: apiextensions.k8s.io/v1 | ||
kind: CustomResourceDefinition | ||
metadata: | ||
annotations: | ||
controller-gen.kubebuilder.io/version: v0.10.0 | ||
creationTimestamp: null | ||
name: keptnmetrics.metrics.keptn.sh | ||
spec: | ||
group: metrics.keptn.sh | ||
names: | ||
kind: KeptnMetric | ||
listKind: KeptnMetricList | ||
plural: keptnmetrics | ||
singular: keptnmetric | ||
scope: Namespaced | ||
versions: | ||
- additionalPrinterColumns: | ||
- jsonPath: .spec.source | ||
name: Provider | ||
type: string | ||
- jsonPath: .spec.query | ||
name: Query | ||
type: string | ||
- jsonPath: .status.value | ||
name: Value | ||
type: string | ||
name: v1alpha1 | ||
schema: | ||
openAPIV3Schema: | ||
description: KeptnMetric is the Schema for the keptnmetrics 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: KeptnMetricSpec defines the desired state of KeptnMetric | ||
properties: | ||
fetchIntervalSeconds: | ||
description: FetchIntervalSeconds represents the update frequency | ||
in seconds that is used to update the metric | ||
type: integer | ||
provider: | ||
description: Provider represents the provider object | ||
properties: | ||
name: | ||
description: Name of the provider | ||
type: string | ||
required: | ||
- name | ||
type: object | ||
query: | ||
description: Query represents the query to be run | ||
type: string | ||
required: | ||
- fetchIntervalSeconds | ||
- provider | ||
- query | ||
type: object | ||
status: | ||
description: KeptnMetricStatus defines the observed state of KeptnMetric | ||
properties: | ||
lastUpdated: | ||
description: LastUpdated represents the time when the status data | ||
was last updated | ||
format: date-time | ||
type: string | ||
rawValue: | ||
description: RawValue represents the resulting value in raw format | ||
format: byte | ||
type: string | ||
value: | ||
description: Value represents the resulting value | ||
type: string | ||
required: | ||
- lastUpdated | ||
- rawValue | ||
- value | ||
type: object | ||
type: object | ||
served: true | ||
storage: true | ||
subresources: | ||
status: {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
|
||
# Ignore autogen patch file for crds | ||
cainjection_in_*.yaml | ||
cainjection_in_*_*.yaml |
Oops, something went wrong.