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

[EKS Prow Cluster] Add karpenter terraform module for eks-prow-build cluster #6895

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

koksay
Copy link
Contributor

@koksay koksay commented Jun 14, 2024

  • Add karpenter module, which creates related roles, sqs queue and events
  • Update EKSAdmin role to be able to create above resources
  • Add manually added SSO role to terraform

Make sure to update the serviceAccount.annotations field in the infra/aws/terraform/prow-build-cluster/resources/karpenter/flux-hr-karpenter.yaml file (also in infra/aws/terraform/prow-build-cluster/resources/karpenter/prod-cluster-values):

# You may use this command to get the arn after terraform apply:
terraform state show module.karpenter.aws_iam_role.controller\[0\] | grep " arn "

There will be a follow-up PR to add nodepool and nodeclass configration.

@k8s-ci-robot k8s-ci-robot added area/infra Infrastructure management, infrastructure design, code in infra/ cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. area/infra/aws Issues or PRs related to Kubernetes AWS infrastructure sig/k8s-infra Categorizes an issue or PR as relevant to SIG K8s Infra. labels Jun 14, 2024
@koksay
Copy link
Contributor Author

koksay commented Jun 14, 2024

/assign @xmudrii

@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jun 14, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: koksay
Once this PR has been reviewed and has the lgtm label, please ask for approval from xmudrii. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@@ -81,6 +82,27 @@ locals {
}
]

karpenter_roles = [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we use cluster access entry instead of adding to the aws-auth configmap?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good question. I tried this code on the Canary cluster first and could not run Karpenter with the access entry. I may have missed something, so I turned it off and continued with the aws-auth file.

cluster_name = module.eks.cluster_name
create_access_entry = false

enable_irsa = true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not use EKS Pod Identity here?

rolearn = "arn:aws:iam::468814281478:role/AWSReservedSSO_AdministratorAccess_abaef4db15a2c055"
username = "sso-admins"
groups = [
"eks-cluster-admin"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure what permissions this group maps to, but similar to above - would cluster access entry work here instead?

interruptionQueue: Karpenter-prow-canary-cluster
serviceAccount:
annotations:
eks.amazonaws.com/role-arn: "arn:aws:iam::054318140392:role/KarpenterController-20240527081538529900000002"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EKS Pod Identity would remove this hardcoded role arn mapping in code

serviceAccount:
annotations:
# terraform state show module.karpenter.aws_iam_role.controller\[0\] | grep " arn "
eks.amazonaws.com/role-arn: arn:aws:iam::468814281478:role/KarpenterController-20240527081538529900000002
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comment - EKS Pod Identity removes this hardcoding

@@ -90,6 +101,12 @@ data "aws_iam_policy_document" "eks_apply" {
"logs:PutRetentionPolicy",
"logs:TagLogGroup",
"s3:PutObject",
"sqs:createqueue",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these permissions required by prow, or by Karpenter? Likewise fir the Eventbridge API permissions

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are required by the karpenter module, it creates a SQS queue for the event messaging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/infra/aws Issues or PRs related to Kubernetes AWS infrastructure area/infra Infrastructure management, infrastructure design, code in infra/ cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. sig/k8s-infra Categorizes an issue or PR as relevant to SIG K8s Infra. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants