Skip to content

Commit

Permalink
pull from ent-ecr
Browse files Browse the repository at this point in the history
  • Loading branch information
morga471 committed Apr 14, 2025
1 parent 37fe374 commit 16ca976
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 30 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,15 @@ The module deploys Karpenter needed AWS resources, namely in IAM. It copies the
| [helm_release.nodepool_resources](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release) | resource |
| [aws_arn.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/arn) | data source |
| [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |
| [aws_ecr_authorization_token.ecr_token](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ecr_authorization_token) | data source |
| [aws_ecr_authorization_token.token](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ecr_authorization_token) | data source |
| [aws_ecr_image.karpenter_image](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ecr_image) | data source |

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_account_id"></a> [account\_id](#input\_account\_id) | aws account number | `string` | `""` | no |
| <a name="input_cluster_endpoint"></a> [cluster\_endpoint](#input\_cluster\_endpoint) | Endpoint for your Kubernetes API server | `string` | n/a | yes |
| <a name="input_cluster_name"></a> [cluster\_name](#input\_cluster\_name) | EKS cluster name name component used through out the EKS cluster describing its purpose (ex: dice-dev) | `string` | n/a | yes |
| <a name="input_karpenter_helm_chart"></a> [karpenter\_helm\_chart](#input\_karpenter\_helm\_chart) | Which helm chart of karpenter | `string` | `"1.1.1"` | no |
Expand Down
23 changes: 18 additions & 5 deletions copy_images.tf
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
locals {
karpenter_key = format("%v#%v", "karpenter/controller", var.karpenter_tag)
karpenter_key = format("%v#%v", "karpenter/controller", var.karpenter_tag)
ent_ecr_source = format("%v.%v.%v.%v", var.account_id, "dkr.ecr", var.region, "amazonaws.com/ent-images")

image_config = [
{
enabled = true
dest_path = null
name = "karpenter/controller"
source_image = "karpenter/controller"
source_registry = "public.ecr.aws"
source_registry = format("%v/%v", local.ent_ecr_source, "public-ecr")
source_tag = var.karpenter_tag
tag = var.karpenter_tag
},
]
}

# 224384469011.dkr.ecr.us-gov-east-1.amazonaws.com/platform-test-1/karpenter:0.37.0
# map[repository:224384469011.dkr.ecr.us-gov-east-1.amazonaws.com/platform-test-1/karpenter tag:0.37.0]
module "images" {
source = "git::https://github.e.it.census.gov/terraform-modules/aws-ecr-copy-images.git/?ref=tf-upgrade"

Expand All @@ -27,5 +26,19 @@ module "images" {
enable_lifecycle_policy = true
lifecycle_policy_all = true
force_delete = true
lifecycle_policy_keep_count = 3
lifecycle_policy_keep_count = 5

source_username = data.aws_ecr_authorization_token.ecr_token.user_name
source_password = data.aws_ecr_authorization_token.ecr_token.password

destination_username = data.aws_ecr_authorization_token.token.user_name
destination_password = data.aws_ecr_authorization_token.token.password
}

data "aws_ecr_authorization_token" "ecr_token" {
registry_id = var.account_id
}

data "aws_ecr_authorization_token" "token" {
registry_id = var.account_id
}
56 changes: 31 additions & 25 deletions variables.tf
Original file line number Diff line number Diff line change
@@ -1,32 +1,23 @@
variable "region" {
description = "AWS region"
type = string
}

variable "profile" {
description = "AWS config profile"
variable "account_id" {
description = "aws account number"
type = string
default = ""
}

variable "cluster_name" {
description = "EKS cluster name name component used through out the EKS cluster describing its purpose (ex: dice-dev)"
type = string
}

variable "cluster_endpoint" {
description = "Endpoint for your Kubernetes API server"
type = string
}

variable "oidc_provider_arn" {
description = "The ARN of the OIDC Provider if `enable_irsa = true`"
variable "cluster_name" {
description = "EKS cluster name name component used through out the EKS cluster describing its purpose (ex: dice-dev)"
type = string
}

variable "karpenter_node_group_name" {
description = "The cluster node group that will host karpenter, should not be a karpenter managed node group"
variable "karpenter_helm_chart" {
description = "Which helm chart of karpenter"
type = string
default = "1.1.1"
}

variable "karpenter_helm_repo" {
Expand All @@ -36,10 +27,9 @@ variable "karpenter_helm_repo" {
# default = "https://charts.karpenter.sh/" public.ecr.aws/karpenter/karpenter:0.37.0
}

variable "karpenter_helm_chart" {
description = "Which helm chart of karpenter"
variable "karpenter_node_group_name" {
description = "The cluster node group that will host karpenter, should not be a karpenter managed node group"
type = string
default = "1.1.1"
}

variable "karpenter_tag" {
Expand All @@ -48,6 +38,28 @@ variable "karpenter_tag" {
default = "1.1.1"
}

variable "namespace" {
description = "Namespace for Karpenter"
type = string
default = "namespace"
}

variable "oidc_provider_arn" {
description = "The ARN of the OIDC Provider if `enable_irsa = true`"
type = string
}

variable "profile" {
description = "AWS config profile"
type = string
default = ""
}

variable "region" {
description = "AWS region"
type = string
}

variable "subnets_name" {
description = "Define the name of the subnets to be used by this cluster"
type = string
Expand All @@ -60,12 +72,6 @@ variable "tags" {
default = {}
}

variable "namespace" {
description = "Namespace for Karpenter"
type = string
default = "namespace"
}

variable "vpc_id" {
description = "The ID of the VPC where the resources will be deployed"
type = string
Expand Down

0 comments on commit 16ca976

Please sign in to comment.