helm-toolkit prometheus service annotation clean up

This adds checks for the fields in the service annotations for
prometheus, similar to the checks made for the pod annotations.
It also moves prometheus annotations under a prometheus: key
under a top-level monitoring tree to allow for other monitoring
mechanisms independent of the endpoints tree

Change-Id: I4be6d6ad8e74e8ca52bd224ceddad785577bf6c7
This commit is contained in:
Steve Wilkerson 2018-01-15 08:30:28 -06:00
parent 9b40b8656d
commit 9ffc748979
14 changed files with 95 additions and 48 deletions

View File

@ -39,6 +39,8 @@ limitations under the License.
{{- $_ := set .Values "pod_dependency" .Values.dependencies.calico_node -}} {{- $_ := set .Values "pod_dependency" .Values.dependencies.calico_node -}}
{{- end -}} {{- end -}}
{{- $prometheus_annotations := $envAll.Values.monitoring.prometheus.calico_node }}
{{- $serviceAccountName := "calico-cni-plugin"}} {{- $serviceAccountName := "calico-cni-plugin"}}
{{ tuple $envAll $envAll.Values.pod_dependency $serviceAccountName | include "helm-toolkit.snippets.kubernetes_pod_rbac_serviceaccount" }} {{ tuple $envAll $envAll.Values.pod_dependency $serviceAccountName | include "helm-toolkit.snippets.kubernetes_pod_rbac_serviceaccount" }}
--- ---
@ -93,7 +95,9 @@ spec:
# reserves resources for critical add-on pods so that they can be rescheduled after # reserves resources for critical add-on pods so that they can be rescheduled after
# a failure. This annotation works in tandem with the toleration below. # a failure. This annotation works in tandem with the toleration below.
scheduler.alpha.kubernetes.io/critical-pod: '' scheduler.alpha.kubernetes.io/critical-pod: ''
{{ tuple $envAll.Values.pod.annotations.calico_node | include "helm-toolkit.snippets.prometheus_pod_annotations" | indent 8 }} {{- if .Values.monitoring.prometheus.enabled }}
{{ tuple $prometheus_annotations | include "helm-toolkit.snippets.prometheus_pod_annotations" | indent 8 }}
{{- end }}
spec: spec:
hostNetwork: true hostNetwork: true
tolerations: tolerations:

View File

@ -44,10 +44,6 @@ images:
- calico_kube_policy_controller - calico_kube_policy_controller
pod: pod:
annotations:
calico_node:
prometheus_port: 9091
prometheus_scrape: true
resources: resources:
enabled: false enabled: false
jobs: jobs:
@ -104,6 +100,13 @@ endpoints:
peer: peer:
default: 6667 default: 6667
monitoring:
prometheus:
enabled: true
calico_node:
scrape: true
port: 9091
networking: networking:
podSubnet: 192.168.0.0/16 podSubnet: 192.168.0.0/16
#NOTE(portdirect): this should be the physical MTU, the appropriate MTU #NOTE(portdirect): this should be the physical MTU, the appropriate MTU

View File

@ -22,14 +22,14 @@ limitations under the License.
# pod's declared ports (default is a port-free target if none are declared). # pod's declared ports (default is a port-free target if none are declared).
{{- define "helm-toolkit.snippets.prometheus_pod_annotations" -}} {{- define "helm-toolkit.snippets.prometheus_pod_annotations" -}}
{{- $pod := index . 0 -}} {{- $config := index . 0 -}}
{{- if $pod.prometheus_scrape }} {{- if $config.scrape }}
prometheus.io/scrape: {{ $pod.prometheus_scrape | quote }} prometheus.io/scrape: {{ $config.scrape | quote }}
{{- end }} {{- end }}
{{- if $pod.prometheus_path }} {{- if $config.path }}
prometheus.io/path: {{ $pod.prometheus_path | quote }} prometheus.io/path: {{ $config.path | quote }}
{{- end }} {{- end }}
{{- if $pod.prometheus_port }} {{- if $config.port }}
prometheus.io/port: {{ $pod.prometheus_port | quote }} prometheus.io/port: {{ $config.port | quote }}
{{- end }} {{- end }}
{{- end -}} {{- end -}}

View File

@ -1,12 +1,9 @@
{{/* {{/*
Copyright 2017 The Openstack-Helm Authors. Copyright 2017 The Openstack-Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
You may obtain a copy of the License at You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -24,9 +21,17 @@ limitations under the License.
# service then set this appropriately. # service then set this appropriately.
{{- define "helm-toolkit.snippets.prometheus_service_annotations" -}} {{- define "helm-toolkit.snippets.prometheus_service_annotations" -}}
{{- $endpoint := index . 0 -}} {{- $config := index . 0 -}}
prometheus.io/scrape: {{ $endpoint.scrape | quote }} {{- if $config.scrape }}
prometheus.io/scheme: {{ $endpoint.scheme.default | quote }} prometheus.io/scrape: {{ $config.scrape | quote }}
prometheus.io/path: {{ $endpoint.path.default | quote }} {{- end }}
prometheus.io/port: {{ $endpoint.scrape_port | quote }} {{- if $config.scheme }}
prometheus.io/scheme: {{ $config.scheme | quote }}
{{- end }}
{{- if $config.path }}
prometheus.io/path: {{ $config.path | quote }}
{{- end }}
{{- if $config.port }}
prometheus.io/port: {{ $config.port | quote }}
{{- end }}
{{- end -}} {{- end -}}

View File

@ -16,7 +16,7 @@ limitations under the License.
{{- if .Values.manifests.service_controller_manager }} {{- if .Values.manifests.service_controller_manager }}
{{- $envAll := . }} {{- $envAll := . }}
{{- $endpoint := $envAll.Values.endpoints.kube_controller_manager }} {{- $prometheus_annotations := $envAll.Values.monitoring.prometheus.kube_controller_manager }}
--- ---
apiVersion: v1 apiVersion: v1
kind: Service kind: Service
@ -25,7 +25,9 @@ metadata:
labels: labels:
{{ tuple $envAll "controller-manager" "metrics" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 4 }} {{ tuple $envAll "controller-manager" "metrics" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 4 }}
annotations: annotations:
{{ tuple $endpoint | include "helm-toolkit.snippets.prometheus_service_annotations" | indent 4 }} {{- if .Values.monitoring.prometheus.enabled }}
{{ tuple $prometheus_annotations | include "helm-toolkit.snippets.prometheus_service_annotations" | indent 4 }}
{{- end }}
spec: spec:
selector: selector:
component: kube-controller-manager component: kube-controller-manager

View File

@ -14,18 +14,20 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/}} */}}
{{- if .Values.manifests.service_kube_metrics }} {{- if .Values.manifests.service_kube_state_metrics }}
{{- $envAll := . }} {{- $envAll := . }}
{{- $endpoint := $envAll.Values.endpoints.kube_metrics }} {{- $prometheus_annotations := $envAll.Values.monitoring.prometheus.kube_state_metrics }}
--- ---
apiVersion: v1 apiVersion: v1
kind: Service kind: Service
metadata: metadata:
name: {{ tuple "kube_metrics" "internal" . | include "helm-toolkit.endpoints.hostname_short_endpoint_lookup" }} name: {{ tuple "kube_state_metrics" "internal" . | include "helm-toolkit.endpoints.hostname_short_endpoint_lookup" }}
labels: labels:
{{ tuple $envAll "kube-state-metrics" "metrics" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 4 }} {{ tuple $envAll "kube-state-metrics" "metrics" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 4 }}
annotations: annotations:
{{ tuple $endpoint | include "helm-toolkit.snippets.prometheus_service_annotations" | indent 4 }} {{- if .Values.monitoring.prometheus.enabled }}
{{ tuple $prometheus_annotations | include "helm-toolkit.snippets.prometheus_service_annotations" | indent 4 }}
{{- end }}
spec: spec:
ports: ports:
- name: http - name: http

