Skip to content
Snippets Groups Projects
Commit 7da6b047 authored by Kemal Akkoyun's avatar Kemal Akkoyun
Browse files

Remove ksonnet from jsonnet/kube-prometheus/kube-prometheus-custom-metrics.libsonnet

parent 6d641706
No related branches found
No related tags found
No related merge requests found
local k = import 'github.com/ksonnet/ksonnet-lib/ksonnet.beta.4/k.libsonnet';
// Custom metrics API allows the HPA v2 to scale based on arbirary metrics. // Custom metrics API allows the HPA v2 to scale based on arbirary metrics.
// For more details on usage visit https://github.com/DirectXMan12/k8s-prometheus-adapter#quick-links // For more details on usage visit https://github.com/DirectXMan12/k8s-prometheus-adapter#quick-links
...@@ -14,19 +12,12 @@ local k = import 'github.com/ksonnet/ksonnet-lib/ksonnet.beta.4/k.libsonnet'; ...@@ -14,19 +12,12 @@ local k = import 'github.com/ksonnet/ksonnet-lib/ksonnet.beta.4/k.libsonnet';
seriesFilters: [], seriesFilters: [],
resources: { resources: {
overrides: { overrides: {
namespace: { namespace: { resource: 'namespace' },
resource: 'namespace' pod: { resource: 'pod' },
},
pod: {
resource: 'pod'
}
}, },
}, },
name: { name: { matches: '^container_(.*)_seconds_total$', as: '' },
matches: '^container_(.*)_seconds_total$', metricsQuery: 'sum(rate(<<.Series>>{<<.LabelMatchers>>,container!="POD"}[1m])) by (<<.GroupBy>>)',
as: ""
},
metricsQuery: 'sum(rate(<<.Series>>{<<.LabelMatchers>>,container!="POD"}[1m])) by (<<.GroupBy>>)'
}, },
{ {
seriesQuery: '{__name__=~"^container_.*",container!="POD",namespace!="",pod!=""}', seriesQuery: '{__name__=~"^container_.*",container!="POD",namespace!="",pod!=""}',
...@@ -35,19 +26,12 @@ local k = import 'github.com/ksonnet/ksonnet-lib/ksonnet.beta.4/k.libsonnet'; ...@@ -35,19 +26,12 @@ local k = import 'github.com/ksonnet/ksonnet-lib/ksonnet.beta.4/k.libsonnet';
], ],
resources: { resources: {
overrides: { overrides: {
namespace: { namespace: { resource: 'namespace' },
resource: 'namespace' pod: { resource: 'pod' },
},
pod: {
resource: 'pod'
}
}, },
}, },
name: { name: { matches: '^container_(.*)_total$', as: '' },
matches: '^container_(.*)_total$', metricsQuery: 'sum(rate(<<.Series>>{<<.LabelMatchers>>,container!="POD"}[1m])) by (<<.GroupBy>>)',
as: ''
},
metricsQuery: 'sum(rate(<<.Series>>{<<.LabelMatchers>>,container!="POD"}[1m])) by (<<.GroupBy>>)'
}, },
{ {
seriesQuery: '{__name__=~"^container_.*",container!="POD",namespace!="",pod!=""}', seriesQuery: '{__name__=~"^container_.*",container!="POD",namespace!="",pod!=""}',
...@@ -56,60 +40,38 @@ local k = import 'github.com/ksonnet/ksonnet-lib/ksonnet.beta.4/k.libsonnet'; ...@@ -56,60 +40,38 @@ local k = import 'github.com/ksonnet/ksonnet-lib/ksonnet.beta.4/k.libsonnet';
], ],
resources: { resources: {
overrides: { overrides: {
namespace: { namespace: { resource: 'namespace' },
resource: 'namespace' pod: { resource: 'pod' },
},
pod: {
resource: 'pod'
}
}, },
}, },
name: { name: { matches: '^container_(.*)$', as: '' },
matches: '^container_(.*)$', metricsQuery: 'sum(<<.Series>>{<<.LabelMatchers>>,container!="POD"}) by (<<.GroupBy>>)',
as: ''
},
metricsQuery: 'sum(<<.Series>>{<<.LabelMatchers>>,container!="POD"}) by (<<.GroupBy>>)'
}, },
{ {
seriesQuery: '{namespace!="",__name__!~"^container_.*"}', seriesQuery: '{namespace!="",__name__!~"^container_.*"}',
seriesFilters: [ seriesFilters: [
{ isNot: '.*_total$' }, { isNot: '.*_total$' },
], ],
resources: { resources: { template: '<<.Resource>>' },
template: '<<.Resource>>' name: { matches: '', as: '' },
}, metricsQuery: 'sum(<<.Series>>{<<.LabelMatchers>>}) by (<<.GroupBy>>)',
name: {
matches: '',
as: ''
},
metricsQuery: 'sum(<<.Series>>{<<.LabelMatchers>>}) by (<<.GroupBy>>)'
}, },
{ {
seriesQuery: '{namespace!="",__name__!~"^container_.*"}', seriesQuery: '{namespace!="",__name__!~"^container_.*"}',
seriesFilters: [ seriesFilters: [
{ isNot: '.*_seconds_total' }, { isNot: '.*_seconds_total' },
], ],
resources: { resources: { template: '<<.Resource>>' },
template: '<<.Resource>>' name: { matches: '^(.*)_total$', as: '' },
}, metricsQuery: 'sum(rate(<<.Series>>{<<.LabelMatchers>>}[1m])) by (<<.GroupBy>>)',
name: {
matches: '^(.*)_total$',
as: ''
},
metricsQuery: 'sum(rate(<<.Series>>{<<.LabelMatchers>>}[1m])) by (<<.GroupBy>>)'
}, },
{ {
seriesQuery: '{namespace!="",__name__!~"^container_.*"}', seriesQuery: '{namespace!="",__name__!~"^container_.*"}',
seriesFilters: [], seriesFilters: [],
resources: { resources: { template: '<<.Resource>>' },
template: '<<.Resource>>' name: { matches: '^(.*)_seconds_total$', as: '' },
}, metricsQuery: 'sum(rate(<<.Series>>{<<.LabelMatchers>>}[1m])) by (<<.GroupBy>>)',
name: { },
matches: '^(.*)_seconds_total$',
as: ''
},
metricsQuery: 'sum(rate(<<.Series>>{<<.LabelMatchers>>}[1m])) by (<<.GroupBy>>)'
}
], ],
}, },
}, },
...@@ -152,46 +114,53 @@ local k = import 'github.com/ksonnet/ksonnet-lib/ksonnet.beta.4/k.libsonnet'; ...@@ -152,46 +114,53 @@ local k = import 'github.com/ksonnet/ksonnet-lib/ksonnet.beta.4/k.libsonnet';
versionPriority: 200, versionPriority: 200,
}, },
}, },
customMetricsClusterRoleServerResources: customMetricsClusterRoleServerResources: {
local clusterRole = k.rbac.v1.clusterRole; apiVersion: 'rbac.authorization.k8s.io/v1',
local policyRule = clusterRole.rulesType; kind: 'ClusterRole',
metadata: {
local rules = name: 'custom-metrics-server-resources',
policyRule.new() + },
policyRule.withApiGroups(['custom.metrics.k8s.io']) + rules: [{
policyRule.withResources(['*']) + apiGroups: ['custom.metrics.k8s.io'],
policyRule.withVerbs(['*']); resources: ['*'],
verbs: ['*'],
clusterRole.new() + }],
clusterRole.mixin.metadata.withName('custom-metrics-server-resources') + },
clusterRole.withRules(rules), customMetricsClusterRoleBindingServerResources: {
apiVersion: 'rbac.authorization.k8s.io/v1',
customMetricsClusterRoleBindingServerResources: kind: 'ClusterRoleBinding',
local clusterRoleBinding = k.rbac.v1.clusterRoleBinding; metadata: {
name: 'custom-metrics-server-resources',
},
clusterRoleBinding.new() + roleRef: {
clusterRoleBinding.mixin.metadata.withName('custom-metrics-server-resources') + apiGroup: 'rbac.authorization.k8s.io',
clusterRoleBinding.mixin.roleRef.withApiGroup('rbac.authorization.k8s.io') + kind: 'ClusterRole',
clusterRoleBinding.mixin.roleRef.withName('custom-metrics-server-resources') + name: 'custom-metrics-server-resources',
clusterRoleBinding.mixin.roleRef.mixinInstance({ kind: 'ClusterRole' }) + },
clusterRoleBinding.withSubjects([{ subjects: [{
kind: 'ServiceAccount', kind: 'ServiceAccount',
name: $.prometheusAdapter.serviceAccount.metadata.name, name: $.prometheusAdapter.serviceAccount.metadata.name,
namespace: $._config.namespace, namespace: $._config.namespace,
}]), }],
},
customMetricsClusterRoleBindingHPA: customMetricsClusterRoleBindingHPA: {
local clusterRoleBinding = k.rbac.v1.clusterRoleBinding; apiVersion: 'rbac.authorization.k8s.io/v1',
kind: 'ClusterRoleBinding',
metadata: {
name: 'hpa-controller-custom-metrics',
},
clusterRoleBinding.new() + roleRef: {
clusterRoleBinding.mixin.metadata.withName('hpa-controller-custom-metrics') + apiGroup: 'rbac.authorization.k8s.io',
clusterRoleBinding.mixin.roleRef.withApiGroup('rbac.authorization.k8s.io') + kind: 'ClusterRole',
clusterRoleBinding.mixin.roleRef.withName('custom-metrics-server-resources') + name: 'custom-metrics-server-resources',
clusterRoleBinding.mixin.roleRef.mixinInstance({ kind: 'ClusterRole' }) + },
clusterRoleBinding.withSubjects([{ subjects: [{
kind: 'ServiceAccount', kind: 'ServiceAccount',
name: 'horizontal-pod-autoscaler', name: 'horizontal-pod-autoscaler',
namespace: 'kube-system', namespace: 'kube-system',
}]), }],
} },
},
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment