Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ No modules.
| <a name="input_metrics_filter"></a> [metrics\_filter](#input\_metrics\_filter) | To filter custom metrics you can specify which metrics to include and exclude. For more info, see https://cloud.ibm.com/docs/monitoring?topic=monitoring-change_kube_agent#change_kube_agent_inc_exc_metrics | <pre>list(object({<br/> include = optional(string)<br/> exclude = optional(string)<br/> }))</pre> | `[]` | no |
| <a name="input_name"></a> [name](#input\_name) | The name to give the agent helm release. | `string` | `"sysdig-agent"` | no |
| <a name="input_namespace"></a> [namespace](#input\_namespace) | Namespace to deploy the agent to. | `string` | `"ibm-observe"` | no |
| <a name="input_node_selector"></a> [node\_selector](#input\_node\_selector) | Map of node selector labels for the DaemonSet pods. Defaults to empty map. | `map(string)` | `{}` | no |
| <a name="input_priority_class_name"></a> [priority\_class\_name](#input\_priority\_class\_name) | The priority class name for the PriorityClasses assigned to the monitoring agent daemonset. If no value is passed, priority class is not used. | `string` | `null` | no |
| <a name="input_priority_class_value"></a> [priority\_class\_value](#input\_priority\_class\_value) | The numerical priority assigned to PriorityClass, which determines the importance of monitoring agent daemonset pod within the cluster for both scheduling and eviction decisions. The value only applies if a value was passed for `priority_class_name` | `number` | `10` | no |
| <a name="input_prometheus_config"></a> [prometheus\_config](#input\_prometheus\_config) | Prometheus configuration for the agent. If you want to enable Prometheus configuration provide the prometheus.yaml file content in `hcl` format. [Learn more](https://github.com/terraform-ibm-modules/terraform-ibm-monitoring-agent/blob/main/solutions/fully-configurable/DA-types.md#prometheus_config). | `map(any)` | `{}` | no |
Expand Down
6 changes: 6 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,12 @@ resource "helm_release" "cloud_monitoring_agent" {
%{if var.max_surge != null}
"maxSurge": ${var.max_surge}
%{endif}
%{if length(var.node_selector) > 0}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you tested this with multiple node_selector's?

I think currently this will currently give invalid json if you provide multiple node selectors. Missing comma between selectors.

var.node_selector = { "k1" = "v1", "k2" = "v2" }

{
  "nodeSelector":
    "k1": "v1" 
    "k2": "v2"
}

Instead we could do something like this:

%{if length(var.node_selector) > 0}
  "nodeSelector": ${jsonencode(var.node_selector)}
%{endif}

And the result be:

{
  "maxSurge": 1,
  "nodeSelector": {
    "k1": "v1",
    "k2": "v2"
  }
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jor2 Yes, I did test with multiple nodeSelector's. It was working.
But using jsonencode() approach seems more robust. I will change the code to use jsonencode()

"nodeSelector":
%{for label_key, label_value in var.node_selector~}
"${label_key}": "${label_value}"
%{endfor~}
%{endif}
EOT
]

Expand Down
1 change: 1 addition & 0 deletions solutions/fully-configurable/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,5 @@ module "monitoring_agent" {
max_surge = var.max_surge
priority_class_name = var.priority_class_name
priority_class_value = var.priority_class_value
node_selector = var.node_selector
}
7 changes: 7 additions & 0 deletions solutions/fully-configurable/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,13 @@ variable "priority_class_value" {
default = 10
}

variable "node_selector" {
type = map(string)
nullable = false
description = "Map of node selector labels for the DaemonSet pods. Defaults to empty map."
default = {}
}

##############################################################################
# Metrics related variables
##############################################################################
Expand Down
7 changes: 7 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,13 @@ variable "priority_class_value" {
default = 10
}

variable "node_selector" {
type = map(string)
nullable = false
description = "Map of node selector labels for the DaemonSet pods. Defaults to empty map."
default = {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If a user passed null to this, I think logic will break since its used in a for loop. Can you add nullable = false so it will not allow null to be passed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay

}

##############################################################################
# Metrics related variables
##############################################################################
Expand Down