Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow custom IAM role & SA names #238

Merged
merged 2 commits into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from all 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 modules/eks-monitoring/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ See examples using this Terraform modules in the **Amazon EKS** section of [this
| <a name="input_helm_config"></a> [helm\_config](#input\_helm\_config) | Helm Config for Prometheus | `any` | `{}` | no |
| <a name="input_irsa_iam_additional_policies"></a> [irsa\_iam\_additional\_policies](#input\_irsa\_iam\_additional\_policies) | IAM additional policies for IRSA roles | `list(string)` | `[]` | no |
| <a name="input_irsa_iam_permissions_boundary"></a> [irsa\_iam\_permissions\_boundary](#input\_irsa\_iam\_permissions\_boundary) | IAM permissions boundary for IRSA roles | `string` | `null` | no |
| <a name="input_irsa_iam_role_name"></a> [irsa\_iam\_role\_name](#input\_irsa\_iam\_role\_name) | IAM role name for IRSA roles | `string` | `""` | no |
| <a name="input_irsa_iam_role_path"></a> [irsa\_iam\_role\_path](#input\_irsa\_iam\_role\_path) | IAM role path for IRSA roles | `string` | `"/"` | no |
| <a name="input_istio_config"></a> [istio\_config](#input\_istio\_config) | Configuration object for ISTIO monitoring | <pre>object({<br> enable_alerting_rules = bool<br> enable_recording_rules = bool<br> enable_dashboards = bool<br> scrape_sample_limit = number<br><br> flux_gitrepository_name = string<br> flux_gitrepository_url = string<br> flux_gitrepository_branch = string<br> flux_kustomization_name = string<br> flux_kustomization_path = string<br><br> managed_prometheus_workspace_id = string<br> prometheus_metrics_endpoint = string<br><br> dashboards = object({<br> cp = string<br> mesh = string<br> performance = string<br> service = string<br> })<br> })</pre> | `null` | no |
| <a name="input_java_config"></a> [java\_config](#input\_java\_config) | Configuration object for Java/JMX monitoring | <pre>object({<br> enable_alerting_rules = bool<br> enable_recording_rules = bool<br> enable_dashboards = bool<br> scrape_sample_limit = number<br><br><br> flux_gitrepository_name = string<br> flux_gitrepository_url = string<br> flux_gitrepository_branch = string<br> flux_kustomization_name = string<br> flux_kustomization_path = string<br><br> grafana_dashboard_url = string<br><br> prometheus_metrics_endpoint = string<br> })</pre> | `null` | no |
Expand Down
5 changes: 3 additions & 2 deletions modules/eks-monitoring/locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ data "aws_eks_cluster" "eks_cluster" {
}

locals {
name = "adot-collector-kubeprometheus"
namespace = try(var.helm_config.namespace, local.name)
name = "adot-collector-kubeprometheus"
kube_service_account_name = try(var.helm_config.service_account, local.name)
namespace = try(var.helm_config.namespace, local.name)

eks_oidc_issuer_url = replace(data.aws_eks_cluster.eks_cluster.identity[0].oidc[0].issuer, "https://", "")
eks_cluster_endpoint = data.aws_eks_cluster.eks_cluster.endpoint
Expand Down
12 changes: 10 additions & 2 deletions modules/eks-monitoring/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -188,15 +188,23 @@ module "helm_addon" {
{
name = "enableAdotcollectorMetrics"
value = var.enable_adotcollector_metrics
},
{
name = "serviceAccount"
value = local.kube_service_account_name
},
{
name = "namespace"
value = local.namespace
}

]

irsa_iam_role_name = var.irsa_iam_role_name
irsa_config = {
create_kubernetes_namespace = true
kubernetes_namespace = local.namespace
create_kubernetes_service_account = true
kubernetes_service_account = try(var.helm_config.service_account, local.name)
kubernetes_service_account = local.kube_service_account_name
irsa_iam_policies = flatten([
"arn:${data.aws_partition.current.partition}:iam::aws:policy/AmazonPrometheusRemoteWriteAccess",
"arn:${data.aws_partition.current.partition}:iam::aws:policy/AWSXrayWriteOnlyAccess",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ roleRef:
name: otel-prometheus-role
subjects:
- kind: ServiceAccount
name: adot-collector-kubeprometheus
namespace: adot-collector-kubeprometheus
name: {{ default "adot-collector-kubeprometheus" .Values.serviceAccount }}
namespace: {{ default "adot-collector-kubeprometheus" .Values.namespace }}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ metadata:
name: adot
spec:
mode: deployment
serviceAccount: adot-collector-kubeprometheus
serviceAccount: {{ default "adot-collector-kubeprometheus" .Values.serviceAccount }}
env:
- name: "K8S_NODE_NAME"
valueFrom:
Expand Down
3 changes: 3 additions & 0 deletions modules/eks-monitoring/otel-config/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,6 @@ istioPrometheusMetricsEndpoint: ${istio_prometheus_metrics_endpoint}
adotLoglevel: ${adot_loglevel}

enableAdotcollectorMetrics: ${enable_adotcollector_metrics}

serviceAccount: ${service_account}
namespace: ${namespace}
6 changes: 6 additions & 0 deletions modules/eks-monitoring/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ variable "helm_config" {
default = {}
}

variable "irsa_iam_role_name" {
description = "IAM role name for IRSA roles"
type = string
default = ""
}

variable "irsa_iam_role_path" {
description = "IAM role path for IRSA roles"
type = string
Expand Down
Loading