From 792c0bd100b794cffb8bee32f1654cb123d6fd86 Mon Sep 17 00:00:00 2001
From: David McWhorter <105815369+dmcwhorter-ddl@users.noreply.github.com>
Date: Wed, 28 Aug 2024 16:42:57 -0400
Subject: [PATCH] External Deployments Operator IAM Role (#258)
---
.gitignore | 3 ++-
.pre-commit-config.yaml | 1 +
examples/deploy/meta.sh | 3 ++-
examples/deploy/terraform/cluster/README.md | 3 +++
examples/deploy/terraform/cluster/main.tf | 12 +++++++++
examples/deploy/terraform/cluster/outputs.tf | 11 ++++++++
.../deploy/terraform/cluster/variables.tf | 12 +++++++++
examples/tfvars/external-deployments.tfvars | 25 +++++++++++++++++++
modules/irsa/README.md | 3 +++
modules/irsa/external-deployments-operator.tf | 23 +++++++++++++++++
modules/irsa/outputs.tf | 8 ++++++
modules/irsa/variables.tf | 11 ++++++++
tests/deploy/cluster-ci.tfvars.tftpl | 6 +++++
tests/deploy/meta.sh | 3 ++-
tests/plan/terraform/README.md | 2 ++
tests/plan/terraform/main.tf | 7 ++++++
tests/plan/terraform/variables.tf | 12 +++++++++
17 files changed, 142 insertions(+), 3 deletions(-)
create mode 100644 examples/tfvars/external-deployments.tfvars
create mode 100644 modules/irsa/external-deployments-operator.tf
diff --git a/.gitignore b/.gitignore
index eef08482..7fcbb6f0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -53,4 +53,5 @@ k8s-proxy-tunnel.sh
# local files
.DS_Store
-*/.idea/*
+.idea/*
+*.iml
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 36cf374b..0299f05e 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -67,6 +67,7 @@ repos:
- "--args=--severity=HIGH,CRITICAL"
- "--args=--ignorefile=__GIT_WORKING_DIR__/.trivyignore"
- "--args=--exit-code=1"
+ - "--hook-config=--parallelism-limit=1"
- repo: local
hooks:
- id: check_aws_partition
diff --git a/examples/deploy/meta.sh b/examples/deploy/meta.sh
index 759e08e0..a69d87f5 100644
--- a/examples/deploy/meta.sh
+++ b/examples/deploy/meta.sh
@@ -11,12 +11,13 @@ declare -a MOD_DIRS=(
declare -A COMP_MODS
COMP_MODS["infra"]="infra"
-COMP_MODS["cluster"]="eks irsa_external_dns irsa_policies"
+COMP_MODS["cluster"]="eks irsa_external_dns irsa_policies irsa_external_deployments_operator"
COMP_MODS["nodes"]="nodes"
declare -A MOD_ADD
MOD_ADD["irsa_external_dns"]="irsa"
MOD_ADD["irsa_policies"]="irsa"
+MOD_ADD["irsa_external_deployments_operator"]="irsa"
INFRA_DIR="${MOD_DIRS[0]}"
CLUSTER_DIR="${MOD_DIRS[1]}"
diff --git a/examples/deploy/terraform/cluster/README.md b/examples/deploy/terraform/cluster/README.md
index b200df3c..f69575e8 100644
--- a/examples/deploy/terraform/cluster/README.md
+++ b/examples/deploy/terraform/cluster/README.md
@@ -21,6 +21,7 @@
| Name | Source | Version |
|------|--------|---------|
| [eks](#module\_eks) | ./../../../../modules/eks | n/a |
+| [irsa\_external\_deployments\_operator](#module\_irsa\_external\_deployments\_operator) | ./../../../../modules/irsa | n/a |
| [irsa\_external\_dns](#module\_irsa\_external\_dns) | ./../../../../modules/irsa | n/a |
| [irsa\_policies](#module\_irsa\_policies) | ./../../../../modules/irsa | n/a |
@@ -37,6 +38,7 @@
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| [eks](#input\_eks) | service\_ipv4\_cidr = CIDR for EKS cluster kubernetes\_network\_config.
creation\_role\_name = Name of the role to import.
k8s\_version = EKS cluster k8s version.
kubeconfig = {
extra\_args = Optional extra args when generating kubeconfig.
path = Fully qualified path name to write the kubeconfig file.
}
public\_access = {
enabled = Enable EKS API public endpoint.
cidrs = List of CIDR ranges permitted for accessing the EKS public endpoint.
}
Custom role maps for aws auth configmap
custom\_role\_maps = {
rolearn = string
username = string
groups = list(string)
}
master\_role\_names = IAM role names to be added as masters in eks.
cluster\_addons = EKS cluster addons. vpc-cni is installed separately.
vpc\_cni = Configuration for AWS VPC CNI
ssm\_log\_group\_name = CloudWatch log group to send the SSM session logs to.
identity\_providers = Configuration for IDP(Identity Provider).
} |
object({| `{}` | no | +| [irsa\_external\_deployments\_operator](#input\_irsa\_external\_deployments\_operator) | Config to create IRSA role for the external deployments operator. |
service_ipv4_cidr = optional(string)
creation_role_name = optional(string, null)
k8s_version = optional(string)
kubeconfig = optional(object({
extra_args = optional(string)
path = optional(string)
}), {})
public_access = optional(object({
enabled = optional(bool)
cidrs = optional(list(string))
}), {})
custom_role_maps = optional(list(object({
rolearn = string
username = string
groups = list(string)
})))
master_role_names = optional(list(string))
cluster_addons = optional(list(string))
ssm_log_group_name = optional(string)
vpc_cni = optional(object({
prefix_delegation = optional(bool)
annotate_pod_ip = optional(bool)
}))
identity_providers = optional(list(object({
client_id = string
groups_claim = optional(string)
groups_prefix = optional(string)
identity_provider_config_name = string
issuer_url = optional(string)
required_claims = optional(string)
username_claim = optional(string)
username_prefix = optional(string)
})))
})
object({| `{}` | no | | [irsa\_external\_dns](#input\_irsa\_external\_dns) | Mappings for custom IRSA configurations. |
enabled = optional(bool, false)
namespace = optional(string, "domino-compute")
service_account_name = optional(string, "pham-juno-operator")
})
object({| `{}` | no | | [irsa\_policies](#input\_irsa\_policies) | Mappings for custom IRSA configurations. |
enabled = optional(bool, false)
hosted_zone_name = optional(string, null)
namespace = optional(string, null)
serviceaccount_name = optional(string, null)
rm_role_policy = optional(object({
remove = optional(bool, false)
detach_from_role = optional(bool, false)
policy_name = optional(string, "")
}), {})
})
list(object({| `[]` | no | | [kms\_info](#input\_kms\_info) | Overrides the KMS key information. Meant for migrated configurations.
name = string
namespace = string
serviceaccount_name = string
policy = string #json
}))
object({| `null` | no | @@ -47,6 +49,7 @@ | Name | Description | |------|-------------| | [eks](#output\_eks) | EKS details. | +| [external\_deployments\_operator](#output\_external\_deployments\_operator) | "External\_deployments\_operator info"
key_id = string
key_arn = string
enabled = bool
})
list(object({| `[]` | no | | [eks\_info](#input\_eks\_info) | cluster = {
name = string
namespace = string
serviceaccount_name = string
policy = string #json
}))
object({| n/a | yes | +| [external\_deployments\_operator](#input\_external\_deployments\_operator) | Config to create IRSA role for the external deployments operator. |
nodes = object({
roles = list(object({
arn = string
name = string
}))
})
cluster = object({
specs = object({
name = string
account_id = string
})
oidc = object({
arn = string
url = string
cert = object({
thumbprint_list = list(string)
url = string
})
})
})
})
object({| `{}` | no | | [external\_dns](#input\_external\_dns) | Config to enable irsa for external-dns |
enabled = optional(bool, false)
namespace = optional(string, "domino-compute")
service_account_name = optional(string, "pham-juno-operator")
})
object({| `{}` | no | | [netapp\_trident\_operator](#input\_netapp\_trident\_operator) | Config to create IRSA role for the netapp-trident-operator. |
enabled = optional(bool, false)
hosted_zone_name = optional(string, null)
hosted_zone_private = optional(string, false)
namespace = optional(string, "domino-platform")
serviceaccount_name = optional(string, "external-dns")
rm_role_policy = optional(object({
remove = optional(bool, false)
detach_from_role = optional(bool, false)
policy_name = optional(string, "")
}), {})
})
object({| `{}` | no | | [use\_cluster\_odc\_idp](#input\_use\_cluster\_odc\_idp) | Toogle to uset the oidc idp connector in the trust policy.
enabled = optional(bool, false)
namespace = optional(string, "trident")
serviceaccount_name = optional(string, "trident-controller")
region = optional(string)
})
object({| `{}` | no | | [enable\_private\_link](#input\_enable\_private\_link) | Enable Private Link connections | `bool` | `false` | no | | [ignore\_tags](#input\_ignore\_tags) | Tag keys to be ignored by the aws provider. | `list(string)` | `[]` | no | +| [irsa\_external\_deployments\_operator](#input\_irsa\_external\_deployments\_operator) | Config to create IRSA role for the external deployments operator. |
k8s_version = optional(string, "1.27")
nodes_master = optional(bool, false)
kubeconfig = optional(object({
extra_args = optional(string, "")
path = optional(string, null)
}), {})
public_access = optional(object({
enabled = optional(bool, false)
cidrs = optional(list(string), [])
}), {})
custom_role_maps = optional(list(object({
rolearn = string
username = string
groups = list(string)
})), [])
master_role_names = optional(list(string), [])
cluster_addons = optional(list(string), ["kube-proxy", "coredns"])
ssm_log_group_name = optional(string, "session-manager")
vpc_cni = optional(object({
prefix_delegation = optional(bool)
annotate_pod_ip = optional(bool)
}))
identity_providers = optional(list(object({
client_id = string
groups_claim = optional(string, null)
groups_prefix = optional(string, null)
identity_provider_config_name = string
issuer_url = optional(string, null)
required_claims = optional(string, null)
username_claim = optional(string, null)
username_prefix = optional(string, null)
})), [])
})
object({| `{}` | no | | [kms](#input\_kms) | enabled = Toggle,if set use either the specified KMS key\_id or a Domino-generated one.
enabled = optional(bool, false)
namespace = optional(string, "domino-compute")
service_account_name = optional(string, "pham-juno-operator")
})
object({| `{}` | no | | [network](#input\_network) | vpc = {
enabled = optional(bool, true)
key_id = optional(string, null)
additional_policies = optional(list(string), [])
})
object({| `{}` | no | | [region](#input\_region) | AWS region for the deployment | `string` | n/a | yes | diff --git a/tests/plan/terraform/main.tf b/tests/plan/terraform/main.tf index 2b38be98..c2f285d3 100644 --- a/tests/plan/terraform/main.tf +++ b/tests/plan/terraform/main.tf @@ -69,6 +69,13 @@ module "irsa_policies" { use_fips_endpoint = var.use_fips_endpoint } +module "irsa_external_deployments_operator" { + source = "./../../../modules/irsa" + eks_info = module.eks.info + external_deployments_operator = var.irsa_external_deployments_operator + use_fips_endpoint = var.use_fips_endpoint +} + module "nodes" { source = "./../../../modules/nodes" region = module.infra.region diff --git a/tests/plan/terraform/variables.tf b/tests/plan/terraform/variables.tf index 45377957..0d94118d 100644 --- a/tests/plan/terraform/variables.tf +++ b/tests/plan/terraform/variables.tf @@ -449,3 +449,15 @@ variable "use_fips_endpoint" { type = bool default = false } + +variable "irsa_external_deployments_operator" { + description = "Config to create IRSA role for the external deployments operator." + + type = object({ + enabled = optional(bool, false) + namespace = optional(string, "domino-compute") + service_account_name = optional(string, "pham-juno-operator") + }) + + default = {} +}
vpc = optional(object({
id = optional(string, null)
subnets = optional(object({
private = optional(list(string), [])
public = optional(list(string), [])
pod = optional(list(string), [])
}), {})
}), {})
network_bits = optional(object({
public = optional(number, 27)
private = optional(number, 19)
pod = optional(number, 19)
}
), {})
cidrs = optional(object({
vpc = optional(string, "10.0.0.0/16")
pod = optional(string, "100.64.0.0/16")
}), {})
use_pod_cidr = optional(bool, true)
})