Skip to content

Commit c7b8e26

Browse files
feat: Add support for priorityClass and make updateStrategy configurable using new inputs priority_class_value, priority_class_name, max_surge, max_unavailable (#189)
1 parent 3ecaac8 commit c7b8e26

File tree

8 files changed

+112
-0
lines changed

8 files changed

+112
-0
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,13 @@ No modules.
143143
| <a name="input_is_vpc_cluster"></a> [is\_vpc\_cluster](#input\_is\_vpc\_cluster) | Specify true if the target cluster is a VPC cluster, false if it is a classic cluster. | `bool` | `true` | no |
144144
| <a name="input_kernal_module_image_repository"></a> [kernal\_module\_image\_repository](#input\_kernal\_module\_image\_repository) | The image repository to pull the agent kernal module initContainer image from. | `string` | `"agent-kmodule"` | no |
145145
| <a name="input_kernel_module_image_tag_digest"></a> [kernel\_module\_image\_tag\_digest](#input\_kernel\_module\_image\_tag\_digest) | The image tag or digest to use for the agent kernel module used by the initContainer. If using digest, it must be in the format of `X.Y.Z@sha256:xxxxx` | `string` | `"14.2.0@sha256:3be3966e2bef75364f55d248156a568a222afaba3067f43c5c642c46b690cca9"` | no |
146+
| <a name="input_max_surge"></a> [max\_surge](#input\_max\_surge) | The number of pods that can be created above the desired amount of daemonset pods during an update. If `max_surge` is set to null, the `max_surge` setting is ignored. The variable accepts absolute number or percentage value(e.g., '1' or '10%'). | `string` | `null` | no |
147+
| <a name="input_max_unavailable"></a> [max\_unavailable](#input\_max\_unavailable) | The maximum number of pods that can be unavailable during a DaemonSet rolling update. Accepts absolute number or percentage (e.g., '1' or '10%'). | `string` | `"1"` | no |
146148
| <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 |
147149
| <a name="input_name"></a> [name](#input\_name) | The name to give the agent helm release. | `string` | `"sysdig-agent"` | no |
148150
| <a name="input_namespace"></a> [namespace](#input\_namespace) | Namespace to deploy the agent to. | `string` | `"ibm-observe"` | no |
151+
| <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 |
152+
| <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 |
149153
| <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 |
150154
| <a name="input_tolerations"></a> [tolerations](#input\_tolerations) | List of tolerations to apply to the agent. | <pre>list(object({<br/> key = optional(string)<br/> operator = optional(string)<br/> value = optional(string)<br/> effect = optional(string)<br/> tolerationSeconds = optional(number)<br/> }))</pre> | <pre>[<br/> {<br/> "operator": "Exists"<br/> },<br/> {<br/> "effect": "NoSchedule",<br/> "key": "node-role.kubernetes.io/master",<br/> "operator": "Exists"<br/> }<br/>]</pre> | no |
151155
| <a name="input_use_private_endpoint"></a> [use\_private\_endpoint](#input\_use\_private\_endpoint) | Whether send data over a private endpoint or not. To use a private endpoint, you must enable virtual routing and forwarding (VRF) for your account. See https://cloud.ibm.com/docs/account?topic=account-vrf-service-endpoint. | `bool` | `true` | no |

examples/obs-agent-iks/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ module "monitoring_agents" {
145145
is_vpc_cluster = var.is_vpc_cluster
146146
access_key = module.cloud_monitoring.access_key
147147
instance_region = var.region
148+
priority_class_name = "sysdig-daemonset-priority"
148149
prometheus_config = {
149150
scrape_configs = [
150151
{

ibm_catalog.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,32 @@
265265
{
266266
"key": "agent_limits_memory"
267267
},
268+
{
269+
"key": "max_surge",
270+
"value_constraints": [
271+
{
272+
"type": "regex",
273+
"description": "The value provided for 'max_surge' must be a positive integer (e.g., '1') or a percentage (e.g., '10%'), or null.",
274+
"value": "^__NULL__$|^\\d+%?$"
275+
}
276+
]
277+
},
278+
{
279+
"key": "max_unavailable",
280+
"value_constraints": [
281+
{
282+
"type": "regex",
283+
"description": "The value provided for 'max_unavailable' must be a positive integer (e.g., '1') or a percentage (e.g., '10%').",
284+
"value": "^\\d+%?$"
285+
}
286+
]
287+
},
288+
{
289+
"key": "priority_class_name"
290+
},
291+
{
292+
"key": "priority_class_value"
293+
},
268294
{
269295
"key": "tolerations",
270296
"type": "array",

main.tf

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,19 @@ resource "helm_release" "cloud_monitoring_agent" {
252252
%{for line in split("\n", yamlencode(var.prometheus_config))~}
253253
${line}
254254
%{endfor~}
255+
%{if var.priority_class_name != null}
256+
"createPriorityClass": true
257+
"priorityClassName": ${var.priority_class_name}
258+
"priorityClassValue": ${var.priority_class_value}
259+
%{endif}
260+
"daemonset":
261+
"updateStrategy":
262+
"type": "RollingUpdate"
263+
"rollingUpdate":
264+
"maxUnavailable": ${var.max_unavailable}
265+
%{if var.max_surge != null}
266+
"maxSurge": ${var.max_surge}
267+
%{endif}
255268
EOT
256269
]
257270

solutions/fully-configurable/main.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,8 @@ module "monitoring_agent" {
5353
cluster_shield_limits_cpu = var.cluster_shield_limits_cpu
5454
cluster_shield_requests_memory = var.cluster_shield_requests_memory
5555
cluster_shield_limits_memory = var.cluster_shield_limits_memory
56+
max_unavailable = var.max_unavailable
57+
max_surge = var.max_surge
58+
priority_class_name = var.priority_class_name
59+
priority_class_value = var.priority_class_value
5660
}

solutions/fully-configurable/variables.tf

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,32 @@ variable "deployment_tag" {
245245
default = "terraform"
246246
}
247247

248+
variable "max_unavailable" {
249+
type = string
250+
description = "The maximum number of pods that can be unavailable during a DaemonSet rolling update. Accepts absolute number or percentage (e.g., '1' or '10%')."
251+
default = "1"
252+
nullable = false
253+
}
254+
255+
variable "max_surge" {
256+
type = string
257+
description = "The number of pods that can be created above the desired amount of daemonset pods during an update. If `max_surge` is set to null, the `max_surge` setting is ignored. The variable accepts absolute number or percentage value(e.g., '1' or '10%')."
258+
default = null
259+
}
260+
261+
variable "priority_class_name" {
262+
type = string
263+
description = "The priority class name for the PriorityClasses assigned to the monitoring agent daemonset. If no value is passed, priority class is not used."
264+
default = null
265+
}
266+
267+
variable "priority_class_value" {
268+
type = number
269+
nullable = false
270+
description = "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`"
271+
default = 10
272+
}
273+
248274
##############################################################################
249275
# Metrics related variables
250276
##############################################################################

tests/pr_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ func TestFullyConfigurableSolution(t *testing.T) {
118118
{Name: "cluster_id", Value: terraform.Output(t, existingTerraformOptions, "cluster_id"), DataType: "string"},
119119
{Name: "cluster_resource_group_id", Value: terraform.Output(t, existingTerraformOptions, "cluster_resource_group_id"), DataType: "string"},
120120
{Name: "access_key", Value: terraform.Output(t, existingTerraformOptions, "access_key"), DataType: "string", Secure: true},
121+
{Name: "priority_class_name", Value: "sysdig-daemonset-priority", DataType: "string"},
121122
}
122123

123124
err := options.RunSchematicTest()

variables.tf

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,43 @@ variable "deployment_tag" {
246246
default = "terraform"
247247
}
248248

249+
variable "max_unavailable" {
250+
type = string
251+
description = "The maximum number of pods that can be unavailable during a DaemonSet rolling update. Accepts absolute number or percentage (e.g., '1' or '10%')."
252+
default = "1"
253+
nullable = false
254+
validation {
255+
condition = can(regex("^\\d+%?$", var.max_unavailable))
256+
error_message = "max_unavailable must be a positive integer (e.g., '1') or a percentage (e.g., '10%')."
257+
}
258+
}
259+
260+
variable "max_surge" {
261+
type = string
262+
description = "The number of pods that can be created above the desired amount of daemonset pods during an update. If `max_surge` is set to null, the `max_surge` setting is ignored. The variable accepts absolute number or percentage value(e.g., '1' or '10%')."
263+
default = null
264+
validation {
265+
condition = (
266+
var.max_surge == null ||
267+
can(regex("^\\d+%?$", var.max_surge))
268+
)
269+
error_message = "max_surge must be a positive integer (e.g., '1') or a percentage (e.g., '10%'), or null."
270+
}
271+
}
272+
273+
variable "priority_class_name" {
274+
type = string
275+
description = "The priority class name for the PriorityClasses assigned to the monitoring agent daemonset. If no value is passed, priority class is not used."
276+
default = null
277+
}
278+
279+
variable "priority_class_value" {
280+
type = number
281+
nullable = false
282+
description = "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`"
283+
default = 10
284+
}
285+
249286
##############################################################################
250287
# Metrics related variables
251288
##############################################################################

0 commit comments

Comments
 (0)