Skip to content

Commit

Permalink
WIP: Graduate custom-metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
johanneswuerbach committed Jan 13, 2020
1 parent 67ed0f6 commit 6242793
Show file tree
Hide file tree
Showing 11 changed files with 48 additions and 253 deletions.
7 changes: 0 additions & 7 deletions experimental/custom-metrics-api/.gitignore

This file was deleted.

21 changes: 0 additions & 21 deletions experimental/custom-metrics-api/README.md

This file was deleted.

This file was deleted.

13 changes: 0 additions & 13 deletions experimental/custom-metrics-api/custom-metrics-apiservice.yaml

This file was deleted.

This file was deleted.

98 changes: 0 additions & 98 deletions experimental/custom-metrics-api/custom-metrics-configmap.yaml

This file was deleted.

7 changes: 0 additions & 7 deletions experimental/custom-metrics-api/deploy.sh

This file was deleted.

This file was deleted.

67 changes: 0 additions & 67 deletions experimental/custom-metrics-api/sample-app.yaml

This file was deleted.

7 changes: 0 additions & 7 deletions experimental/custom-metrics-api/teardown.sh

This file was deleted.

Expand Up @@ -68,6 +68,26 @@ local k = import 'ksonnet/ksonnet.beta.4/k.libsonnet';
},
},

customMetricsApiService:
{
apiVersion: 'apiregistration.k8s.io/v1',
kind: 'APIService',
metadata: {
name: 'v1beta1.custom.metrics.k8s.io',
},
spec: {
service: {
name: $.prometheusAdapter.service.metadata.name,
namespace: $._config.namespace,
},
group: 'custom.metrics.k8s.io',
version: 'v1beta1',
insecureSkipTLSVerify: true,
groupPriorityMinimum: 100,
versionPriority: 100,
},
},

configMap:
local configmap = k.core.v1.configMap;

Expand Down Expand Up @@ -217,5 +237,33 @@ local k = import 'ksonnet/ksonnet.beta.4/k.libsonnet';
name: $.prometheusAdapter.serviceAccount.metadata.name,
namespace: $._config.namespace,
}]),

customMetricsClusterRoleServerResources:
local clusterRole = k.rbac.v1.clusterRole;
local policyRule = clusterRole.rulesType;

local rules =
policyRule.new() +
policyRule.withApiGroups(['custom.metrics.k8s.io']) +
policyRule.withResources(['*']) +
policyRule.withVerbs(['*']);

clusterRole.new() +
clusterRole.mixin.metadata.withName('custom-metrics-server-resources') +
clusterRole.withRules(rules),

customMetricsClusterRoleBindingServerResources:
local clusterRoleBinding = k.rbac.v1.clusterRoleBinding;

clusterRoleBinding.new() +
clusterRoleBinding.mixin.metadata.withName('hpa-controller-custom-metrics') +
clusterRoleBinding.mixin.roleRef.withApiGroup('rbac.authorization.k8s.io') +
clusterRoleBinding.mixin.roleRef.withName('custom-metrics-server-resources') +
clusterRoleBinding.mixin.roleRef.mixinInstance({ kind: 'ClusterRole' }) +
clusterRoleBinding.withSubjects([{
kind: 'ServiceAccount',
name: 'horizontal-pod-autoscaler',
namespace: 'kube-system',
}]),
},
}

0 comments on commit 6242793

Please sign in to comment.