Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Prometheus-adapter addon to version 0.6.0 #2441

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions buildchain/buildchain/versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ def _version_prefix(version: str, prefix: str = 'v') -> str:
),
Image(
name='k8s-prometheus-adapter-amd64',
version='v0.5.0',
digest='sha256:acf4c4dc6aaa51e3004eebdc410b509db45d1a6ebd255457c5745f0b4671678f',
version='v0.6.0',
digest='sha256:b63dc612e3cb73f79d2401a4516f794f9f0a83002600ca72e675e41baecff437',
),
Image(
name='prometheus-config-reloader',
Expand Down
4 changes: 2 additions & 2 deletions charts/prometheus-adapter/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apiVersion: v1
appVersion: v0.5.0
appVersion: v0.6.0
description: A Helm chart for k8s prometheus adapter
home: https://github.com/DirectXMan12/k8s-prometheus-adapter
keywords:
Expand All @@ -17,4 +17,4 @@ name: prometheus-adapter
sources:
- https://github.com/kubernetes/charts
- https://github.com/DirectXMan12/k8s-prometheus-adapter
version: 1.4.0
version: 2.3.1
14 changes: 8 additions & 6 deletions charts/prometheus-adapter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Installs the [Prometheus Adapter](https://github.com/DirectXMan12/k8s-prometheus

## Prerequisites

Kubernetes 1.11+
Kubernetes 1.14+

## Installing the Chart

Expand Down Expand Up @@ -74,9 +74,9 @@ rules:
resource: node
namespace:
resource: namespace
pod_name:
pod:
resource: pod
containerLabel: container_name
containerLabel: container
memory:
containerQuery: sum(container_memory_working_set_bytes{<<.LabelMatchers>>}) by (<<.GroupBy>>)
nodeQuery: sum(container_memory_working_set_bytes{<<.LabelMatchers>>,id='/'}) by (<<.GroupBy>>)
Expand All @@ -86,9 +86,9 @@ rules:
resource: node
namespace:
resource: namespace
pod_name:
pod:
resource: pod
containerLabel: container_name
containerLabel: container
window: 3m
```

Expand All @@ -112,12 +112,14 @@ The following table lists the configurable parameters of the Prometheus Adapter
| ------------------------------- | ------------------------------------------------------------------------------- | --------------------------------------------|
| `affinity` | Node affinity | `{}` |
| `image.repository` | Image repository | `directxman12/k8s-prometheus-adapter-amd64` |
| `image.tag` | Image tag | `v0.5.0` |
| `image.tag` | Image tag | `v0.6.0` |
| `image.pullPolicy` | Image pull policy | `IfNotPresent` |
| `image.pullSecrets` | Image pull secrets | `{}` |
| `logLevel` | Log level | `4` |
| `listenPort` | Port that application would listen on in the container | `6443` |
| `metricsRelistInterval` | Interval at which to re-list the set of all available metrics from Prometheus | `1m` |
| `nodeSelector` | Node labels for pod assignment | `{}` |
| `podLabels` | Labels to add to the pod | `{}` |
| `podAnnotations` | Annotations to add to the pod | `{}` |
| `priorityClassName` | Pod priority | `` |
| `prometheus.url` | Url of where we can find the Prometheus service | `http://prometheus.default.svc` |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ spec:
chart: {{ template "k8s-prometheus-adapter.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
{{- with .Values.podLabels }}
{{- toYaml . | trim | nindent 8 }}
{{- end }}
name: {{ template "k8s-prometheus-adapter.name" . }}
annotations:
checksum/config: {{ include (print $.Template.BasePath "/custom-metrics-configmap.yaml") . | sha256sum }}
Expand All @@ -28,13 +31,16 @@ spec:
{{- end }}
spec:
serviceAccountName: {{ template "k8s-prometheus-adapter.serviceAccountName" . }}
{{- if .Values.hostNetwork.enabled }}
hostNetwork: true
{{- end }}
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
args:
- /adapter
- --secure-port=6443
- --secure-port={{ .Values.listenPort }}
{{- if .Values.tls.enable }}
- --tls-cert-file=/var/run/serving-cert/tls.crt
- --tls-private-key-file=/var/run/serving-cert/tls.key
Expand All @@ -46,7 +52,7 @@ spec:
- --v={{ .Values.logLevel }}
- --config=/etc/adapter/config.yaml
ports:
- containerPort: 6443
- containerPort: {{ .Values.listenPort }}
name: https
livenessProbe:
httpGet:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if or .Values.rules.default .Values.rules.custom }}
apiVersion: apiregistration.k8s.io/v1beta1
kind: APIService
metadata:
Expand All @@ -19,3 +20,4 @@ spec:
insecureSkipTLSVerify: {{ if .Values.tls.enable }}false{{ else }}true{{ end }}
groupPriorityMinimum: 100
versionPriority: 100
{{- end }}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if .Values.rbac.create -}}
{{- if and .Values.rbac.create (or .Values.rules.default .Values.rules.custom) -}}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,48 +10,49 @@ metadata:
heritage: {{ .Release.Service }}
data:
config.yaml: |
{{- if or .Values.rules.default .Values.rules.custom }}
rules:
{{- if .Values.rules.default }}
- seriesQuery: '{__name__=~"^container_.*",container_name!="POD",namespace!="",pod_name!=""}'
- seriesQuery: '{__name__=~"^container_.*",container!="POD",namespace!="",pod!=""}'
seriesFilters: []
resources:
overrides:
namespace:
resource: namespace
pod_name:
pod:
resource: pod
name:
matches: ^container_(.*)_seconds_total$
as: ""
metricsQuery: sum(rate(<<.Series>>{<<.LabelMatchers>>,container_name!="POD"}[5m]))
metricsQuery: sum(rate(<<.Series>>{<<.LabelMatchers>>,container!="POD"}[5m]))
by (<<.GroupBy>>)
- seriesQuery: '{__name__=~"^container_.*",container_name!="POD",namespace!="",pod_name!=""}'
- seriesQuery: '{__name__=~"^container_.*",container!="POD",namespace!="",pod!=""}'
seriesFilters:
- isNot: ^container_.*_seconds_total$
resources:
overrides:
namespace:
resource: namespace
pod_name:
pod:
resource: pod
name:
matches: ^container_(.*)_total$
as: ""
metricsQuery: sum(rate(<<.Series>>{<<.LabelMatchers>>,container_name!="POD"}[5m]))
metricsQuery: sum(rate(<<.Series>>{<<.LabelMatchers>>,container!="POD"}[5m]))
by (<<.GroupBy>>)
- seriesQuery: '{__name__=~"^container_.*",container_name!="POD",namespace!="",pod_name!=""}'
- seriesQuery: '{__name__=~"^container_.*",container!="POD",namespace!="",pod!=""}'
seriesFilters:
- isNot: ^container_.*_total$
resources:
overrides:
namespace:
resource: namespace
pod_name:
pod:
resource: pod
name:
matches: ^container_(.*)$
as: ""
metricsQuery: sum(<<.Series>>{<<.LabelMatchers>>,container_name!="POD"}) by (<<.GroupBy>>)
metricsQuery: sum(<<.Series>>{<<.LabelMatchers>>,container!="POD"}) by (<<.GroupBy>>)
- seriesQuery: '{namespace!="",__name__!~"^container_.*"}'
seriesFilters:
- isNot: .*_total$
Expand Down Expand Up @@ -82,6 +83,7 @@ data:
{{- if .Values.rules.custom }}
{{ toYaml .Values.rules.custom | indent 4 }}
{{- end -}}
{{- end -}}
{{- if .Values.rules.external }}
externalRules:
{{ toYaml .Values.rules.external | indent 4 }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ rules:
verbs:
- get
- list
- watch
{{- end -}}
23 changes: 18 additions & 5 deletions charts/prometheus-adapter/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ affinity: {}

image:
repository: directxman12/k8s-prometheus-adapter-amd64
tag: v0.5.0
tag: v0.6.0
pullPolicy: IfNotPresent

logLevel: 4

metricsRelistInterval: 1m

listenPort: 6443

nodeSelector: {}

priorityClassName: ""
Expand Down Expand Up @@ -71,9 +73,9 @@ rules:
# resource: node
# namespace:
# resource: namespace
# pod_name:
# pod:
# resource: pod
# containerLabel: container_name
# containerLabel: container
# memory:
# containerQuery: sum(container_memory_working_set_bytes{<<.LabelMatchers>>}) by (<<.GroupBy>>)
# nodeQuery: sum(container_memory_working_set_bytes{<<.LabelMatchers>>,id='/'}) by (<<.GroupBy>>)
Expand All @@ -83,9 +85,9 @@ rules:
# resource: node
# namespace:
# resource: namespace
# pod_name:
# pod:
# resource: pod
# containerLabel: container_name
# containerLabel: container
# window: 3m

service:
Expand Down Expand Up @@ -123,5 +125,16 @@ extraVolumeMounts: []

tolerations: []

# Labels added to the pod
podLabels: {}

# Annotations added to the pod
podAnnotations: {}

hostNetwork:
# Specifies if prometheus-adapter should be started in hostNetwork mode.
#
# You would require this enabled if you use alternate overlay networking for pods and
# API server unable to communicate with metrics-server. As an example, this is required
# if you use Weave network on EKS
enabled: false
19 changes: 9 additions & 10 deletions charts/render.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ def main():
'--service-config',
action='append',
nargs=2,
required=False,
dest="service_configs",
help="Example: --service-config grafana metalk8s-grafana-config"
)
Expand All @@ -212,16 +213,14 @@ def main():
)
)

sys.stdout.write(
START_BLOCK.format(
configlines='\n'.join(
("{{%- set {} = salt.metalk8s_service_configuration"
".get_service_conf('{}', '{}') %}}").format(
service_config[0], args.namespace, service_config[1]
) for service_config in args.service_configs
)
).lstrip()
)
config = '\n'.join(
("{{%- set {} = salt.metalk8s_service_configuration"
".get_service_conf('{}', '{}') %}}").format(
service_config[0], args.namespace, service_config[1]
) for service_config in args.service_configs
) if args.service_configs else ''

sys.stdout.write(START_BLOCK.format(configlines=config).lstrip())
sys.stdout.write('\n')

stream = io.StringIO()
Expand Down
Loading