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

Add example for IRSA and cluster-autoscaler #710

Merged
merged 7 commits into from
Jan 30, 2020
Merged

Add example for IRSA and cluster-autoscaler #710

merged 7 commits into from
Jan 30, 2020

Conversation

max-rocket-internet
Copy link
Contributor

@max-rocket-internet max-rocket-internet commented Jan 24, 2020

PR o'clock

Description

Many people have requested an example using IRSA (IAM Roles for Service Accounts). So here I am adding an example for the cluster-autoscaler.

Checklist

Copy link
Contributor

@dpiddockcmp dpiddockcmp left a comment

Choose a reason for hiding this comment

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

👏 ❤️
Comments suggesting things to delete to remove distractions 😄

Comment on lines 29 to 31
kubectl -n kube-system create serviceaccount tiller
kubectl create clusterrolebinding tiller --clusterrole cluster-admin --serviceaccount=kube-system:tiller
helm init --service-account=tiller
Copy link
Contributor

Choose a reason for hiding this comment

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

Please please can fresh examples use Helm 3? No more tiller!

Copy link
Member

@barryib barryib Jan 24, 2020

Choose a reason for hiding this comment

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

Maybe we can omit tiller installation. And add note that we must have a working helm installation. Because, it's not relevant here.

I personally use terraform with helm provider to perform cluster-autoscaler installation during my cluster setup. But it doen't matter how we install it. What we need for the serviceaccount is here https://github.com/terraform-aws-modules/terraform-aws-eks/pull/710/files#diff-5d3e96c50e09c013f8553243cb0be4d6R3-R6

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree 100%. I just haven't used Helm 3 yet 😢

I'll redo next week with Helm 3. I need to it this anyway!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe we can omit tiller installation.

OK good input. I'll remove that part. But I'll keep the helm install command for the chart. Is it same for Helm 3?

Copy link
Member

Choose a reason for hiding this comment

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

yep.

examples/irsa/main.tf Outdated Show resolved Hide resolved
@max-rocket-internet
Copy link
Contributor Author

@barryib do you know why the terraform_docs check is failing? I don't get it...

@barryib
Copy link
Member

barryib commented Jan 24, 2020

@barryib do you know why the terraform_docs check is failing? I don't get it...

Nope. But even the terraform fmt is failing.

@barryib
Copy link
Member

barryib commented Jan 24, 2020

@max-rocket-internet terraform-doc 0.8.0 is now in stable. We should probably update terraform pre-commit antonbabenko/pre-commit-terraform#85.

pre-commit autoupdate would probably help.

@max-rocket-internet
Copy link
Contributor Author

We should probably update terraform pre-commit antonbabenko/pre-commit-terraform#85.

OK cool. Next week I'll have a look.

I think we should also remove the autoscaling_enabled = true option from workers and remove the autoscaling policies from the module. In a a separate PR. People can do this outside the module now and IRSA is one way to do it.

cluster_name = local.cluster_name
subnets = module.vpc.private_subnets
vpc_id = module.vpc.vpc_id
enable_irsa = true
Copy link

Choose a reason for hiding this comment

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

If I'm not mistaken, using IRSA on cluster-autoscaler, it would be good to add these flags to the cluster variables:

# module no longer needs to manage autoscaling policy since this is moved to the service-account IAM role
manage_worker_autoscaling_policy = false
attach_worker_autoscaling_policy = false

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are not mistake but I think we just remove the autoscaling policy stuff completely and let users manage that themselves.

Copy link

Choose a reason for hiding this comment

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

May I suggest: Leave the policy stuff in but change default enabled to false in next release (and ofc. mention in release notes). Then remove in subsequent release.

This would allow users to somewhat seamlessly transition to IRSA, without needing to temporary bolt on additional policies.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@TBeijen actually we already have var.attach_worker_autoscaling_policy/var.manage_worker_autoscaling_policy. I'll just make a PR to set these to default of false.

@@ -1,6 +1,6 @@
repos:
- repo: git://github.com/antonbabenko/pre-commit-terraform
rev: v1.22.0
rev: v1.24.0
Copy link
Member

Choose a reason for hiding this comment

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

@max-rocket-internet please change args into args: ["--args=--with-aggregate-type-defaults", "--args=--no-escape"]

@barryib barryib changed the title Add example for IRSA and cluster-autoscaler WIP: Add example for IRSA and cluster-autoscaler Jan 27, 2020
@max-rocket-internet max-rocket-internet changed the title WIP: Add example for IRSA and cluster-autoscaler Add example for IRSA and cluster-autoscaler Jan 28, 2020
@max-rocket-internet
Copy link
Contributor Author

OK I have:

  • Switched to use the public module terraform-aws-modules/iam/aws//modules/iam-assumable-role-with-oidc for the IAM part, it's a little bit simpler and also pushes the focus away from this module a bit 😃
  • Removed helm init stuff
  • Removed autoscaling_enabled = true and just added the required tag directly to the node group. This way it's clear how it works and the example won't change when we remove the policy.
  • Simplified the example further by removing NAT gateways and private subnets

Please re-review @barryib @dpiddockcmp @TBeijen 🚀

@barryib
Copy link
Member

barryib commented Jan 28, 2020

Can you please update your branch and upgrade to terraform-docs 0.8.1 ?

Copy link
Contributor

@dpiddockcmp dpiddockcmp left a comment

Choose a reason for hiding this comment

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

This looks good to me


data "aws_caller_identity" "current" {}

resource "random_string" "suffix" {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this resource used anywhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks. I've removed it.

@max-rocket-internet
Copy link
Contributor Author

@barryib done rebase. Thanks for fixing the pre-commit stuff

Copy link

@TBeijen TBeijen left a comment

Choose a reason for hiding this comment

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

Looks fine. As mentioned in the other PR: Makes sense also to not have 2 releases with breaking changes, so unlike what I suggested, ditching all references to manage autoscaling looks good.

@max-rocket-internet max-rocket-internet merged commit 9032dce into terraform-aws-modules:master Jan 30, 2020
@max-rocket-internet max-rocket-internet deleted the irsa_example branch January 30, 2020 14:21
@ankushagarwal
Copy link

@max-rocket-internet : Curious as to what is the reason to use worker_groups instead of node_groups in module "eks". I am not sure what the difference between them is. The managed_node_groups/main.tf example uses node_groups in module "eks"

@morganchristiansson
Copy link
Contributor

morganchristiansson commented Jan 31, 2020

worker_groups is the classic unmanaged way of doing things and allows you to use spot instances and provide kubelet args.

I believe either will work with irsa.

@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants