Add prometheus memcached exporter

This adds a prometheus memcached exporter to the memcached chart
and disables it by default

Change-Id: Ia7725cd41b578730b853cbedaa97f28ff9806936
This commit is contained in:
Steve Wilkerson 2018-03-01 13:47:11 -06:00
parent 4c8205bd54
commit e39a1ba750
7 changed files with 218 additions and 2 deletions

View File

@ -39,6 +39,7 @@ spec:
{{ tuple $envAll "memcached" "server" | include "helm-toolkit.snippets.kubernetes_pod_anti_affinity" | indent 8 }}
nodeSelector:
{{ .Values.labels.server.node_selector_key }}: {{ .Values.labels.server.node_selector_value }}
terminationGracePeriodSeconds: {{ .Values.pod.lifecycle.termination_grace_period.memcached.timeout | default "30" }}
initContainers:
{{ tuple $envAll "memcached" list | include "helm-toolkit.snippets.kubernetes_entrypoint_init_container" | indent 9 }}
containers:

View File

@ -0,0 +1,30 @@
#!/bin/sh
{{/*
Copyright 2017 The Openstack-Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/}}
set -ex
COMMAND="${@:-start}"
function start () {
exec /bin/memcached_exporter --memcached.address "$MEMCACHED_HOST"
}
function stop () {
kill -TERM 1
}
$COMMAND

View File

@ -0,0 +1,28 @@
{{/*
Copyright 2017 The Openstack-Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/}}
{{- if and .Values.manifests.monitoring.prometheus.configmap_bin .Values.monitoring.prometheus.enabled }}
{{- $envAll := . }}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ printf "%s-%s" $envAll.Release.Name "memcached-exporter-bin" | quote }}
data:
memcached-exporter.sh: |
{{ tuple "bin/_memcached-exporter.sh.tpl" . | include "helm-toolkit.utils.template" | indent 4 }}
{{- end }}

View File

@ -0,0 +1,68 @@
{{/*
Copyright 2017 The Openstack-Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/}}
{{- if and .Values.manifests.monitoring.prometheus.deployment_exporter .Values.monitoring.prometheus.enabled }}
{{- $envAll := . }}
{{- $rcControllerName := printf "%s-%s" $envAll.Release.Name "memcached-exporter" }}
{{- $configMapBinName := printf "%s-%s" $envAll.Release.Name "memcached-exporter-bin" }}
{{ tuple $envAll "prometheus_memcached_exporter" $rcControllerName | include "helm-toolkit.snippets.kubernetes_pod_rbac_serviceaccount" }}
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: {{ $rcControllerName | quote }}
spec:
replicas: {{ .Values.pod.replicas.prometheus_memcached_exporter }}
{{ tuple $envAll | include "helm-toolkit.snippets.kubernetes_upgrades_deployment" | indent 2 }}
template:
metadata:
labels:
{{ tuple $envAll "prometheus_memcached_exporter" "exporter" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 8 }}
namespace: {{ .Values.endpoints.prometheus_memcached_exporter.namespace }}
spec:
serviceAccountName: {{ $rcControllerName | quote }}
nodeSelector:
{{ .Values.labels.prometheus_memcached_exporter.node_selector_key }}: {{ .Values.labels.prometheus_memcached_exporter.node_selector_value }}
terminationGracePeriodSeconds: {{ .Values.pod.lifecycle.termination_grace_period.prometheus_memcached_exporter.timeout | default "30" }}
initContainers:
{{ tuple $envAll "prometheus_memcached_exporter" list | include "helm-toolkit.snippets.kubernetes_entrypoint_init_container" | indent 8 }}
containers:
- name: memcached-exporter
image: {{ .Values.images.tags.prometheus_memcached_exporter }}
imagePullPolicy: {{ .Values.images.pull_policy }}
{{ tuple $envAll $envAll.Values.pod.resources.prometheus_memcached_exporter | include "helm-toolkit.snippets.kubernetes_resources" | indent 10 }}
command:
- /tmp/memcached-exporter.sh
- start
ports:
- name: metrics
containerPort: {{ tuple "prometheus_memcached_exporter" "internal" "metrics" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }}
env:
- name: MEMCACHED_HOST
value: {{ tuple "oslo_cache" "internal" "memcache" . | include "helm-toolkit.endpoints.host_and_port_endpoint_uri_lookup" }}
volumeMounts:
- name: memcached-exporter-bin
mountPath: /tmp/memcached-exporter.sh
subPath: memcached-exporter.sh
readOnly: true
volumes:
- name: memcached-exporter-bin
configMap:
name: {{ $configMapBinName | quote }}
defaultMode: 0555
{{- end }}

View File

@ -0,0 +1,37 @@
{{/*
Copyright 2017 The Openstack-Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/}}
{{- if and .Values.manifests.monitoring.prometheus.service_exporter .Values.monitoring.prometheus.enabled }}
{{- $envAll := . }}
{{- $prometheus_annotations := $envAll.Values.monitoring.prometheus.memcached_exporter }}
---
apiVersion: v1
kind: Service
metadata:
name: {{ tuple "prometheus_memcached_exporter" "internal" . | include "helm-toolkit.endpoints.hostname_short_endpoint_lookup" }}
labels:
{{ tuple $envAll "prometheus_memcached_exporter" "metrics" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 4 }}
annotations:
{{- if .Values.monitoring.prometheus.enabled }}
{{ tuple $prometheus_annotations | include "helm-toolkit.snippets.prometheus_service_annotations" | indent 4 }}
{{- end }}
spec:
ports:
- name: metrics
port: {{ tuple "prometheus_memcached_exporter" "internal" "metrics" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }}
selector:
{{ tuple $envAll "prometheus_memcached_exporter" "exporter" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 4 }}
{{- end }}

View File

@ -40,6 +40,10 @@ dependencies:
services:
- endpoint: internal
service: local_image_registry
prometheus_memcached_exporter:
services:
- endpoint: internal
service: oslo_cache
endpoints:
cluster_domain_suffix: cluster.local
@ -56,6 +60,7 @@ endpoints:
registry:
node: 5000
oslo_cache:
namespace: null
host_fqdn_override:
default: null
hosts:
@ -64,12 +69,32 @@ endpoints:
port:
memcache:
default: 11211
prometheus_memcached_exporter:
namespace: null
hosts:
default: memcached-exporter
host_fqdn_override:
default: null
path:
default: /metrics
scheme:
default: 'http'
port:
metrics:
default: 9150
monitoring:
prometheus:
enabled: false
memcached_exporter:
scrape: true
images:
pull_policy: IfNotPresent
tags:
dep_check: 'quay.io/stackanetes/kubernetes-entrypoint:v0.3.1'
memcached: 'docker.io/memcached:1.5.5'
prometheus_memcached_exporter: docker.io/prom/memcached-exporter:v0.4.1
image_repo_sync: docker.io/docker:17.07.0
local_registry:
active: false
@ -81,12 +106,20 @@ labels:
server:
node_selector_key: openstack-control-plane
node_selector_value: enabled
prometheus_memcached_exporter:
node_selector_key: openstack-control-plane
node_selector_value: enabled
manifests:
configmap_bin: true
deployment: true
job_image_repo_sync: true
service: true
monitoring:
prometheus:
configmap_bin: true
deployment_exporter: true
service_exporter: true
pod:
affinity:
@ -103,14 +136,27 @@ pod:
rolling_update:
max_surge: 3
max_unavailable: 1
termination_grace_period:
memcached:
timeout: 30
prometheus_memcached_exporter:
timeout: 30
replicas:
server: 1
prometheus_memcached_exporter: 1
resources:
enabled: false
memcached:
limits:
cpu: 500m
memory: 1024Mi
cpu: "2000m"
memory: "1024Mi"
requests:
cpu: "500m"
memory: "128Mi"
prometheus_memcached_exporter:
limits:
memory: "1024Mi"
cpu: "2000m"
requests:
cpu: 500m
memory: 128Mi

View File

@ -164,6 +164,12 @@ data:
server:
node_selector_key: openstack-control-plane
node_selector_value: enabled
prometheus_memcached_exporter:
node_selector_key: openstack-control-plane
node_selector_value: enabled
monitoring:
prometheus:
enabled: true
source:
type: local
location: ${OSH_PATH}