Skip to content

Commit

Permalink
Merge pull request #76 from dasmeta/DMVP-2778-kube-state-metrics-refa…
Browse files Browse the repository at this point in the history
…ctoring

fix(DMVP-2778): Kube State Metrics refactoring
  • Loading branch information
viktoryathegreat authored Sep 29, 2023
2 parents a1af57a + 251f92d commit 42c7f1c
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 12 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,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_adot_config"></a> [adot\_config](#input\_adot\_config) | n/a | `any` | <pre>{<br> "accepte_namespace_regex": "(default|kube-system)",<br> "additional_metrics": {}<br>}</pre> | no |
| <a name="input_adot_config"></a> [adot\_config](#input\_adot\_config) | n/a | `any` | <pre>{<br> "accept_namespace_regex": "(default|kube-system)",<br> "additional_metrics": {},<br> "log_group_name": "adot_log_group"<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_alb_log_bucket_name"></a> [alb\_log\_bucket\_name](#input\_alb\_log\_bucket\_name) | n/a | `string` | `""` | no |
| <a name="input_alb_log_bucket_path"></a> [alb\_log\_bucket\_path](#input\_alb\_log\_bucket\_path) | ALB-INGRESS-CONTROLLER | `string` | `""` | no |
Expand Down Expand Up @@ -268,6 +268,7 @@ worker_groups = {
| <a name="input_node_groups"></a> [node\_groups](#input\_node\_groups) | Map of EKS managed node group definitions to create | `any` | <pre>{<br> "default": {<br> "desired_size": 2,<br> "iam_role_additional_policies": [<br> "arn:aws:iam::aws:policy/CloudWatchAgentServerPolicy"<br> ],<br> "instance_types": [<br> "t3.medium"<br> ],<br> "max_size": 4,<br> "min_size": 2<br> }<br>}</pre> | no |
| <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.medium"<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_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 |
| <a name="input_scale_down_unneeded_time"></a> [scale\_down\_unneeded\_time](#input\_scale\_down\_unneeded\_time) | Scale down unneeded in minutes | `number` | `2` | no |
Expand Down
2 changes: 1 addition & 1 deletion examples/spot-instance/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

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

## Modules

Expand Down
5 changes: 5 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ module "adot" {
oidc_provider_arn = module.eks-cluster[0].oidc_provider_arn
adot_config = var.adot_config
adot_version = var.adot_version
prometheus_metrics = var.prometheus_metrics
region = local.region
depends_on = [
module.eks-cluster,
Expand Down Expand Up @@ -358,6 +359,10 @@ resource "helm_release" "kube-state-metrics" {
version = "4.22.3"
create_namespace = false
atomic = true
set_list {
name = "metricAllowlist"
value = var.prometheus_metrics
}
}

module "autoscaler" {
Expand Down
4 changes: 2 additions & 2 deletions modules/adot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,14 @@ No modules.
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_adot_collector_policy_arns"></a> [adot\_collector\_policy\_arns](#input\_adot\_collector\_policy\_arns) | List of IAM policy ARNs to attach to the ADOT collector service account. | `list(string)` | <pre>[<br> "arn:aws:iam::aws:policy/AmazonPrometheusRemoteWriteAccess",<br> "arn:aws:iam::aws:policy/CloudWatchAgentServerPolicy",<br> "arn:aws:iam::aws:policy/AWSXrayWriteOnlyAccess"<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. | `any` | <pre>{<br> "accept_namespace_regex": "(default|kube-system)",<br> "additional_metrics": [],<br> "helm_values": null<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. | `any` | <pre>{<br> "accept_namespace_regex": "(default|kube-system)",<br> "additional_metrics": [],<br> "helm_values": null,<br> "log_group_name": "adot_log_group"<br>}</pre> | no |
| <a name="input_adot_log_group_name"></a> [adot\_log\_group\_name](#input\_adot\_log\_group\_name) | ADOT log group name | `string` | `"adot_log_group_name"` | 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_cluster_name"></a> [cluster\_name](#input\_cluster\_name) | K8s cluster name. | `string` | n/a | yes |
| <a name="input_eks_oidc_root_ca_thumbprint"></a> [eks\_oidc\_root\_ca\_thumbprint](#input\_eks\_oidc\_root\_ca\_thumbprint) | EKS oidc root ca thumbprint. | `string` | n/a | yes |
| <a name="input_namespace"></a> [namespace](#input\_namespace) | The namespace to install the AWS Distro for OpenTelemetry addon. | `string` | `"adot"` | no |
| <a name="input_oidc_provider_arn"></a> [oidc\_provider\_arn](#input\_oidc\_provider\_arn) | EKC oidc provider arn. | `string` | n/a | yes |
| <a name="input_prometheus_metrics"></a> [prometheus\_metrics](#input\_prometheus\_metrics) | Prometheus Metrics | `any` | `{}` | 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 | `string` | n/a | yes |

## Outputs
Expand Down
2 changes: 1 addition & 1 deletion modules/adot/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ resource "helm_release" "adot-collector" {
region = local.region
cluster_name = var.cluster_name
accept_namespace_regex = var.adot_config.accept_namespace_regex
log_group_name = var.adot_log_group_name
log_group_name = var.adot_config.log_group_name
metrics = local.merged_metrics
metrics_namespace_specific = local.merged_namespace_specific
prometheus_metrics = var.prometheus_metrics
Expand Down
6 changes: 3 additions & 3 deletions modules/adot/templates/adot-values.yaml.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ adotCollector:
- Deployment
metric_name_selectors:
- kube_deployment_spec_replicas
%{ for key,value in prometheus_metrics }
- dimensions: ${key}
metric_name_selectors: ${jsonencode(value)}
- kube_deployment_status_replicas_available
%{ for value in prometheus_metrics }
- ${value}
%{ endfor ~}
namespace: ContainerInsights
parse_json_encoded_attr_values:
Expand Down
2 changes: 1 addition & 1 deletion modules/adot/tests/template_file/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

| Name | Version |
|------|---------|
| <a name="provider_helm"></a> [helm](#provider\_helm) | 2.9.0 |
| <a name="provider_helm"></a> [helm](#provider\_helm) | n/a |
| <a name="provider_test"></a> [test](#provider\_test) | n/a |

## Modules
Expand Down
3 changes: 2 additions & 1 deletion modules/adot/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ variable "adot_config" {
default = {
accept_namespace_regex = "(default|kube-system)"
additional_metrics = []
log_group_name = "adot_log_group"
# ADOT helm chart values.yaml, if you don't use variable adot will be deployed with module default values file
helm_values = null
}
Expand All @@ -54,7 +55,7 @@ variable "region" {
variable "prometheus_metrics" {
description = "Prometheus Metrics"
type = any
default = {}
default = []
}

variable "adot_log_group_name" {
Expand Down
11 changes: 9 additions & 2 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,9 @@ variable "metrics_exporter" {
variable "adot_config" {
type = any
default = {
accepte_namespace_regex = "(default|kube-system)"
additional_metrics = {}
accept_namespace_regex = "(default|kube-system)"
additional_metrics = {}
log_group_name = "adot_log_group"
}
}

Expand Down Expand Up @@ -377,3 +378,9 @@ variable "enable_olm" {
default = false
description = "To install OLM controller (experimental)."
}

variable "prometheus_metrics" {
description = "Prometheus Metrics"
type = any
default = []
}

0 comments on commit 42c7f1c

Please sign in to comment.