Skip to content

Commit

Permalink
feat: add optional defaults for cpu and memory limit
Browse files Browse the repository at this point in the history
  • Loading branch information
tboerger committed Aug 24, 2023
1 parent 01bab9d commit 4e92a98
Show file tree
Hide file tree
Showing 4 changed files with 241 additions and 1 deletion.
172 changes: 171 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![Source Code](https://img.shields.io/badge/github-source%20code-blue?logo=github&logoColor=white)](https://github.com/rolehippie/prometheus)
[![General Workflow](https://github.com/rolehippie/prometheus/actions/workflows/general.yml/badge.svg)](https://github.com/rolehippie/prometheus/actions/workflows/general.yml)
[![Readme Workflow](https://github.com/rolehippie/prometheus/actions/workflows/readme.yml/badge.svg)](https://github.com/rolehippie/prometheus/actions/workflows/readme.yml)
[![Readme Workflow](https://github.com/rolehippie/prometheus/actions/workflows/docs.yml/badge.svg)](https://github.com/rolehippie/prometheus/actions/workflows/docs.yml)
[![Galaxy Workflow](https://github.com/rolehippie/prometheus/actions/workflows/galaxy.yml/badge.svg)](https://github.com/rolehippie/prometheus/actions/workflows/galaxy.yml)
[![License: Apache-2.0](https://img.shields.io/github/license/rolehippie/prometheus)](https://github.com/rolehippie/prometheus/blob/master/LICENSE)
[![Ansible Role](https://img.shields.io/badge/role-rolehippie.prometheus-blue)](https://galaxy.ansible.com/rolehippie/prometheus)
Expand All @@ -18,6 +18,7 @@ Building and improving this Ansible role have been sponsored by my current and p
- [Requirements](#requirements)
- [Default Variables](#default-variables)
- [prometheus_alertmanagers](#prometheus_alertmanagers)
- [prometheus_cpu_shares](#prometheus_cpu_shares)
- [prometheus_default_folders](#prometheus_default_folders)
- [prometheus_default_labels](#prometheus_default_labels)
- [prometheus_default_publish](#prometheus_default_publish)
Expand All @@ -35,12 +36,17 @@ Building and improving this Ansible role have been sponsored by my current and p
- [prometheus_image](#prometheus_image)
- [prometheus_installation](#prometheus_installation)
- [prometheus_listen_address](#prometheus_listen_address)
- [prometheus_memory_limit](#prometheus_memory_limit)
- [prometheus_memory_soft_limit](#prometheus_memory_soft_limit)
- [prometheus_memory_swap](#prometheus_memory_swap)
- [prometheus_network](#prometheus_network)
- [prometheus_number_of_cpus](#prometheus_number_of_cpus)
- [prometheus_oauth2_access_logging](#prometheus_oauth2_access_logging)
- [prometheus_oauth2_allowed_groups](#prometheus_oauth2_allowed_groups)
- [prometheus_oauth2_client_id](#prometheus_oauth2_client_id)
- [prometheus_oauth2_client_secret](#prometheus_oauth2_client_secret)
- [prometheus_oauth2_cookie_secret](#prometheus_oauth2_cookie_secret)
- [prometheus_oauth2_cpu_shares](#prometheus_oauth2_cpu_shares)
- [prometheus_oauth2_default_labels](#prometheus_oauth2_default_labels)
- [prometheus_oauth2_default_publish](#prometheus_oauth2_default_publish)
- [prometheus_oauth2_download](#prometheus_oauth2_download)
Expand All @@ -50,7 +56,11 @@ Building and improving this Ansible role have been sponsored by my current and p
- [prometheus_oauth2_image](#prometheus_oauth2_image)
- [prometheus_oauth2_keycloak_url](#prometheus_oauth2_keycloak_url)
- [prometheus_oauth2_listen_address](#prometheus_oauth2_listen_address)
- [prometheus_oauth2_memory_limit](#prometheus_oauth2_memory_limit)
- [prometheus_oauth2_memory_soft_limit](#prometheus_oauth2_memory_soft_limit)
- [prometheus_oauth2_memory_swap](#prometheus_oauth2_memory_swap)
- [prometheus_oauth2_network](#prometheus_oauth2_network)
- [prometheus_oauth2_number_of_cpus](#prometheus_oauth2_number_of_cpus)
- [prometheus_oauth2_provider](#prometheus_oauth2_provider)
- [prometheus_oauth2_pull_image](#prometheus_oauth2_pull_image)
- [prometheus_oauth2_request_logging](#prometheus_oauth2_request_logging)
Expand Down Expand Up @@ -99,6 +109,22 @@ prometheus_alertmanagers:
- loclhost:9093
```

### prometheus_cpu_shares

CPU shares with Docker deployment

#### Default value

```YAML
prometheus_cpu_shares:
```

#### Example usage

```YAML
prometheus_cpu_shares: '512'
```

### prometheus_default_folders

List of default folders to create
Expand Down Expand Up @@ -353,6 +379,54 @@ Listen address for the prometheus
prometheus_listen_address: 0.0.0.0:9090
```

### prometheus_memory_limit

Memory limit with Docker deployment

#### Default value

```YAML
prometheus_memory_limit:
```

#### Example usage

```YAML
prometheus_memory_limit: 1024m
```

### prometheus_memory_soft_limit

Soft memory limit with Docker deployment

#### Default value

```YAML
prometheus_memory_soft_limit:
```

#### Example usage

```YAML
prometheus_memory_soft_limit: 512m
```

### prometheus_memory_swap

Swap usage with Docker deployment

#### Default value

```YAML
prometheus_memory_swap:
```

#### Example usage

```YAML
prometheus_memory_swap: 2048m
```

### prometheus_network

Optional docker network to attach on OAuth2 Proxy
Expand All @@ -363,6 +437,22 @@ Optional docker network to attach on OAuth2 Proxy
prometheus_network:
```

### prometheus_number_of_cpus

Number of CPUs with Docker deployment

#### Default value

```YAML
prometheus_number_of_cpus:
```

#### Example usage

```YAML
prometheus_number_of_cpus: '1.0'
```

### prometheus_oauth2_access_logging

Enable access logging for OAuth2 proxy
Expand Down Expand Up @@ -422,6 +512,22 @@ Cookie secret used by OAuth2 proxy
prometheus_oauth2_cookie_secret:
```

### prometheus_oauth2_cpu_shares

CPU shares with Docker deployment

#### Default value

```YAML
prometheus_oauth2_cpu_shares:
```

#### Example usage

```YAML
prometheus_oauth2_cpu_shares: '512'
```

### prometheus_oauth2_default_labels

List of default labels to assign to docker on OAuth2 Proxy
Expand Down Expand Up @@ -524,6 +630,54 @@ Listem address for the OAuth2 proxy
prometheus_oauth2_listen_address: 0.0.0.0:9089
```

### prometheus_oauth2_memory_limit

Memory limit with Docker deployment

#### Default value

```YAML
prometheus_oauth2_memory_limit:
```

#### Example usage

```YAML
prometheus_oauth2_memory_limit: 1024m
```

### prometheus_oauth2_memory_soft_limit

Soft memory limit with Docker deployment

#### Default value

```YAML
prometheus_oauth2_memory_soft_limit:
```

#### Example usage

```YAML
prometheus_oauth2_memory_soft_limit: 512m
```

### prometheus_oauth2_memory_swap

Swap usage with Docker deployment

#### Default value

```YAML
prometheus_oauth2_memory_swap:
```

#### Example usage

```YAML
prometheus_oauth2_memory_swap: 2048m
```

### prometheus_oauth2_network

#### Default value
Expand All @@ -532,6 +686,22 @@ prometheus_oauth2_listen_address: 0.0.0.0:9089
prometheus_oauth2_network: '{{ prometheus_network }}'
```

### prometheus_oauth2_number_of_cpus

Number of CPUs with Docker deployment

#### Default value

```YAML
prometheus_oauth2_number_of_cpus:
```

#### Example usage

```YAML
prometheus_oauth2_number_of_cpus: '1.5'
```

### prometheus_oauth2_provider

Provider for OAuth2 authentication
Expand Down
40 changes: 40 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,26 @@ prometheus_default_volumes:
# @end
prometheus_extra_volumes: []

# @var prometheus_memory_limit:description: Memory limit with Docker deployment
# @var prometheus_memory_limit:example: $ "1024m"
prometheus_memory_limit:

# @var prometheus_memory_swap:description: Swap usage with Docker deployment
# @var prometheus_memory_swap:example: $ "2048m"
prometheus_memory_swap:

# @var prometheus_memory_soft_limit:description: Soft memory limit with Docker deployment
# @var prometheus_memory_soft_limit:example: $ "512m"
prometheus_memory_soft_limit:

# @var prometheus_cpu_shares:description: CPU shares with Docker deployment
# @var prometheus_cpu_shares:example: $ "512"
prometheus_cpu_shares:

# @var prometheus_number_of_cpus:description: Number of CPUs with Docker deployment
# @var prometheus_number_of_cpus:example: $ "1.0"
prometheus_number_of_cpus:

# @var prometheus_domain:description: Domain for external access
# @var prometheus_domain:example: $ "https://prometheus.example.com"
prometheus_domain:
Expand Down Expand Up @@ -195,6 +215,26 @@ prometheus_oauth2_default_labels: []
# @var prometheus_oauth2_extra_labels:description: List of extra labels to assign to docker on OAuth2 Proxy
prometheus_oauth2_extra_labels: []

# @var prometheus_oauth2_memory_limit:description: Memory limit with Docker deployment
# @var prometheus_oauth2_memory_limit:example: $ "1024m"
prometheus_oauth2_memory_limit:

# @var prometheus_oauth2_memory_swap:description: Swap usage with Docker deployment
# @var prometheus_oauth2_memory_swap:example: $ "2048m"
prometheus_oauth2_memory_swap:

# @var prometheus_oauth2_memory_soft_limit:description: Soft memory limit with Docker deployment
# @var prometheus_oauth2_memory_soft_limit:example: $ "512m"
prometheus_oauth2_memory_soft_limit:

# @var prometheus_oauth2_cpu_shares:description: CPU shares with Docker deployment
# @var prometheus_oauth2_cpu_shares:example: $ "512"
prometheus_oauth2_cpu_shares:

# @var prometheus_oauth2_number_of_cpus:description: Number of CPUs with Docker deployment
# @var prometheus_oauth2_number_of_cpus:example: $ "1.5"
prometheus_oauth2_number_of_cpus:

# @var prometheus_oauth2_upstream:description: Upstream target for the OAuth2 proxy
prometheus_oauth2_upstream: "http://{{ prometheus_listen_address if prometheus_installation == 'native' else 'prometheus:9090' }}"

Expand Down
15 changes: 15 additions & 0 deletions templates/oauth2/service.j2
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,21 @@ ExecStart=/usr/bin/docker run --rm \
--name %p \
--hostname %p \
--env-file /etc/default/prometheus-oauth2 \
{% if prometheus_oauth2_memory_limit | default(False) %}
--memory {{ prometheus_oauth2_memory_limit }} \
{% endif %}
{% if prometheus_oauth2_memory_swap | default(False) %}
--memory-swap {{ prometheus_oauth2_memory_swap }} \
{% endif %}
{% if prometheus_oauth2_memory_soft_limit | default(False) %}
--memory-reservation {{ prometheus_oauth2_memory_soft_limit }} \
{% endif %}
{% if prometheus_oauth2_cpu_shares | default(False) %}
--cpu-shares {{ prometheus_oauth2_cpu_shares }} \
{% endif %}
{% if prometheus_oauth2_number_of_cpus | default(False) %}
--cpus {{ prometheus_oauth2_number_of_cpus }} \
{% endif %}
{% for item in prometheus_oauth2_default_labels + prometheus_oauth2_extra_labels %}
--label {{ item }} \
{% endfor %}
Expand Down
15 changes: 15 additions & 0 deletions templates/service.j2
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,21 @@ ExecStart=/usr/bin/docker run --rm \
--name %p \
--hostname %p \
--env-file /etc/default/prometheus \
{% if prometheus_memory_limit | default(False) %}
--memory {{ prometheus_memory_limit }} \
{% endif %}
{% if prometheus_memory_swap | default(False) %}
--memory-swap {{ prometheus_memory_swap }} \
{% endif %}
{% if prometheus_memory_soft_limit | default(False) %}
--memory-reservation {{ prometheus_memory_soft_limit }} \
{% endif %}
{% if prometheus_cpu_shares | default(False) %}
--cpu-shares {{ prometheus_cpu_shares }} \
{% endif %}
{% if prometheus_number_of_cpus | default(False) %}
--cpus {{ prometheus_number_of_cpus }} \
{% endif %}
{% for item in prometheus_default_labels + prometheus_extra_labels %}
--label {{ item }} \
{% endfor %}
Expand Down

0 comments on commit 4e92a98

Please sign in to comment.