jsonnet/kube-prometheus/kube-state-metrics: Move rules into array

This commit is contained in:
Matthias Loibl
2019-07-12 13:36:24 +02:00
committed by Lili Cosic
parent 2f1083be7e
commit 7d6183a9ec

View File

@@ -43,88 +43,89 @@ local k = import 'ksonnet/ksonnet.beta.4/k.libsonnet';
local clusterRole = k.rbac.v1.clusterRole; local clusterRole = k.rbac.v1.clusterRole;
local rulesType = clusterRole.rulesType; local rulesType = clusterRole.rulesType;
local coreRule = rulesType.new() + local rules = [
rulesType.withApiGroups(['']) + rulesType.new() +
rulesType.withResources([ rulesType.withApiGroups(['']) +
'configmaps', rulesType.withResources([
'secrets', 'configmaps',
'nodes', 'secrets',
'pods', 'nodes',
'services', 'pods',
'resourcequotas', 'services',
'replicationcontrollers', 'resourcequotas',
'limitranges', 'replicationcontrollers',
'persistentvolumeclaims', 'limitranges',
'persistentvolumes', 'persistentvolumeclaims',
'namespaces', 'persistentvolumes',
'endpoints', 'namespaces',
]) + 'endpoints',
rulesType.withVerbs(['list', 'watch']); ]) +
rulesType.withVerbs(['list', 'watch']),
local extensionsRule = rulesType.new() + rulesType.new() +
rulesType.withApiGroups(['extensions']) + rulesType.withApiGroups(['extensions']) +
rulesType.withResources([ rulesType.withResources([
'daemonsets', 'daemonsets',
'deployments', 'deployments',
'replicasets', 'replicasets',
'ingresses', 'ingresses',
]) + ]) +
rulesType.withVerbs(['list', 'watch']); rulesType.withVerbs(['list', 'watch']),
local appsRule = rulesType.new() + rulesType.new() +
rulesType.withApiGroups(['apps']) + rulesType.withApiGroups(['apps']) +
rulesType.withResources([ rulesType.withResources([
'statefulsets', 'statefulsets',
'daemonsets', 'daemonsets',
'deployments', 'deployments',
'replicasets', 'replicasets',
]) + ]) +
rulesType.withVerbs(['list', 'watch']); rulesType.withVerbs(['list', 'watch']),
local batchRule = rulesType.new() + rulesType.new() +
rulesType.withApiGroups(['batch']) + rulesType.withApiGroups(['batch']) +
rulesType.withResources([ rulesType.withResources([
'cronjobs', 'cronjobs',
'jobs', 'jobs',
]) + ]) +
rulesType.withVerbs(['list', 'watch']); rulesType.withVerbs(['list', 'watch']),
local autoscalingRule = rulesType.new() + rulesType.new() +
rulesType.withApiGroups(['autoscaling']) + rulesType.withApiGroups(['autoscaling']) +
rulesType.withResources([ rulesType.withResources([
'horizontalpodautoscalers', 'horizontalpodautoscalers',
]) + ]) +
rulesType.withVerbs(['list', 'watch']); rulesType.withVerbs(['list', 'watch']),
local authenticationRole = rulesType.new() + rulesType.new() +
rulesType.withApiGroups(['authentication.k8s.io']) + rulesType.withApiGroups(['authentication.k8s.io']) +
rulesType.withResources([ rulesType.withResources([
'tokenreviews', 'tokenreviews',
]) + ]) +
rulesType.withVerbs(['create']); rulesType.withVerbs(['create']),
local authorizationRole = rulesType.new() + rulesType.new() +
rulesType.withApiGroups(['authorization.k8s.io']) + rulesType.withApiGroups(['authorization.k8s.io']) +
rulesType.withResources([ rulesType.withResources([
'subjectaccessreviews', 'subjectaccessreviews',
]) + ]) +
rulesType.withVerbs(['create']); rulesType.withVerbs(['create']),
local policyRule = rulesType.new() + rulesType.new() +
rulesType.withApiGroups(['policy']) + rulesType.withApiGroups(['policy']) +
rulesType.withResources([ rulesType.withResources([
'poddisruptionbudgets', 'poddisruptionbudgets',
]) + ]) +
rulesType.withVerbs(['list', 'watch']); rulesType.withVerbs(['list', 'watch']),
local certificateRule = rulesType.new() +
rulesType.withApiGroups(['certificates.k8s.io']) +
rulesType.withResources([
'certificatesigningrequests',
]) +
rulesType.withVerbs(['list', 'watch']);
local rules = [coreRule, extensionsRule, appsRule, batchRule, autoscalingRule, authenticationRole, authorizationRole, policyRule, certificateRule]; rulesType.new() +
rulesType.withApiGroups(['certificates.k8s.io']) +
rulesType.withResources([
'certificatesigningrequests',
]) +
rulesType.withVerbs(['list', 'watch']),
];
clusterRole.new() + clusterRole.new() +
clusterRole.mixin.metadata.withName('kube-state-metrics') + clusterRole.mixin.metadata.withName('kube-state-metrics') +