-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add MetadataProfile CRDs and template
- Loading branch information
1 parent
f6f51f5
commit a7b4015
Showing
5 changed files
with
312 additions
and
0 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
manifests/autotune/metadata-profiles/cluster_metadata_local_monitoring.json
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,47 @@ | ||
{ | ||
"apiVersion": "recommender.com/v1", | ||
"kind": "KruizeMetadataProfile", | ||
"metadata": { | ||
"name": "cluster-metadata-local-monitoring" | ||
}, | ||
"profile_version": 1, | ||
"k8s_type": "openshift", | ||
"query_variables": [ | ||
{ | ||
"name": "namespacesAcrossCluster", | ||
"datasource": "prometheus", | ||
"value_type": "double", | ||
"kubernetes_object": "container", | ||
"aggregation_functions": [ | ||
{ | ||
"function": "sum", | ||
"query": "sum by (namespace) (avg_over_time(kube_namespace_status_phase{namespace!=\"\"}[$MEASUREMENT_DURATION_IN_MIN$m]))" | ||
} | ||
] | ||
}, | ||
{ | ||
"name": "workloadsAcrossCluster", | ||
"datasource": "prometheus", | ||
"value_type": "double", | ||
"kubernetes_object": "container", | ||
"aggregation_functions": [ | ||
{ | ||
"function": "sum", | ||
"query": "sum by (namespace, workload, workload_type) (avg_over_time(namespace_workload_pod:kube_pod_owner:relabel{workload!=\"\"}[$MEASUREMENT_DURATION_IN_MIN$m]))" | ||
} | ||
] | ||
}, | ||
{ | ||
"name": "containersAcrossCluster", | ||
"datasource": "prometheus", | ||
"value_type": "double", | ||
"kubernetes_object": "container", | ||
"aggregation_functions": [ | ||
{ | ||
"function": "sum", | ||
"query": "sum by (container, image, workload, workload_type, namespace) (avg_over_time(kube_pod_container_info{container!=\"\"}[$MEASUREMENT_DURATION_IN_MIN$m]) * on (pod, namespace) group_left(workload, workload_type) avg_over_time(namespace_workload_pod:kube_pod_owner:relabel{workload!=\"\"}[$MEASUREMENT_DURATION_IN_MIN$m]))" | ||
} | ||
] | ||
} | ||
] | ||
} |
31 changes: 31 additions & 0 deletions
31
manifests/autotune/metadata-profiles/cluster_metadata_local_monitoring.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,31 @@ | ||
apiVersion: "recommender.com/v1" | ||
kind: "KruizeMetadataProfile" | ||
metadata: | ||
name: "cluster-metadata-local-monitoring" | ||
profile_version: 1.0 | ||
k8s_type: openshift | ||
query_variables: | ||
|
||
- name: namespacesAcrossCluster | ||
datasource: prometheus | ||
value_type: "double" | ||
kubernetes_object: "namespace" | ||
aggregation_functions: | ||
- function: sum | ||
query: 'sum by (namespace) (avg_over_time(kube_namespace_status_phase{namespace!=""}[$MEASUREMENT_DURATION_IN_MIN$d]))' | ||
|
||
- name: workloadsAcrossCluster | ||
datasource: prometheus | ||
value_type: "double" | ||
kubernetes_object: "container" | ||
aggregation_functions: | ||
- function: sum | ||
query: 'sum by (namespace, workload, workload_type) (avg_over_time(namespace_workload_pod:kube_pod_owner:relabel{workload!=""}[$MEASUREMENT_DURATION_IN_MIN$d]))' | ||
|
||
- name: containersAcrossCluster | ||
datasource: prometheus | ||
value_type: "double" | ||
kubernetes_object: "container" | ||
aggregation_functions: | ||
- function: sum | ||
query: 'sum by (container, image, workload, workload_type, namespace) (avg_over_time(kube_pod_container_info{container!=""}[$MEASUREMENT_DURATION_IN_MIN$d]) * on (pod, namespace) group_left(workload, workload_type) avg_over_time(namespace_workload_pod:kube_pod_owner:relabel{workload!=""}[$MEASUREMENT_DURATION_IN_MIN$d]))' |
85 changes: 85 additions & 0 deletions
85
manifests/autotune/metadata-profiles/kruize-metadata-profile-crd.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,85 @@ | ||
apiVersion: "recommender.com/v1" | ||
kind: CustomResourceDefinition | ||
metadata: | ||
#name must match the spec fields below, and be in the form: <plural>.<group> | ||
name: kruizemetadataprofiles.recommender.com | ||
spec: | ||
# group name to use for REST API: /apis/<group>/<version> | ||
group: "recommender.com" | ||
names: | ||
plural: kruizemetadataprofiles | ||
singular: kruizemetadataprofile | ||
#types can be identified with this tag | ||
kind: KruizeMetadataProfile | ||
scope: Namespaced | ||
versions: | ||
- name: v1 | ||
served: true | ||
storage: true | ||
schema: | ||
openAPIV3Schema: | ||
type: object | ||
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 | ||
profile_version: | ||
description: 'Version of the profile' | ||
type: number | ||
k8s_type: | ||
description: 'minikube or openshift' | ||
type: string | ||
query_variables: | ||
description: 'Query variables to be used' | ||
type: array | ||
items: | ||
type: object | ||
properties: | ||
name: | ||
description: 'name of the variable' | ||
type: string | ||
datasource: | ||
description: 'datasource of the query' | ||
type: string | ||
value_type: | ||
description: 'can be double or integer' | ||
type: string | ||
kubernetes_object: | ||
description: 'k8s object that this query is tied to: "deployment", "pod", "namespace" or "container"' | ||
type: string | ||
query: | ||
description: 'one of the query or aggregation_functions is mandatory' | ||
type: string | ||
aggregation_functions: | ||
description: 'one of the query or aggregation_functions is mandatory' | ||
type: array | ||
items: | ||
type: object | ||
properties: | ||
function: | ||
description: 'aggregate functions associated with this variable' | ||
type: string | ||
query: | ||
description: 'query' | ||
type: string | ||
version: | ||
description: 'Any specific version that this query is tied to' | ||
type: string | ||
required: | ||
- function | ||
- query | ||
required: | ||
- name | ||
- datasource | ||
- value_type | ||
required: | ||
- query_variables |
87 changes: 87 additions & 0 deletions
87
manifests/autotune/metadata-profiles/kruize-metadata-profile-supported-queries.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,87 @@ | ||
apiVersion: "recommender.com/v1" | ||
kind: "KruizeMetadataProfile" | ||
metadata: | ||
name: "cluster-metadata-local-monitoring" | ||
profile_version: 1.0 | ||
k8s_type: openshift | ||
query_variables: | ||
|
||
# list of namespaces across cluster | ||
- name: 'namespacesAcrossCluster' | ||
datasource: prometheus | ||
kubernetes_object: "container" # or namespace | ||
aggregation_functions: | ||
- function: sum | ||
query: 'sum by (namespace) (avg_over_time(kube_namespace_status_phase{namespace!=""}[15d]))' | ||
|
||
|
||
# list of namespaces for specified org_id and cluster_id | ||
- name: 'namespacesForOrgAndClusterId' | ||
datasource: prometheus | ||
kubernetes_object: "container" # or namespace | ||
aggregation_functions: | ||
- function: sum | ||
query: 'sum by (namespace) (avg_over_time(kube_namespace_status_phase{namespace!="", org_id="$org_id$", cluster_id="$cluster_id$"}[15d]))' | ||
|
||
|
||
# list of namespaces for user specified custom label | ||
- name: 'namespacesForAdditionalLabel' # or 'namespacesForCustomLabel' | ||
datasource: prometheus | ||
kubernetes_object: "container" # or namespace | ||
aggregation_functions: | ||
- function: sum | ||
query: 'sum by (namespace) (avg_over_time(kube_namespace_status_phase{namespace!=""}[15d]))' | ||
|
||
|
||
# list of all the workloads across cluster | ||
- name: 'workloadsAcrossCluster' | ||
datasource: prometheus | ||
kubernetes_object: "container" | ||
aggregation_functions: | ||
- function: sum | ||
query: 'sum by (namespace, workload, workload_type) (avg_over_time(namespace_workload_pod:kube_pod_owner:relabel{workload!=""}[15d]))' | ||
|
||
|
||
# list of workloads for specified org_id and cluster_id | ||
- name: 'workloadsForOrgAndClusterId' | ||
datasource: prometheus | ||
kubernetes_object: "container" | ||
aggregation_functions: | ||
- function: sum | ||
query: 'sum by (namespace, workload, workload_type) (avg_over_time(namespace_workload_pod:kube_pod_owner:relabel{workload!="", org_id="$org_id$", cluster_id="$cluster_id$"}[15d]))' | ||
|
||
|
||
# list of workloads for user specified custom label | ||
- name: 'workloadsForAdditionalLabel' # or 'workloadsForCustomLabel' | ||
datasource: prometheus | ||
kubernetes_object: "container" | ||
aggregation_functions: | ||
- function: sum | ||
query: 'sum by (namespace, workload, workload_type) (avg_over_time(namespace_workload_pod:kube_pod_owner:relabel{workload!="" ADDITIONAL_LABEL}[15d]))' | ||
|
||
|
||
# list of all the containers across cluster | ||
- name: 'containersAcrossCluster' | ||
datasource: prometheus | ||
kubernetes_object: "container" | ||
aggregation_functions: | ||
- function: sum | ||
query: 'sum by (container, image, workload, workload_type, namespace) (avg_over_time(kube_pod_container_info{container!=""}[15d]) * on (pod, namespace) group_left(workload, workload_type) avg_over_time(namespace_workload_pod:kube_pod_owner:relabel{workload!=""}[15d]))' | ||
|
||
|
||
# list of containers for specified org_id and cluster_id | ||
- name: 'containersForOrgAndClusterId' | ||
datasource: prometheus | ||
kubernetes_object: "container" | ||
aggregation_functions: | ||
- function: sum | ||
query: 'sum by (container, image, workload, workload_type, namespace) (avg_over_time(kube_pod_container_info{container!="", org_id="$org_id$", cluster_id="$cluster_id$"}[15d]) * on (pod, namespace) group_left(workload, workload_type) avg_over_time(namespace_workload_pod:kube_pod_owner:relabel{workload!="", org_id="$org_id$", cluster_id="$cluster_id$"}[15d]))' | ||
|
||
|
||
# list of containers for user specified custom label | ||
- name: 'containersForAdditionalLabel' # or 'containersForCustomLabel' | ||
datasource: prometheus | ||
kubernetes_object: "container" | ||
aggregation_functions: | ||
- function: sum | ||
query: 'sum by (container, image, workload, workload_type, namespace) (avg_over_time(kube_pod_container_info{container!="" ADDITIONAL_LABEL}[15d]) * on (pod, namespace) group_left(workload, workload_type) avg_over_time(namespace_workload_pod:kube_pod_owner:relabel{workload!="" ADDITIONAL_LABEL}[15d]))' |
62 changes: 62 additions & 0 deletions
62
manifests/autotune/metadata-profiles/metadata-profile-template.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,62 @@ | ||
apiVersion: "recommender.com/v1" | ||
kind: "KruizeMetadataProfile" | ||
metadata: | ||
name: "add_name_here" | ||
|
||
# Version of the profile. | ||
# This helps when queries change often | ||
profile_version: 1.0 | ||
|
||
# Is this for a specific kubernetes type? | ||
# OPTIONAL. | ||
# If not present, assumed to be used universally. | ||
# If specified, it should have a corresponding config in | ||
# manifests/configmaps dir (i.e. supported target by Kruize) | ||
# Eg. manifests/configmaps/openshift-config.yaml | ||
k8s_type: openshift | ||
|
||
# Describe the query variables to be used | ||
# MANDATORY | ||
query_variables: | ||
|
||
# name of the variable | ||
# MANDATORY | ||
- name: namespacesAcrossCluster | ||
# datasource of the query | ||
# MANDATORY | ||
datasource: prometheus | ||
# value_type. Supported are "double" or "integer". | ||
# MANDATORY | ||
value_type: "double" | ||
|
||
# Any k8s object that this query is tied to | ||
# eg. "deployment", "pod", "container" | ||
# OPTIONAL | ||
kubernetes_object: "namespace" | ||
|
||
# One of query or aggregation_functions mandatory | ||
# Both can be present together | ||
query: 'sum by (namespace) (avg_over_time(kube_namespace_status_phase{namespace!=""}[$MEASUREMENT_DURATION_IN_MIN$d]))' | ||
|
||
# aggregate functions associated with this variable | ||
# Eg. "avg", "sum", "max", "min" | ||
aggregation_functions: | ||
# MANDATORY | ||
- function: sum | ||
# query | ||
# MANDATORY | ||
query: 'sum by (namespace) (avg_over_time(kube_namespace_status_phase{namespace!=""}[$MEASUREMENT_DURATION_IN_MIN$d]))' | ||
|
||
# Any specific versions that this query is tied to | ||
# OPTIONAL | ||
version: ">4.9" | ||
|
||
# list of all the workloads present in the cluster | ||
- name: workloadsAcrossCluster | ||
datasource: prometheus | ||
value_type: "double" | ||
kubernetes_object: "container" | ||
# sum of the pod ownership metrics, grouped by namespace, workload, and workload_type, filtering out empty workloads. | ||
aggregation_functions: | ||
- function: sum | ||
query: 'sum by (namespace, workload, workload_type) (avg_over_time(namespace_workload_pod:kube_pod_owner:relabel{workload!=""}[$MEASUREMENT_DURATION_IN_MIN$d]))' |