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

feat: Add support for addons #1443

Closed
wants to merge 14 commits into from

Conversation

tnimni
Copy link

@tnimni tnimni commented Jun 15, 2021

PR o'clock

Description

Add support for eks addons recommended by aws

  1. VPC CNI
  2. CoreDns
  3. kube-proxy

https://docs.aws.amazon.com/eks/latest/userguide/eks-add-ons.html

The default behavior will NOT install the addons to the cluster.

Requires irsa to be enabled to deploy the VPC CNI addon

Checklist

Copy link
Contributor

@daroga0002 daroga0002 left a comment

Choose a reason for hiding this comment

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

can we add some example into examples directory which will be using this?

# Hack for a homemade `depends_on` https://discuss.hashicorp.com/t/tips-howto-implement-module-depends-on-emulation/2305/2
# Will be removed in Terraform 0.13 with the support of module's `depends_on` https://github.com/hashicorp/terraform/issues/10462
variable "eks_depends_on" {
description = "List of references to other resources this submodule depends on."
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe this should me moved to module level as terraform from some time allowing it?

Copy link
Author

Choose a reason for hiding this comment

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

This pattern is used in modules/fargate and modules/node_groups, I just copied it from there to keep everything consistent.
I'm not sure which example you require, as eks_depends_on is defined in addons.tf in the root of the main module, https://github.com/tnimni/terraform-aws-eks/blob/feature/addons/addons.tf#L11-L14


variable "coredns_versions" {
# Versions are taken from https://docs.aws.amazon.com/eks/latest/userguide/managing-coredns.html#updating-coredns-add-on
type = map(any)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think better will be map(string) just to not loose type over time

Copy link
Author

Choose a reason for hiding this comment

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

Changed to map(string)


variable "kube_proxy_versions" {
# Versions are taken from https://docs.aws.amazon.com/eks/latest/userguide/managing-kube-proxy.html#updating-kube-proxy-add-on
type = map(any)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think better will be map(string) just to not loose type over time

Copy link
Author

Choose a reason for hiding this comment

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

Changed to map(string)

variable "vpc_cni_versions" {
# Versions are taken from https://docs.aws.amazon.com/eks/latest/userguide/managing-vpc-cni.html#updating-vpc-cni-add-on
# Latest patch version is taken from https://github.com/aws/amazon-vpc-cni-k8s
type = map(any)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think better will be map(string) just to not loose type over time

Copy link
Author

Choose a reason for hiding this comment

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

Changed to map(string)

# Will be removed in Terraform 0.13 with the support of module's `depends_on` https://github.com/hashicorp/terraform/issues/10462
variable "eks_depends_on" {
description = "List of references to other resources this submodule depends on."
type = any
Copy link
Contributor

Choose a reason for hiding this comment

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

probably string will be better

Copy link
Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

yup, this was created before modules were supporting dependncies. Lets maintainers decide does we want to leave this for consistency or we will start using module dependency.

@@ -0,0 +1,14 @@
output "vpc_cni_id" {
description = "The id of the Amazon VPC CNI addon"
value = aws_eks_addon.vpc_cni[0].id
Copy link
Contributor

Choose a reason for hiding this comment

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

does it will be working when I will not create this addon (there will be no element 0)?

Copy link
Author

@tnimni tnimni Jun 15, 2021

Choose a reason for hiding this comment

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

Fixed the count=0 issue

cluster_name = var.cluster_name
addon_name = "coredns"
resolve_conflicts = "OVERWRITE"
addon_version = lookup(var.coredns_versions, var.cluster_version, "Not Found")
Copy link
Contributor

Choose a reason for hiding this comment

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

how AWS API will react when we pass "Not Found", does there is validation on their end?

Copy link
Author

Choose a reason for hiding this comment

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

This is on purpose, it will not even reach aws api. terraform plan will throw an error stating the addon version can not be "Not Found" giving a hint for the user that the cluster version is not supported by the module

Tsachi Nimni and others added 4 commits June 16, 2021 01:02
Copy link
Contributor

@daroga0002 daroga0002 left a comment

Choose a reason for hiding this comment

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

for me it looks good, @barryib can you take a look on it?

@stevehipwell
Copy link
Contributor

Please can the defaults not be to enable these.

@tnimni
Copy link
Author

tnimni commented Jun 16, 2021

@stevehipwell
changed defaults to false

@tnimni
Copy link
Author

tnimni commented Jun 17, 2021

Can we please get this approved? @barryib

@thecosmicfrog
Copy link

Good work here @tnimni - hoping for it to be merged soon.

@tnimni
Copy link
Author

tnimni commented Jun 22, 2021

Good work here @tnimni - hoping for it to be merged soon.

Thank you

@mmerickel
Copy link

So if we enable the vpc cni addon then should we pass attach_worker_cni_policy=false? Would be good to mention that in the docs if so.

@tnimni
Copy link
Author

tnimni commented Jun 23, 2021

attach_worker_cni_policy=false

Hi,
it is not required to do so,

I checked and aws recommend it here https://docs.aws.amazon.com/eks/latest/userguide/cni-iam-role.html

I added to the example and also updated the main module readme to reflect that the variable attach_worker_cni_policy should be set to false if deploying the vpc cni addon

I appreciate your input

@nikitacr7
Copy link
Contributor

Hi

Awesome. We're waiting for it.

@thapakazi
Copy link

Same Same, nice work @tnimni 👏

@tnimni
Copy link
Author

tnimni commented Jun 30, 2021

@nikitacr7 @thapakazi thank you both

@csschwe
Copy link

csschwe commented Jul 9, 2021

@tnimni This is great!!!

I do have one request though. Can you add support for tags like the node_groups module

https://github.com/terraform-aws-modules/terraform-aws-eks/blob/master/node_groups.tf#L9

Thanks

@tnimni
Copy link
Author

tnimni commented Jul 15, 2021

@tnimni This is great!!!

I do have one request though. Can you add support for tags like the node_groups module

https://github.com/terraform-aws-modules/terraform-aws-eks/blob/master/node_groups.tf#L9

Thanks

I'll have a look into it

Edit: I have added tags to addons
they do not reflect in was UI, but they are added

use addon_tags = {
Environment = "dev"
}

@wellermann
Copy link

wellermann commented Jul 22, 2021

EKS 1.21 just came out this week so it might be worth adding it now.

Either way this is great work @tnimni Thank you for doing this.

@stevehipwell
Copy link
Contributor

Thanks @antonbabenko your design deals with my concerns and will allow anyone who wants to use addons to do so without impacting any of us who choose not to.

@stale
Copy link

stale bot commented Oct 3, 2021

This PR has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
To track this PR (even if closed), please open a corresponding issue if one does not already exist.

@stale stale bot added the stale label Oct 3, 2021
@daroga0002 daroga0002 removed the stale label Oct 4, 2021
@fubar
Copy link

fubar commented Oct 21, 2021

We'd love to have support for this, is this PR still being worked on?

@tnimni
Copy link
Author

tnimni commented Oct 21, 2021

We'd love to have support for this, is this PR still being worked on?

I'm waiting for the provider to be updated

I'm considering releasing this as a stand alone module, perhaps n 2 weeks time

@github-actions
Copy link

This PR has been automatically marked as stale because it has been open 30 days
with no activity. Remove stale label or comment or this PR will be closed in 10 days

@bryantbiggs
Copy link
Member

not stale

@beingamarnath
Copy link

Any updates on this? Now that EKS version 1.21 is out there, can we introduce this to the module directly

@github-actions
Copy link

This PR has been automatically marked as stale because it has been open 30 days
with no activity. Remove stale label or comment or this PR will be closed in 10 days

@github-actions github-actions bot added the stale label Dec 30, 2021
@Lillecarl
Copy link

Not stale

@antonbabenko
Copy link
Member

This issue has been resolved in version 18.0.0 🎉

@mmerickel
Copy link

I think this was closed in error... I do not see any of the changes from this PR in master or the 18.0.3 release.

@bryantbiggs
Copy link
Member

@mmerickel

resource "aws_eks_addon" "this" {

@mmerickel
Copy link

Huh ok so it was refactored and done differently from this PR (addons.tf is not there, or any of the examples, etc). It's also not in the changelog. But thanks yes it looks like something like this PR is in master now. Thanks!

@bryantbiggs
Copy link
Member

yes, see convo above #1443 (comment)

there are examples of using this features as well

@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 11, 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.