Skip to content

Commit

Permalink
feat: allow setting cadvisor and node-exporter image registry and repo (
Browse files Browse the repository at this point in the history
#38)

## Description
<!--- Describe your changes in detail -->

## Motivation and Context
<!--- Why is this change required? What problem does it solve? -->
<!--- If it fixes an open issue, please link to the issue here. -->

## Breaking Changes
<!-- Does this break backwards compatibility with the current major
version? -->
<!-- If so, please provide an explanation why it is necessary. -->

## How Has This Been Tested?
- [ ] I have updated at least one of the `examples/*` to demonstrate and
validate my change(s)
- [ ] I have tested and validated these changes using one or more of the
provided `examples/*` projects
<!--- Users should start with an existing example as its written, deploy
it, then check their changes against it -->
<!--- This will highlight breaking/disruptive changes. Once you have
checked, deploy your changes to verify -->
<!--- Please describe how you tested your changes -->
- [ ] I have executed `pre-commit run -a` on my pull request
<!--- Please see
https://github.com/antonbabenko/pre-commit-terraform#how-to-install for
how to install -->
  • Loading branch information
applike-ss authored Feb 21, 2024
1 parent bc47fa4 commit 960bfcf
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
| <a name="input_aws_account_id"></a> [aws\_account\_id](#input\_aws\_account\_id) | AWS account id | `string` | `null` | no |
| <a name="input_aws_region"></a> [aws\_region](#input\_aws\_region) | AWS region | `string` | `null` | no |
| <a name="input_cadvisor_cpu"></a> [cadvisor\_cpu](#input\_cadvisor\_cpu) | Number of CPU units to reserve for the container | `number` | `100` | no |
| <a name="input_cadvisor_registry"></a> [cadvisor\_registry](#input\_cadvisor\_registry) | cAdvisor registry to be used | `string` | `"gcr.io"` | no |
| <a name="input_cadvisor_repository"></a> [cadvisor\_repository](#input\_cadvisor\_repository) | cAdvisor repository to be used | `string` | `"cadvisor/cadvisor"` | no |
| <a name="input_cadvisor_version"></a> [cadvisor\_version](#input\_cadvisor\_version) | cAdvisor version to be deployed | `string` | `"v0.47.0"` | no |
| <a name="input_container_memory_reservation"></a> [container\_memory\_reservation](#input\_container\_memory\_reservation) | The amount of memory (in MiB) to reserve for the container. If container needs to exceed this threshold, it can do so up to the set container\_memory hard limit | `number` | `128` | no |
| <a name="input_context"></a> [context](#input\_context) | Single object for setting entire context at once.<br>See description of individual variables for details.<br>Leave string and numeric variables as `null` to use default value.<br>Individual variable settings (non-null) override settings in context object,<br>except for attributes, tags, and additional\_tag\_map, which are merged. | `any` | <pre>{<br> "additional_tag_map": {},<br> "attributes": [],<br> "delimiter": null,<br> "descriptor_formats": {},<br> "enabled": true,<br> "environment": null,<br> "id_length_limit": null,<br> "label_key_case": null,<br> "label_order": [],<br> "label_value_case": null,<br> "labels_as_tags": [<br> "unset"<br> ],<br> "name": null,<br> "namespace": null,<br> "regex_replace_chars": null,<br> "stage": null,<br> "tags": {},<br> "tenant": null<br>}</pre> | no |
Expand All @@ -58,6 +60,8 @@
| <a name="input_name"></a> [name](#input\_name) | ID element. Usually the component or solution name, e.g. 'app' or 'jenkins'.<br>This is the only ID element not also included as a `tag`.<br>The "name" tag is set to the full `id` string. There is no tag with the value of the `name` input. | `string` | `null` | no |
| <a name="input_namespace"></a> [namespace](#input\_namespace) | ID element. Usually an abbreviation of your organization name, e.g. 'eg' or 'cp', to help ensure generated IDs are globally unique | `string` | `null` | no |
| <a name="input_node_exporter_cpu"></a> [node\_exporter\_cpu](#input\_node\_exporter\_cpu) | Number of CPU units to reserve for the container | `number` | `100` | no |
| <a name="input_node_exporter_registry"></a> [node\_exporter\_registry](#input\_node\_exporter\_registry) | Node exporter registry to be used | `string` | `"quay.io"` | no |
| <a name="input_node_exporter_repository"></a> [node\_exporter\_repository](#input\_node\_exporter\_repository) | Node exporter repository to be used | `string` | `"prometheus/node-exporter"` | no |
| <a name="input_node_exporter_version"></a> [node\_exporter\_version](#input\_node\_exporter\_version) | Node exporter version to be deployed | `string` | `"v1.5.0"` | no |
| <a name="input_organizational_unit"></a> [organizational\_unit](#input\_organizational\_unit) | Usually used to indicate the AWS organizational unit, e.g. 'prod', 'sdlc' | `string` | `null` | no |
| <a name="input_regex_replace_chars"></a> [regex\_replace\_chars](#input\_regex\_replace\_chars) | Terraform regular expression (regex) string.<br>Characters matching the regex will be removed from the ID elements.<br>If not set, `"/[^a-zA-Z0-9-]/"` is used to remove all characters other than hyphens, letters and digits. | `string` | `null` | no |
Expand Down
4 changes: 2 additions & 2 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ module "node_exporter_definition" {
interactive = false
readonly_root_filesystem = true
container_name = "node-exporter"
container_image = "quay.io/prometheus/node-exporter:${var.node_exporter_version}"
container_image = "${var.node_exporter_registry}/${var.node_exporter_repository}:${var.node_exporter_version}"
mount_points = [
{
containerPath = "/host"
Expand Down Expand Up @@ -68,7 +68,7 @@ module "cadvisor_definition" {
interactive = false
readonly_root_filesystem = true
container_name = "cadvisor"
container_image = "gcr.io/cadvisor/cadvisor:${var.cadvisor_version}"
container_image = "${var.cadvisor_registry}/${var.cadvisor_repository}:${var.cadvisor_version}"
mount_points = [
{
containerPath = "/sys/fs/cgroup"
Expand Down
24 changes: 24 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@ variable "cadvisor_cpu" {
default = 100
}

variable "cadvisor_registry" {
type = string
description = "cAdvisor registry to be used"
default = "gcr.io"
}

variable "cadvisor_repository" {
type = string
description = "cAdvisor repository to be used"
default = "cadvisor/cadvisor"
}

variable "cadvisor_version" {
type = string
description = "cAdvisor version to be deployed"
Expand Down Expand Up @@ -50,6 +62,18 @@ variable "node_exporter_cpu" {
default = 100
}

variable "node_exporter_registry" {
type = string
description = "Node exporter registry to be used"
default = "quay.io"
}

variable "node_exporter_repository" {
type = string
description = "Node exporter repository to be used"
default = "prometheus/node-exporter"
}

variable "node_exporter_version" {
type = string
description = "Node exporter version to be deployed"
Expand Down

0 comments on commit 960bfcf

Please sign in to comment.