Skip to content

Commit

Permalink
monitoring: deploy prometheus-adapter
Browse files Browse the repository at this point in the history
This should enable the `metrics.k8s.io` API, and as such reinstate the
`kubectl top` functionality and allow the `HorizontalPodAutoscaler`
controller to work.

The chart is rendered using

```
$ ./charts/render.py prometheus-adapter metalk8s-monitoring charts/prometheus-adapter.yaml charts/prometheus-adapter/ > salt/metalk8s/addons/prometheus-adapter/deployed/chart.sls
```

Fixes: #2049
See: #2049
  • Loading branch information
NicolasT committed Nov 19, 2019
1 parent 5756483 commit c1c2b2a
Show file tree
Hide file tree
Showing 8 changed files with 489 additions and 8 deletions.
17 changes: 9 additions & 8 deletions buildchain/buildchain/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@
CMD_WIDTH : int = 14

# URLs of the main container repositories.
CALICO_REPOSITORY : str = 'quay.io/calico'
COREOS_REPOSITORY : str = 'quay.io/coreos'
DOCKER_REPOSITORY : str = 'docker.io/library'
GOOGLE_REPOSITORY : str = 'k8s.gcr.io'
GRAFANA_REPOSITORY : str = 'docker.io/grafana'
INGRESS_REPOSITORY : str = 'quay.io/kubernetes-ingress-controller'
KIWIGRID_REPOSITORY : str = 'docker.io/kiwigrid'
PROMETHEUS_REPOSITORY : str = 'quay.io/prometheus'
CALICO_REPOSITORY : str = 'quay.io/calico'
COREOS_REPOSITORY : str = 'quay.io/coreos'
DOCKER_REPOSITORY : str = 'docker.io/library'
GOOGLE_REPOSITORY : str = 'k8s.gcr.io'
GRAFANA_REPOSITORY : str = 'docker.io/grafana'
INGRESS_REPOSITORY : str = 'quay.io/kubernetes-ingress-controller'
KIWIGRID_REPOSITORY : str = 'docker.io/kiwigrid'
PROMETHEUS_ADAPTER_REPOSITORY : str = 'docker.io/directxman12'
PROMETHEUS_REPOSITORY : str = 'quay.io/prometheus'

# Paths {{{

Expand Down
3 changes: 3 additions & 0 deletions buildchain/buildchain/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,9 @@ def _operator_image(name: str, **kwargs: Any) -> targets.OperatorImage:
constants.KIWIGRID_REPOSITORY: [
'k8s-sidecar',
],
constants.PROMETHEUS_ADAPTER_REPOSITORY: [
'k8s-prometheus-adapter-amd64',
],
constants.PROMETHEUS_REPOSITORY: [
'alertmanager',
'node-exporter',
Expand Down
3 changes: 3 additions & 0 deletions buildchain/buildchain/salt_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,9 @@ def _get_parts(self) -> Iterator[str]:
renderer=targets.Renderer.JSON,
),

Path('salt/metalk8s/addons/prometheus-adapter/deployed/chart.sls'),
Path('salt/metalk8s/addons/prometheus-adapter/deployed/init.sls'),

Path('salt/metalk8s/addons/prometheus-operator/deployed/chart.sls'),
Path('salt/metalk8s/addons/prometheus-operator/deployed/cleanup.sls'),
Path('salt/metalk8s/addons/prometheus-operator/deployed/dashboards.sls'),
Expand Down
5 changes: 5 additions & 0 deletions buildchain/buildchain/versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,11 @@ def _version_prefix(version: str, prefix: str = 'v') -> str:
version='v2.12.0',
digest='sha256:cd93b8711bb92eb9c437d74217311519e0a93bc55779aa664325dc83cd13cb3',
),
Image(
name='k8s-prometheus-adapter-amd64',
version='v0.5.0',
digest='sha256:acf4c4dc6aaa51e3004eebdc410b509db45d1a6ebd255457c5745f0b4671678f',
),
Image(
name='prometheus-config-reloader',
version='v0.32.0',
Expand Down
47 changes: 47 additions & 0 deletions charts/prometheus-adapter.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
image:
repository: '{%- endraw -%}{{ build_image_name(\"k8s-prometheus-adapter-amd64\", False) }}{%- raw -%}'

nodeSelector:
node-role.kubernetes.io/infra: ''

prometheus:
url: http://prometheus-operator-prometheus

replicas: 2

rules:
resource:
cpu:
containerQuery: sum(rate(container_cpu_usage_seconds_total{<<.LabelMatchers>>}[3m])) by (<<.GroupBy>>)
nodeQuery: sum(rate(container_cpu_usage_seconds_total{<<.LabelMatchers>>, id='/'}[3m])) by (<<.GroupBy>>)
resources:
overrides:
node:
resource: node
namespace:
resource: namespace
pod_name:
resource: pod
containerLabel: container_name
memory:
containerQuery: sum(container_memory_working_set_bytes{<<.LabelMatchers>>}) by (<<.GroupBy>>)
nodeQuery: sum(container_memory_working_set_bytes{<<.LabelMatchers>>,id='/'}) by (<<.GroupBy>>)
resources:
overrides:
node:
resource: node
namespace:
resource: namespace
pod_name:
resource: pod
containerLabel: container_name
window: 3m


tolerations:
- key: 'node-role.kubernetes.io/bootstrap'
operator: 'Exists'
effect: 'NoSchedule'
- key: 'node-role.kubernetes.io/infra'
operator: 'Exists'
effect: 'NoSchedule'
Loading

0 comments on commit c1c2b2a

Please sign in to comment.