View File

@ -16,7 +16,7 @@ limitations under the License.
{{- if .Values.manifests.service_scheduler }} {{- if .Values.manifests.service_scheduler }}
{{- $envAll := . }} {{- $envAll := . }}
{{- $endpoint := $envAll.Values.endpoints.kube_scheduler }} {{- $prometheus_annotations := $envAll.Values.monitoring.prometheus.kube_scheduler }}
--- ---
apiVersion: v1 apiVersion: v1
kind: Service kind: Service
@ -25,7 +25,9 @@ metadata:
labels: labels:
{{ tuple $envAll "kube-scheduler" "metrics" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 4 }} {{ tuple $envAll "kube-scheduler" "metrics" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 4 }}
annotations: annotations:
{{ tuple $endpoint | include "helm-toolkit.snippets.prometheus_service_annotations" | indent 4 }} {{- if .Values.monitoring.prometheus.enabled }}
{{ tuple $prometheus_annotations | include "helm-toolkit.snippets.prometheus_service_annotations" | indent 4 }}
{{- end }}
spec: spec:
selector: selector:
component: kube-scheduler component: kube-scheduler

View File

@ -102,10 +102,10 @@ endpoints:
port: port:
registry: registry:
node: 5000 node: 5000
kube_metrics: kube_state_metrics:
namespace: null namespace: null
hosts: hosts:
default: kube-metrics default: kube-state-metrics
host_fqdn_override: host_fqdn_override:
default: null default: null
path: path:
@ -115,22 +115,26 @@ endpoints:
port: port:
http: http:
default: 8080 default: 8080
scrape: true
scrape_port: 8080
kube_scheduler: kube_scheduler:
scheme: scheme:
default: 'http' default: 'http'
path: path:
default: /metrics default: /metrics
scrape: true
scrape_port: 10251
kube_controller_manager: kube_controller_manager:
scheme: scheme:
default: 'http' default: 'http'
path: path:
default: /metrics default: /metrics
monitoring:
prometheus:
enabled: true
kube_state_metrics:
scrape: true
kube_scheduler:
scrape: true
kube_controller_manager:
scrape: true scrape: true
scrape_port: 10252
network: network:
kube_state_metrics: kube_state_metrics:
@ -142,7 +146,7 @@ manifests:
clusterrolebinding: true clusterrolebinding: true
deployment: true deployment: true
job_image_repo_sync: true job_image_repo_sync: true
service_kube_metrics: true service_kube_state_metrics: true
service_controller_manager: true service_controller_manager: true
service_scheduler: true service_scheduler: true
serviceaccount: true serviceaccount: true

View File

@ -16,7 +16,7 @@ limitations under the License.
{{- if .Values.manifests.service }} {{- if .Values.manifests.service }}
{{- $envAll := . }} {{- $envAll := . }}
{{- $endpoint := $envAll.Values.endpoints.node_metrics }} {{- $prometheus_annotations := $envAll.Values.monitoring.prometheus.node_exporter }}
--- ---
apiVersion: v1 apiVersion: v1
kind: Service kind: Service
@ -25,7 +25,9 @@ metadata:
labels: labels:
{{ tuple $envAll "node_exporter" "metrics" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 4 }} {{ tuple $envAll "node_exporter" "metrics" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 4 }}
annotations: annotations:
{{ tuple $endpoint | include "helm-toolkit.snippets.prometheus_service_annotations" | indent 4 }} {{- if .Values.monitoring.prometheus.enabled }}
{{ tuple $prometheus_annotations | include "helm-toolkit.snippets.prometheus_service_annotations" | indent 4 }}
{{- end }}
spec: spec:
type: ClusterIP type: ClusterIP
clusterIP: None clusterIP: None

View File

@ -92,6 +92,12 @@ conditional_dependencies:
- service: local_image_registry - service: local_image_registry
endpoint: node endpoint: node
monitoring:
prometheus:
enabled: true
node_exporter:
scrape: true
network: network:
node_exporter: node_exporter:
port: 9100 port: 9100
@ -123,8 +129,8 @@ endpoints:
port: port:
metrics: metrics:
default: 9100 default: 9100
scrape: true prometheus_port:
scrape_port: 9100 default: 9100
manifests: manifests:
configmap_bin: true configmap_bin: true

View File

@ -16,7 +16,7 @@ limitations under the License.
{{- if .Values.manifests.service }} {{- if .Values.manifests.service }}
{{- $envAll := . }} {{- $envAll := . }}
{{- $endpoint := $envAll.Values.endpoints.prometheus_openstack_exporter }} {{- $prometheus_annotations := $envAll.Values.monitoring.prometheus.openstack_exporter }}
--- ---
apiVersion: v1 apiVersion: v1
kind: Service kind: Service
@ -25,7 +25,9 @@ metadata:
labels: labels:
{{ tuple $envAll "prometheus-openstack-exporter" "metrics" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 4 }} {{ tuple $envAll "prometheus-openstack-exporter" "metrics" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 4 }}
annotations: annotations:
{{ tuple $endpoint | include "helm-toolkit.snippets.prometheus_service_annotations" | indent 4 }} {{- if .Values.monitoring.prometheus.enabled }}
{{ tuple $prometheus_annotations | include "helm-toolkit.snippets.prometheus_service_annotations" | indent 4 }}
{{- end }}
spec: spec:
ports: ports:
- name: http - name: http

View File

@ -144,7 +144,6 @@ endpoints:
port: port:
exporter: exporter:
default: 9103 default: 9103
scrape: true
identity: identity:
name: keystone name: keystone
auth: auth:
@ -178,6 +177,16 @@ endpoints:
api: api:
default: 80 default: 80
monitoring:
prometheus:
enabled: true
openstack_exporter:
scrape: true
network:
openstack_metrics_exporter:
port: 9103
manifests: manifests:
configmap_bin: true configmap_bin: true
deployment: true deployment: true

View File

@ -16,7 +16,7 @@ limitations under the License.
{{- if .Values.manifests.service }} {{- if .Values.manifests.service }}
{{- $envAll := . }} {{- $envAll := . }}
{{- $endpoint := $envAll.Values.endpoints.monitoring }} {{- $prometheus_annotations := $envAll.Values.monitoring.prometheus.prometheus }}
--- ---
apiVersion: v1 apiVersion: v1
kind: Service kind: Service
@ -25,7 +25,9 @@ metadata:
labels: labels:
{{ tuple $envAll "prometheus" "metrics" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 4 }} {{ tuple $envAll "prometheus" "metrics" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 4 }}
annotations: annotations:
{{ tuple $endpoint | include "helm-toolkit.snippets.prometheus_service_annotations" | indent 4 }} {{- if .Values.monitoring.prometheus.enabled }}
{{ tuple $prometheus_annotations | include "helm-toolkit.snippets.prometheus_service_annotations" | indent 4 }}
{{- end }}
spec: spec:
ports: ports:
- name: prom-metrics - name: prom-metrics

View File

@ -112,8 +112,6 @@ endpoints:
api: api:
default: 9090 default: 9090
public: 80 public: 80
scrape: true
scrape_port: 9090
alerts: alerts:
name: alertmanager name: alertmanager
namespace: null namespace: null
@ -147,6 +145,12 @@ conditional_dependencies:
- service: local_image_registry - service: local_image_registry
endpoint: node endpoint: node
monitoring:
prometheus:
enabled: true
prometheus:
scrape: true
network: network:
prometheus: prometheus:
ingress: ingress: