From b67686409e7bb10c25b47a492c176c60545b6f66 Mon Sep 17 00:00:00 2001 From: paulfantom <pawel@krupa.net.pl> Date: Thu, 14 Jan 2021 13:19:39 +0100 Subject: [PATCH] jsonnet: remove wrapping prometheus-operator lib --- .../prometheus-operator.libsonnet | 120 ++++++++---------- 1 file changed, 53 insertions(+), 67 deletions(-) diff --git a/jsonnet/kube-prometheus/prometheus-operator/prometheus-operator.libsonnet b/jsonnet/kube-prometheus/prometheus-operator/prometheus-operator.libsonnet index 91469503..26940c61 100644 --- a/jsonnet/kube-prometheus/prometheus-operator/prometheus-operator.libsonnet +++ b/jsonnet/kube-prometheus/prometheus-operator/prometheus-operator.libsonnet @@ -25,85 +25,71 @@ local defaults = { }, }; -function(params) { - local po = self, - config:: defaults + params, +function(params) + local config = defaults + params; // Safety check - assert std.isObject(po.config.resources), + assert std.isObject(config.resources); - //TODO(paulfantom): it would be better to include it on the same level as self. - local polib = prometheusOperator(po.config), + prometheusOperator(config) { + service+: { + spec+: { + ports: [ + { + name: 'https', + port: 8443, + targetPort: 'https', + }, + ], + }, + }, - '0alertmanagerConfigCustomResourceDefinition': polib['0alertmanagerConfigCustomResourceDefinition'], - '0alertmanagerCustomResourceDefinition': polib['0alertmanagerCustomResourceDefinition'], - '0podmonitorCustomResourceDefinition': polib['0podmonitorCustomResourceDefinition'], - '0probeCustomResourceDefinition': polib['0probeCustomResourceDefinition'], - '0prometheusCustomResourceDefinition': polib['0prometheusCustomResourceDefinition'], - '0prometheusruleCustomResourceDefinition': polib['0prometheusruleCustomResourceDefinition'], - '0servicemonitorCustomResourceDefinition': polib['0servicemonitorCustomResourceDefinition'], - '0thanosrulerCustomResourceDefinition': polib['0thanosrulerCustomResourceDefinition'], + serviceMonitor+: { + spec+: { + endpoints: [ + { + port: 'https', + scheme: 'https', + honorLabels: true, + bearerTokenFile: '/var/run/secrets/kubernetes.io/serviceaccount/token', + tlsConfig: { + insecureSkipVerify: true, + }, + }, + ], + }, + }, - serviceAccount: polib.serviceAccount, - service: polib.service { - spec+: { - ports: [ + clusterRole+: { + rules+: [ { - name: 'https', - port: 8443, - targetPort: 'https', + apiGroups: ['authentication.k8s.io'], + resources: ['tokenreviews'], + verbs: ['create'], }, - ], - }, - }, - - serviceMonitor: polib.serviceMonitor { - spec+: { - endpoints: [ { - port: 'https', - scheme: 'https', - honorLabels: true, - bearerTokenFile: '/var/run/secrets/kubernetes.io/serviceaccount/token', - tlsConfig: { - insecureSkipVerify: true, - }, + apiGroups: ['authorization.k8s.io'], + resources: ['subjectaccessreviews'], + verbs: ['create'], }, ], }, - }, - - clusterRoleBinding: polib.clusterRoleBinding, - clusterRole: polib.clusterRole { - rules+: [ - { - apiGroups: ['authentication.k8s.io'], - resources: ['tokenreviews'], - verbs: ['create'], - }, - { - apiGroups: ['authorization.k8s.io'], - resources: ['subjectaccessreviews'], - verbs: ['create'], - }, - ], - }, - local kubeRbacProxy = krp({ - name: 'kube-rbac-proxy', - upstream: 'http://127.0.0.1:8080/', - secureListenAddress: ':8443', - ports: [ - { name: 'https', containerPort: 8443 }, - ], - }), + local kubeRbacProxy = krp({ + name: 'kube-rbac-proxy', + upstream: 'http://127.0.0.1:8080/', + secureListenAddress: ':8443', + ports: [ + { name: 'https', containerPort: 8443 }, + ], + }), - deployment: polib.deployment { - spec+: { - template+: { - spec+: { - containers+: [kubeRbacProxy], + deployment+: { + spec+: { + template+: { + spec+: { + containers+: [kubeRbacProxy], + }, }, }, }, - }, -} + } -- GitLab