Skip to content

Commit

Permalink
fix(priority-class): DMVP-5359 add priority class
Browse files Browse the repository at this point in the history
  • Loading branch information
aramkarapetian committed Sep 26, 2024
1 parent e3bd59b commit 0dbe9e2
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 25 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ worker_groups = {
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_account_id"></a> [account\_id](#input\_account\_id) | AWS Account Id to apply changes into | `string` | `null` | no |
| <a name="input_additional_priority_classes"></a> [additional\_priority\_classes](#input\_additional\_priority\_classes) | Defines Priority Classes in Kubernetes, used to assign different levels of priority to pods. By default, this module creates three Priority Classes: 'high'(1000000), 'medium'(500000) and 'low'(250000) . You can also provide a custom list of Priority Classes if needed. | <pre>list(object({<br> name = string<br> value = string # number in string form<br> }))</pre> | `[]` | no |
| <a name="input_adot_config"></a> [adot\_config](#input\_adot\_config) | accept\_namespace\_regex defines the list of namespaces from which metrics will be exported, and additional\_metrics defines additional metrics to export. | <pre>object({<br> accept_namespace_regex = optional(string, "(default|kube-system)")<br> additional_metrics = optional(list(string), [])<br> log_group_name = optional(string, "adot")<br> log_retention = optional(number, 14)<br> helm_values = optional(any, null)<br> logging_enable = optional(bool, false)<br> resources = optional(object({<br> limit = object({<br> cpu = optional(string, "200m")<br> memory = optional(string, "200Mi")<br> })<br> requests = object({<br> cpu = optional(string, "200m")<br> memory = optional(string, "200Mi")<br> })<br> }), {<br> limit = {<br> cpu = "200m"<br> memory = "200Mi"<br> }<br> requests = {<br> cpu = "200m"<br> memory = "200Mi"<br> }<br> })<br> })</pre> | <pre>{<br> "accept_namespace_regex": "(default|kube-system)",<br> "additional_metrics": [],<br> "helm_values": null,<br> "log_group_name": "adot",<br> "log_retention": 14,<br> "logging_enable": false,<br> "resources": {<br> "limit": {<br> "cpu": "200m",<br> "memory": "200Mi"<br> },<br> "requests": {<br> "cpu": "200m",<br> "memory": "200Mi"<br> }<br> }<br>}</pre> | no |
| <a name="input_adot_version"></a> [adot\_version](#input\_adot\_version) | The version of the AWS Distro for OpenTelemetry addon to use. | `string` | `"v0.78.0-eksbuild.1"` | no |
| <a name="input_alarms"></a> [alarms](#input\_alarms) | Alarms enabled by default you need set sns topic name for send alarms for customize alarms threshold use custom\_values | <pre>object({<br> enabled = optional(bool, true)<br> sns_topic = string<br> custom_values = optional(any, {})<br> })</pre> | n/a | yes |
Expand Down Expand Up @@ -279,7 +280,6 @@ worker_groups = {
| <a name="input_node_groups_default"></a> [node\_groups\_default](#input\_node\_groups\_default) | Map of EKS managed node group default configurations | `any` | <pre>{<br> "disk_size": 50,<br> "iam_role_additional_policies": [<br> "arn:aws:iam::aws:policy/CloudWatchAgentServerPolicy"<br> ],<br> "instance_types": [<br> "t3.large"<br> ]<br>}</pre> | no |
| <a name="input_node_security_group_additional_rules"></a> [node\_security\_group\_additional\_rules](#input\_node\_security\_group\_additional\_rules) | n/a | `any` | <pre>{<br> "ingress_cluster_10250": {<br> "description": "Metric server to node groups",<br> "from_port": 10250,<br> "protocol": "tcp",<br> "self": true,<br> "to_port": 10250,<br> "type": "ingress"<br> },<br> "ingress_cluster_8443": {<br> "description": "Metric server to node groups",<br> "from_port": 8443,<br> "protocol": "tcp",<br> "source_cluster_security_group": true,<br> "to_port": 8443,<br> "type": "ingress"<br> }<br>}</pre> | no |
| <a name="input_portainer_config"></a> [portainer\_config](#input\_portainer\_config) | Portainer hostname and ingress config. | <pre>object({<br> host = optional(string, "portainer.dasmeta.com")<br> enable_ingress = optional(bool, true)<br> })</pre> | `{}` | no |
| <a name="input_priority_class"></a> [priority\_class](#input\_priority\_class) | Defines Priority Classes in Kubernetes, used to assign different levels of priority to pods. By default, this module creates three Priority Classes: 'high', 'medium' and 'low' . You can also provide a custom list of Priority Classes if needed. | `list(any)` | <pre>[<br> {}<br>]</pre> | no |
| <a name="input_prometheus_metrics"></a> [prometheus\_metrics](#input\_prometheus\_metrics) | Prometheus Metrics | `any` | `[]` | no |
| <a name="input_region"></a> [region](#input\_region) | AWS Region name. | `string` | `null` | no |
| <a name="input_roles"></a> [roles](#input\_roles) | Variable describes which role will user have K8s | <pre>list(object({<br> actions = list(string)<br> resources = list(string)<br> }))</pre> | `[]` | no |
Expand Down
4 changes: 2 additions & 2 deletions modules/priority-class/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ No modules.

| Name | Type |
|------|------|
| [kubernetes_priority_class.example](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/priority_class) | resource |
| [kubernetes_priority_class.this](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/priority_class) | resource |

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_priority_class"></a> [priority\_class](#input\_priority\_class) | Defines Priority Classes in Kubernetes, used to assign different levels of priority to pods. By default, this module creates three Priority Classes: 'high', 'medium' and 'low' . You can also provide a custom list of Priority Classes if needed. | `list(any)` | <pre>[<br> {}<br>]</pre> | no |
| <a name="input_additional_priority_classes"></a> [additional\_priority\_classes](#input\_additional\_priority\_classes) | Defines Priority Classes in Kubernetes, used to assign different levels of priority to pods. By default, this module creates three Priority Classes: 'high'(1000000), 'medium'(500000) and 'low'(250000) . You can also provide a custom list of Priority Classes if needed. | <pre>list(object({<br> name = string<br> value = string # number in string form<br> }))</pre> | `[]` | no |

## Outputs

Expand Down
5 changes: 2 additions & 3 deletions modules/priority-class/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,14 @@ locals {
value = "250000"
}
]
merged_priority_class = concat(local.priority_class_default, var.priority_class)
priority_class = [for map in local.merged_priority_class : map if length(map) > 0]
priority_class = concat(local.priority_class_default, var.additional_priority_classes)
}

output "priority_class" {
value = local.priority_class
}

resource "kubernetes_priority_class" "example" {
resource "kubernetes_priority_class" "this" {
# Transform the list of maps into a key-value map suitable for for_each
for_each = { for pc in local.priority_class : pc.name => pc }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ No requirements.

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | n/a |
| <a name="provider_aws"></a> [aws](#provider\_aws) | 5.68.0 |

## Modules

Expand Down
6 changes: 1 addition & 5 deletions modules/priority-class/tests/add-new-priority-class/main.tf
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
module "test" {
source = "../../"

priority_class = [
additional_priority_classes = [
{
name = "important"
value = "2000000"
},
]
}

output "priority_class" {
value = module.test.priority_class
}
3 changes: 3 additions & 0 deletions modules/priority-class/tests/add-new-priority-class/output.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
output "priority_class" {
value = module.test.priority_class
}
4 changes: 0 additions & 4 deletions modules/priority-class/tests/basic/main.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
module "test" {
source = "../../"
}

output "priority_class" {
value = module.test.priority_class
}
3 changes: 3 additions & 0 deletions modules/priority-class/tests/basic/output.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
output "priority_class" {
value = module.test.priority_class
}
11 changes: 7 additions & 4 deletions modules/priority-class/variables.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
variable "priority_class" {
type = list(any)
description = "Defines Priority Classes in Kubernetes, used to assign different levels of priority to pods. By default, this module creates three Priority Classes: 'high', 'medium' and 'low' . You can also provide a custom list of Priority Classes if needed."
default = [{}]
variable "additional_priority_classes" {
type = list(object({
name = string
value = string # number in string form
}))
description = "Defines Priority Classes in Kubernetes, used to assign different levels of priority to pods. By default, this module creates three Priority Classes: 'high'(1000000), 'medium'(500000) and 'low'(250000) . You can also provide a custom list of Priority Classes if needed."
default = []
}
2 changes: 1 addition & 1 deletion priority-class.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module "priority_class" {
source = "./modules/priority-class/"

priority_class = var.priority_class
additional_priority_classes = var.additional_priority_classes
}
11 changes: 7 additions & 4 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -564,8 +564,11 @@ variable "alarms" {
description = "Alarms enabled by default you need set sns topic name for send alarms for customize alarms threshold use custom_values"
}

variable "priority_class" {
type = list(any)
description = "Defines Priority Classes in Kubernetes, used to assign different levels of priority to pods. By default, this module creates three Priority Classes: 'high', 'medium' and 'low' . You can also provide a custom list of Priority Classes if needed."
default = [{}]
variable "additional_priority_classes" {
type = list(object({
name = string
value = string # number in string form
}))
description = "Defines Priority Classes in Kubernetes, used to assign different levels of priority to pods. By default, this module creates three Priority Classes: 'high'(1000000), 'medium'(500000) and 'low'(250000) . You can also provide a custom list of Priority Classes if needed."
default = []
}

0 comments on commit 0dbe9e2

Please sign in to comment.