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

adding openid connect provider to enable irsa feature #1903

Merged
merged 5 commits into from
Aug 30, 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: 0 additions & 1 deletion src/_nebari/stages/infrastructure/template/aws/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ module "kubernetes" {
name = local.cluster_name
tags = local.additional_tags
region = var.region
partition = local.partition
kubernetes_version = var.kubernetes_version

cluster_subnets = local.subnet_ids
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
locals {
cluster_policies = concat([
"arn:${var.partition}:iam::aws:policy/AmazonEKSClusterPolicy",
"arn:${var.partition}:iam::aws:policy/AmazonEKSServicePolicy",
"arn:${var.partition}:iam::aws:policy/service-role/AmazonEBSCSIDriverPolicy",
"arn:${local.partition}:iam::aws:policy/AmazonEKSClusterPolicy",
"arn:${local.partition}:iam::aws:policy/AmazonEKSServicePolicy",
"arn:${local.partition}:iam::aws:policy/service-role/AmazonEBSCSIDriverPolicy",
], var.cluster_additional_policies)

node_group_policies = concat([
"arn:${var.partition}:iam::aws:policy/AmazonEKSWorkerNodePolicy",
"arn:${var.partition}:iam::aws:policy/AmazonEKS_CNI_Policy",
"arn:${var.partition}:iam::aws:policy/service-role/AmazonEBSCSIDriverPolicy",
"arn:${local.partition}:iam::aws:policy/AmazonEKSWorkerNodePolicy",
"arn:${local.partition}:iam::aws:policy/AmazonEKS_CNI_Policy",
"arn:${local.partition}:iam::aws:policy/service-role/AmazonEBSCSIDriverPolicy",
aws_iam_policy.worker_autoscaling.arn
], var.node_group_additional_policies)

gpu_node_group_names = [for node_group in var.node_groups : node_group.name if node_group.gpu == true]

partition = data.aws_partition.current.partition
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
data "aws_partition" "current" {}

resource "aws_eks_cluster" "main" {
name = var.name
role_arn = aws_iam_role.cluster.arn
Expand Down Expand Up @@ -70,3 +72,18 @@ resource "aws_eks_addon" "aws-ebs-csi-driver" {
aws_eks_node_group.main,
]
}

data "tls_certificate" "this" {
url = aws_eks_cluster.main.identity[0].oidc[0].issuer
}

resource "aws_iam_openid_connect_provider" "oidc_provider" {
client_id_list = ["sts.${data.aws_partition.current.dns_suffix}"]
thumbprint_list = data.tls_certificate.this.certificates[*].sha1_fingerprint
url = aws_eks_cluster.main.identity[0].oidc[0].issuer

tags = merge(
{ Name = "${var.name}-eks-irsa" },
var.tags
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@ output "node_groups_arn" {
value = aws_eks_node_group.main[*].arn
}

output "cluster_oidc_issuer_url" {
description = "The URL on the EKS cluster for the OpenID Connect identity provider"
value = aws_eks_cluster.main.identity[0].oidc[0].issuer
}

output "oidc_provider_arn" {
description = "The ARN of the OIDC Provider"
value = aws_iam_openid_connect_provider.oidc_provider.arn
}

# https://github.com/terraform-aws-modules/terraform-aws-eks/blob/16f46db94b7158fd762d9133119206aaa7cf6d63/examples/self_managed_node_group/main.tf
output "kubeconfig" {
description = "Kubernetes connection configuration kubeconfig"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@ variable "region" {
type = string
}

variable "partition" {
description = "AWS partition for EKS cluster"
type = string
}

variable "kubernetes_version" {
description = "AWS kubernetes version for EKS cluster"
type = string
Expand Down
10 changes: 10 additions & 0 deletions src/_nebari/stages/infrastructure/template/aws/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,13 @@ output "nfs_endpoint" {
description = "Endpoint for nfs server"
value = module.efs.credentials.dns_name
}

output "cluster_oidc_issuer_url" {
description = "The URL on the EKS cluster for the OpenID Connect identity provider"
value = module.kubernetes.cluster_oidc_issuer_url
}

output "oidc_provider_arn" {
description = "The ARN of the OIDC Provider"
value = module.kubernetes.oidc_provider_arn
}