From 7be0b80cf0a9e66ebb4e8cb95ce3ba7b5e565533 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Prud=27homme?= Date: Tue, 8 Jan 2019 17:08:09 +0100 Subject: [PATCH] [stable/prometheus-operator] Resolve scraping controller-manager and scheduler outside out the cluster (#10366) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [stable/prometheus-operator] Resolve scraping controller-manager and scheduler outside out the cluster Signed-off-by: Sébastien Prud'homme * [stable/prometheus-operator] Bump version Signed-off-by: Sébastien Prud'homme --- stable/prometheus-operator/Chart.yaml | 2 +- stable/prometheus-operator/README.md | 6 ++++++ .../prometheus-operator/ci/test-values.yaml | 20 +++++++++++++++++++ .../kube-controller-manager/endpoints.yaml | 20 +++++++++++++++++++ .../kube-controller-manager/service.yaml | 3 +++ .../exporters/kube-scheduler/endpoints.yaml | 20 +++++++++++++++++++ .../exporters/kube-scheduler/service.yaml | 2 ++ stable/prometheus-operator/values.yaml | 20 +++++++++++++++++++ 8 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 stable/prometheus-operator/templates/exporters/kube-controller-manager/endpoints.yaml create mode 100644 stable/prometheus-operator/templates/exporters/kube-scheduler/endpoints.yaml diff --git a/stable/prometheus-operator/Chart.yaml b/stable/prometheus-operator/Chart.yaml index b0cbe39981..8febecaede 100644 --- a/stable/prometheus-operator/Chart.yaml +++ b/stable/prometheus-operator/Chart.yaml @@ -9,7 +9,7 @@ name: prometheus-operator sources: - https://github.com/coreos/prometheus-operator - https://coreos.com/operators/prometheus -version: 1.5.1 +version: 1.5.2 appVersion: 0.26.0 home: https://github.com/coreos/prometheus-operator keywords: diff --git a/stable/prometheus-operator/README.md b/stable/prometheus-operator/README.md index 939d911eb4..ad73bc4c69 100644 --- a/stable/prometheus-operator/README.md +++ b/stable/prometheus-operator/README.md @@ -238,6 +238,7 @@ The following tables lists the configurable parameters of the prometheus-operato | `kubelet.namespace` | Namespace where the kubelet is deployed. See also `prometheusOperator.kubeletService.namespace` | `kube-system` | | `kubelet.serviceMonitor.https` | Enable scraping of the kubelet over HTTPS. For more information, see https://github.com/coreos/prometheus-operator/issues/926 | `false` | | `kubeControllerManager.enabled` | Deploy a `service` and `serviceMonitor` to scrape the Kubernetes controller-manager | `true` | +| `kubeControllerManager.endpoints` | Endpoints where Controller-manager runs. Provide this if running Controller-manager outside the cluster | `[]` | | `kubeControllermanager.service.port` | Controller-manager port for the service runs on | `10252` | | `kubeControllermanager.service.targetPort` | Controller-manager targetPort for the service runs on | `10252` | | `kubeControllermanager.service.targetPort.selector` | Controller-manager service selector | `{"k8s-app" : "kube-controller-manager" }` @@ -258,6 +259,11 @@ The following tables lists the configurable parameters of the prometheus-operato | `kubeEtcd.servicemonitor.caFile` | Certificate authority file to use when connecting to etcd. See `prometheus.prometheusSpec.secrets` | `""` | | `kubeEtcd.servicemonitor.certFile` | Client certificate file to use when connecting to etcd. See `prometheus.prometheusSpec.secrets` | `""` | | `kubeEtcd.servicemonitor.keyFile` | Client key file to use when connecting to etcd. See `prometheus.prometheusSpec.secrets` | `""` | +| `kubeScheduler.enabled` | Deploy a `service` and `serviceMonitor` to scrape the Kubernetes scheduler | `true` | +| `kubeScheduler.endpoints` | Endpoints where scheduler runs. Provide this if running scheduler outside the cluster | `[]` | +| `kubeScheduler.service.port` | Scheduler port for the service runs on | `10251` | +| `kubeScheduler.service.targetPort` | Scheduler targetPort for the service runs on | `10251` | +| `kubeScheduler.service.targetPort.selector` | Scheduler service selector | `{"k8s-app" : "kube-scheduler" }` | `kubeStateMetrics.enabled` | Deploy the `kube-state-metrics` chart and configure a servicemonitor to scrape | `true` | | `kube-state-metrics.rbac.create` | Create RBAC components in kube-state-metrics. See `global.rbac.create` | `true` | | `nodeExporter.enabled` | Deploy the `prometheus-node-exporter` and scrape it | `true` | diff --git a/stable/prometheus-operator/ci/test-values.yaml b/stable/prometheus-operator/ci/test-values.yaml index 534da96aba..8398d4f70e 100644 --- a/stable/prometheus-operator/ci/test-values.yaml +++ b/stable/prometheus-operator/ci/test-values.yaml @@ -342,6 +342,16 @@ kubelet: ## kubeControllerManager: enabled: true + + ## If your kube controller manager is not deployed as a pod, specify IPs it can be found on + ## + endpoints: [] + # - 10.141.4.22 + # - 10.141.4.23 + # - 10.141.4.24 + + ## If using kubeControllerManager.endpoints only the port and targetPort are used + ## service: port: 10252 targetPort: 10252 @@ -408,6 +418,16 @@ kubeEtcd: ## kubeScheduler: enabled: true + + ## If your kube scheduler is not deployed as a pod, specify IPs it can be found on + ## + endpoints: [] + # - 10.141.4.22 + # - 10.141.4.23 + # - 10.141.4.24 + + ## If using kubeScheduler.endpoints only the port and targetPort are used + ## service: port: 10251 targetPort: 10251 diff --git a/stable/prometheus-operator/templates/exporters/kube-controller-manager/endpoints.yaml b/stable/prometheus-operator/templates/exporters/kube-controller-manager/endpoints.yaml new file mode 100644 index 0000000000..a74077657e --- /dev/null +++ b/stable/prometheus-operator/templates/exporters/kube-controller-manager/endpoints.yaml @@ -0,0 +1,20 @@ +{{- if and .Values.kubeControllerManager.enabled .Values.kubeControllerManager.endpoints }} +apiVersion: v1 +kind: Endpoints +metadata: + name: {{ template "prometheus-operator.fullname" . }}-kube-controller-manager + labels: + app: {{ template "prometheus-operator.name" . }}-kube-controller-manager + k8s-app: kube-controller-manager +{{ include "prometheus-operator.labels" . | indent 4 }} + namespace: kube-system +subsets: + - addresses: + {{- range .Values.kubeControllerManager.endpoints }} + - ip: {{ . }} + {{- end }} + ports: + - name: http-metrics + port: {{ .Values.kubeControllerManager.service.port }} + protocol: TCP +{{- end }} \ No newline at end of file diff --git a/stable/prometheus-operator/templates/exporters/kube-controller-manager/service.yaml b/stable/prometheus-operator/templates/exporters/kube-controller-manager/service.yaml index 6731b7a017..f680ac36a8 100644 --- a/stable/prometheus-operator/templates/exporters/kube-controller-manager/service.yaml +++ b/stable/prometheus-operator/templates/exporters/kube-controller-manager/service.yaml @@ -14,7 +14,10 @@ spec: - name: http-metrics port: {{ .Values.kubeControllerManager.service.port }} protocol: TCP + targetPort: {{ .Values.kubeControllerManager.service.targetPort }} +{{- if .Values.kubeControllerManager.endpoints }}{{- else }} selector: {{ include "prometheus-operator.rangeskipempty" .Values.kubeControllerManager.service.selector | indent 4 }} +{{- end }} type: ClusterIP {{- end }} \ No newline at end of file diff --git a/stable/prometheus-operator/templates/exporters/kube-scheduler/endpoints.yaml b/stable/prometheus-operator/templates/exporters/kube-scheduler/endpoints.yaml new file mode 100644 index 0000000000..26426c8478 --- /dev/null +++ b/stable/prometheus-operator/templates/exporters/kube-scheduler/endpoints.yaml @@ -0,0 +1,20 @@ +{{- if and .Values.kubeScheduler.enabled .Values.kubeScheduler.endpoints }} +apiVersion: v1 +kind: Endpoints +metadata: + name: {{ template "prometheus-operator.fullname" . }}-kube-scheduler + labels: + app: {{ template "prometheus-operator.name" . }}-kube-scheduler + k8s-app: kube-scheduler +{{ include "prometheus-operator.labels" . | indent 4 }} + namespace: kube-system +subsets: + - addresses: + {{- range .Values.kubeScheduler.endpoints }} + - ip: {{ . }} + {{- end }} + ports: + - name: http-metrics + port: {{ .Values.kubeScheduler.service.port }} + protocol: TCP +{{- end }} \ No newline at end of file diff --git a/stable/prometheus-operator/templates/exporters/kube-scheduler/service.yaml b/stable/prometheus-operator/templates/exporters/kube-scheduler/service.yaml index fa137e7d0e..264b8acfe8 100644 --- a/stable/prometheus-operator/templates/exporters/kube-scheduler/service.yaml +++ b/stable/prometheus-operator/templates/exporters/kube-scheduler/service.yaml @@ -15,7 +15,9 @@ spec: port: {{ .Values.kubeScheduler.service.port}} protocol: TCP targetPort: {{ .Values.kubeScheduler.service.targetPort}} +{{- if .Values.kubeScheduler.endpoints }}{{- else }} selector: {{ include "prometheus-operator.rangeskipempty" .Values.kubeScheduler.service.selector | indent 4 }} +{{- end }} type: ClusterIP {{- end -}} \ No newline at end of file diff --git a/stable/prometheus-operator/values.yaml b/stable/prometheus-operator/values.yaml index 402cd708b9..20b25696e6 100644 --- a/stable/prometheus-operator/values.yaml +++ b/stable/prometheus-operator/values.yaml @@ -350,6 +350,16 @@ kubelet: ## kubeControllerManager: enabled: true + + ## If your kube controller manager is not deployed as a pod, specify IPs it can be found on + ## + endpoints: [] + # - 10.141.4.22 + # - 10.141.4.23 + # - 10.141.4.24 + + ## If using kubeControllerManager.endpoints only the port and targetPort are used + ## service: port: 10252 targetPort: 10252 @@ -416,6 +426,16 @@ kubeEtcd: ## kubeScheduler: enabled: true + + ## If your kube scheduler is not deployed as a pod, specify IPs it can be found on + ## + endpoints: [] + # - 10.141.4.22 + # - 10.141.4.23 + # - 10.141.4.24 + + ## If using kubeScheduler.endpoints only the port and targetPort are used + ## service: port: 10251 targetPort: 10251