Adds Prometheus ServiceMonitor resource to kube2iam (#11416)

Changes:
 - Adds ServiceMonitor & Service resources for use with Prometheus Operator.
 - Allows configuring the metrics port option of kube2iam and will
 configure the new named port on the DaemonSet when applicable.
 - Adds docs for all new config params

Bonus:
 - Adds missing docs for `host.port` config param

Signed-off-by: Will Frew <will.frew1@gmail.com>
This commit is contained in:
Will Frew
2019-04-23 02:14:08 -07:00
committed by Kubernetes Prow Robot
parent a959eabefd
commit b86cc40544
6 changed files with 84 additions and 2 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
name: kube2iam
version: 0.10.0
version: 0.11.0
appVersion: 0.10.4
description: Provide IAM credentials to pods based on annotations.
keywords:
+5
View File
@@ -47,12 +47,17 @@ Parameter | Description | Default
`host.ip` | IP address of host | `$(HOST_IP)`
`host.iptables` | Add iptables rule | `false`
`host.interface` | Host interface for proxying AWS metadata | `docker0`
`host.port` | Port to listen on | `8181`
`image.repository` | Image | `jtblin/kube2iam`
`image.tag` | Image tag | `0.10.4`
`image.pullPolicy` | Image pull policy | `IfNotPresent`
`nodeSelector` | node labels for pod assignment | `{}`
`podAnnotations` | annotations to be added to pods | `{}`
`priorityClassName` | priorityClassName to be added to pods | `{}`
`prometheus.metricsPort` | Port to expose prometheus metrics on (if unspecified, `host.port` is used) | `host.port`
`prometheus.serviceMonitor.enabled` | If true, create a Prometheus Operator ServiceMonitor resource | `false`
`prometheus.serviceMonitor.interval` | Interval at which the metrics endpoint is scraped | `10s`
`prometheus.serviceMonitor.namespace` | An alternative namespace in which to install the ServiceMonitor | `""`
`rbac.create` | If true, create & use RBAC resources | `false`
`rbac.serviceAccountName` | existing ServiceAccount to use (ignored if rbac.create=true) | `default`
`resources` | pod resource requests & limits | `{}`
+9 -1
View File
@@ -43,6 +43,9 @@ spec:
- --verbose
{{- end }}
- --app-port={{ .Values.host.port }}
{{- if .Values.prometheus.metricsPort }}
- --metrics-port={{ .Values.prometheus.metricsPort }}
{{- end }}
env:
- name: HOST_IP
valueFrom:
@@ -73,7 +76,12 @@ spec:
value: {{ quote $value }}
{{- end }}
ports:
- containerPort: {{ .Values.host.port }}
- name: http
containerPort: {{ .Values.host.port }}
{{- if .Values.prometheus.metricsPort }}
- name: metrics
containerPort: {{ .Values.prometheus.metricsPort }}
{{- end}}
{{- if .Values.probe }}
livenessProbe:
httpGet:
+27
View File
@@ -0,0 +1,27 @@
{{- if .Values.prometheus.serviceMonitor.enabled }}
apiVersion: v1
kind: Service
metadata:
annotations:
name: {{ template "kube2iam.fullname" . }}-metrics
labels:
app: {{ template "kube2iam.name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
selector:
app: {{ template "kube2iam.name" . }}
release: {{ .Release.Name }}
ports:
{{- if .Values.prometheus.metricsPort }}
- name: metrics
port: {{ .Values.prometheus.metricsPort }}
targetPort: {{ .Values.prometheus.metricsPort }}
{{- else }}
- name: http
port: {{ .Values.host.port }}
targetPort: {{ .Values.host.port }}
{{- end }}
protocol: TCP
{{ end }}
@@ -0,0 +1,30 @@
{{- if .Values.prometheus.serviceMonitor.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ template "kube2iam.fullname" . }}
{{- if .Values.prometheus.serviceMonitor.namespace }}
namespace: {{ .Values.prometheus.serviceMonitor.namespace }}
{{- end }}
labels:
app: {{ template "kube2iam.name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
spec:
selector:
matchLabels:
app: {{ template "kube2iam.name" . }}
release: {{ .Release.Name }}
namespaceSelector:
matchNames:
- {{ .Release.Namespace }}
endpoints:
{{- if .Values.prometheus.metricsPort }}
- port: metrics
{{- else }}
- port: http
{{- end }}
interval: {{ .Values.prometheus.serviceMonitor.interval }}
path: /metrics
{{- end -}}
+12
View File
@@ -14,6 +14,18 @@ host:
interface: docker0
port: 8181
prometheus:
# Port to expose the /metrics endpoint on. If unset, defaults to `host.port`
# metricsPort: 8181
serviceMonitor:
# Create prometheus-operator ServiceMonitor
enabled: false
# Interval at which the metrics endpoint is scraped
interval: 10s
# Alternative namespace to install the ServiceMonitor in
namespace: ""
image:
repository: jtblin/kube2iam
tag: 0.10.4