From ad9f127d9287f41cd44aa8ecbcb4e79289d148c5 Mon Sep 17 00:00:00 2001 From: Daniel Hartig Date: Tue, 15 Oct 2024 10:54:16 -0500 Subject: [PATCH 1/5] Proposed document changes --- docs/deploy/installation.md | 149 +++++++++++++++++++++++++++++++----- 1 file changed, 131 insertions(+), 18 deletions(-) diff --git a/docs/deploy/installation.md b/docs/deploy/installation.md index dda9fd4a8..f037804cd 100644 --- a/docs/deploy/installation.md +++ b/docs/deploy/installation.md @@ -43,9 +43,134 @@ Instead of depending on IMDSv2, you can specify the AWS Region via the controlle The controller runs on the worker nodes, so it needs access to the AWS ALB/NLB APIs with IAM permissions. -The IAM permissions can either be setup using [IAM roles for service accounts (IRSA)](https://docs.aws.amazon.com/eks/latest/userguide/iam-roles-for-service-accounts.html) or can be attached directly to the worker node IAM roles. The best practice is using IRSA if you're using Amazon EKS. If you're using kOps or self-hosted Kubernetes, you must manually attach polices to node instances. +The IAM permissions can be setup using any of: -### Option A: Recommended, IAM roles for service accounts (IRSA) +- [Pod Identity](https://docs.aws.amazon.com/eks/latest/userguide/pod-identities.html) associations +- [IAM roles for service accounts (IRSA)](https://docs.aws.amazon.com/eks/latest/userguide/iam-roles-for-service-accounts.html) +- Attached IAM permissions directly to the worker node IAM roles. + +The best practice is using Pod Identity associations if you're using Amazon EKS. If you're using kOps or self-hosted Kubernetes, you must manually attach polices to node instances. + +### Required IAM policy + +The IAM policy that must be attached to a service account may differ based on the region. Download an IAM policy for AWS Load Balancer Controller for your region using one of the following commands:

+ If your cluster is in a US Gov Cloud region: + ``` + curl -o iam-policy.json https://raw.githubusercontent.com/kubernetes-sigs/aws-load-balancer-controller/v2.9.0/docs/install/iam_policy_us-gov.json + ``` + If your cluster is in a China region: + ``` + curl -o iam-policy.json https://raw.githubusercontent.com/kubernetes-sigs/aws-load-balancer-controller/v2.9.0/docs/install/iam_policy_cn.json + ``` + If your cluster is in any other region: + ``` + curl -o iam-policy.json https://raw.githubusercontent.com/kubernetes-sigs/aws-load-balancer-controller/v2.9.0/docs/install/iam_policy.json + ``` + +### Option A: Recommended, EKS Pod Identity + +Instructions are shown from the aws and eksctl CLIs, as well as with terraform. Terraform must be set up with the terrafrom aws provider (version `~>5.0`). Appropriate permissions for the CLI or terraform provider must be provisioned. + +1. Download an IAM policy as [defined above](#required-iam-policy). + +1. Create an IAM policy from the downloaded policy JSON document. If you downloaded a different policy, replace `iam-policy` with the name of the policy that you downloaded. + ```bash + aws iam create-policy \ + --policy-name AWSLoadBalancerControllerIAMPolicy \ + --policy-document file://iam-policy.json + ``` + The equivalent operation in Terrform is: + ```hcl + resource "aws_iam_policy" "albc_service_account" { + name = "albc-service-account" + policy = file("path/to/iam-policy.json") + } + ``` +1. Create an IAM role for the service account to assume, and set an assume policy for it. + ```bash + cat > assume-albc-service-account-role-policy.json < - If your cluster is in a US Gov Cloud region: - ``` - curl -o iam-policy.json https://raw.githubusercontent.com/kubernetes-sigs/aws-load-balancer-controller/v2.9.0/docs/install/iam_policy_us-gov.json - ``` - If your cluster is in a China region: - ``` - curl -o iam-policy.json https://raw.githubusercontent.com/kubernetes-sigs/aws-load-balancer-controller/v2.9.0/docs/install/iam_policy_cn.json - ``` - If your cluster is in any other region: - ``` - curl -o iam-policy.json https://raw.githubusercontent.com/kubernetes-sigs/aws-load-balancer-controller/v2.9.0/docs/install/iam_policy.json - ``` +1. Download an IAM policy as [defined above](#required-iam-policy). -3. Create an IAM policy named `AWSLoadBalancerControllerIAMPolicy`. If you downloaded a different policy, replace `iam-policy` with the name of the policy that you downloaded. +1. Create an IAM policy named `AWSLoadBalancerControllerIAMPolicy`. If you downloaded a different policy, replace `iam-policy` with the name of the policy that you downloaded. ``` aws iam create-policy \ --policy-name AWSLoadBalancerControllerIAMPolicy \ @@ -109,7 +222,7 @@ Example condition for cluster name resource tag: ``` Take note of the policy ARN that's returned. -4. Create an IAM role and Kubernetes `ServiceAccount` for the LBC. Use the ARN from the previous step. +1. Create an IAM role and Kubernetes `ServiceAccount` for the LBC. Use the ARN from the previous step. ``` eksctl create iamserviceaccount \ --cluster= \ @@ -121,7 +234,7 @@ Example condition for cluster name resource tag: --approve ``` -### Option B: Attach IAM policies to nodes +### Option C: Attach IAM policies to nodes If you're not setting up IAM roles for service accounts, apply the IAM policies from the following URL at a minimum. Please be aware of the possibility that the controller permissions may be assumed by other users in a pod after retrieving the node role credentials, so the best practice would be using IRSA instead of attaching IAM policy directly. ``` curl -o iam-policy.json https://raw.githubusercontent.com/kubernetes-sigs/aws-load-balancer-controller/v2.9.0/docs/install/iam_policy.json From 5338e1be2d76e1a0c30519b2e41c6beb4b8c755d Mon Sep 17 00:00:00 2001 From: Daniel Hartig Date: Tue, 15 Oct 2024 10:54:16 -0500 Subject: [PATCH 2/5] Proposed document changes --- docs/deploy/installation.md | 149 +++++++++++++++++++++++++++++++----- 1 file changed, 131 insertions(+), 18 deletions(-) diff --git a/docs/deploy/installation.md b/docs/deploy/installation.md index dda9fd4a8..f037804cd 100644 --- a/docs/deploy/installation.md +++ b/docs/deploy/installation.md @@ -43,9 +43,134 @@ Instead of depending on IMDSv2, you can specify the AWS Region via the controlle The controller runs on the worker nodes, so it needs access to the AWS ALB/NLB APIs with IAM permissions. -The IAM permissions can either be setup using [IAM roles for service accounts (IRSA)](https://docs.aws.amazon.com/eks/latest/userguide/iam-roles-for-service-accounts.html) or can be attached directly to the worker node IAM roles. The best practice is using IRSA if you're using Amazon EKS. If you're using kOps or self-hosted Kubernetes, you must manually attach polices to node instances. +The IAM permissions can be setup using any of: -### Option A: Recommended, IAM roles for service accounts (IRSA) +- [Pod Identity](https://docs.aws.amazon.com/eks/latest/userguide/pod-identities.html) associations +- [IAM roles for service accounts (IRSA)](https://docs.aws.amazon.com/eks/latest/userguide/iam-roles-for-service-accounts.html) +- Attached IAM permissions directly to the worker node IAM roles. + +The best practice is using Pod Identity associations if you're using Amazon EKS. If you're using kOps or self-hosted Kubernetes, you must manually attach polices to node instances. + +### Required IAM policy + +The IAM policy that must be attached to a service account may differ based on the region. Download an IAM policy for AWS Load Balancer Controller for your region using one of the following commands:

+ If your cluster is in a US Gov Cloud region: + ``` + curl -o iam-policy.json https://raw.githubusercontent.com/kubernetes-sigs/aws-load-balancer-controller/v2.9.0/docs/install/iam_policy_us-gov.json + ``` + If your cluster is in a China region: + ``` + curl -o iam-policy.json https://raw.githubusercontent.com/kubernetes-sigs/aws-load-balancer-controller/v2.9.0/docs/install/iam_policy_cn.json + ``` + If your cluster is in any other region: + ``` + curl -o iam-policy.json https://raw.githubusercontent.com/kubernetes-sigs/aws-load-balancer-controller/v2.9.0/docs/install/iam_policy.json + ``` + +### Option A: Recommended, EKS Pod Identity + +Instructions are shown from the aws and eksctl CLIs, as well as with terraform. Terraform must be set up with the terrafrom aws provider (version `~>5.0`). Appropriate permissions for the CLI or terraform provider must be provisioned. + +1. Download an IAM policy as [defined above](#required-iam-policy). + +1. Create an IAM policy from the downloaded policy JSON document. If you downloaded a different policy, replace `iam-policy` with the name of the policy that you downloaded. + ```bash + aws iam create-policy \ + --policy-name AWSLoadBalancerControllerIAMPolicy \ + --policy-document file://iam-policy.json + ``` + The equivalent operation in Terrform is: + ```hcl + resource "aws_iam_policy" "albc_service_account" { + name = "albc-service-account" + policy = file("path/to/iam-policy.json") + } + ``` +1. Create an IAM role for the service account to assume, and set an assume policy for it. + ```bash + cat > assume-albc-service-account-role-policy.json < - If your cluster is in a US Gov Cloud region: - ``` - curl -o iam-policy.json https://raw.githubusercontent.com/kubernetes-sigs/aws-load-balancer-controller/v2.9.0/docs/install/iam_policy_us-gov.json - ``` - If your cluster is in a China region: - ``` - curl -o iam-policy.json https://raw.githubusercontent.com/kubernetes-sigs/aws-load-balancer-controller/v2.9.0/docs/install/iam_policy_cn.json - ``` - If your cluster is in any other region: - ``` - curl -o iam-policy.json https://raw.githubusercontent.com/kubernetes-sigs/aws-load-balancer-controller/v2.9.0/docs/install/iam_policy.json - ``` +1. Download an IAM policy as [defined above](#required-iam-policy). -3. Create an IAM policy named `AWSLoadBalancerControllerIAMPolicy`. If you downloaded a different policy, replace `iam-policy` with the name of the policy that you downloaded. +1. Create an IAM policy named `AWSLoadBalancerControllerIAMPolicy`. If you downloaded a different policy, replace `iam-policy` with the name of the policy that you downloaded. ``` aws iam create-policy \ --policy-name AWSLoadBalancerControllerIAMPolicy \ @@ -109,7 +222,7 @@ Example condition for cluster name resource tag: ``` Take note of the policy ARN that's returned. -4. Create an IAM role and Kubernetes `ServiceAccount` for the LBC. Use the ARN from the previous step. +1. Create an IAM role and Kubernetes `ServiceAccount` for the LBC. Use the ARN from the previous step. ``` eksctl create iamserviceaccount \ --cluster= \ @@ -121,7 +234,7 @@ Example condition for cluster name resource tag: --approve ``` -### Option B: Attach IAM policies to nodes +### Option C: Attach IAM policies to nodes If you're not setting up IAM roles for service accounts, apply the IAM policies from the following URL at a minimum. Please be aware of the possibility that the controller permissions may be assumed by other users in a pod after retrieving the node role credentials, so the best practice would be using IRSA instead of attaching IAM policy directly. ``` curl -o iam-policy.json https://raw.githubusercontent.com/kubernetes-sigs/aws-load-balancer-controller/v2.9.0/docs/install/iam_policy.json From 2db9b456a4697968df05e54d83a70cb9deff0333 Mon Sep 17 00:00:00 2001 From: Daniel Hartig Date: Tue, 15 Oct 2024 12:28:32 -0500 Subject: [PATCH 3/5] Trivial change to set new author --- docs/deploy/installation.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/deploy/installation.md b/docs/deploy/installation.md index f037804cd..33f8f3c7e 100644 --- a/docs/deploy/installation.md +++ b/docs/deploy/installation.md @@ -272,6 +272,7 @@ Review the [worker nodes security group](https://docs.aws.amazon.com/eks/latest/ If you use [eksctl](https://eksctl.io/usage/vpc-networking/), this is the default configuration. If you use custom networking, please refer to the [EKS Best Practices Guides](https://aws.github.io/aws-eks-best-practices/networking/custom-networking/#use-custom-networking-when) for network configuration. + ## Add controller to cluster We recommend using the Helm chart to install the controller. The chart supports Fargate and facilitates updating the controller. From 50ae59b0e5dc28663ddd7bfde48d65c44c6f33d8 Mon Sep 17 00:00:00 2001 From: Daniel Hartig Date: Tue, 15 Oct 2024 13:02:45 -0500 Subject: [PATCH 4/5] Proposed document changes --- docs/deploy/installation.md | 149 +++++++++++++++++++++++++++++++----- 1 file changed, 131 insertions(+), 18 deletions(-) diff --git a/docs/deploy/installation.md b/docs/deploy/installation.md index dda9fd4a8..f037804cd 100644 --- a/docs/deploy/installation.md +++ b/docs/deploy/installation.md @@ -43,9 +43,134 @@ Instead of depending on IMDSv2, you can specify the AWS Region via the controlle The controller runs on the worker nodes, so it needs access to the AWS ALB/NLB APIs with IAM permissions. -The IAM permissions can either be setup using [IAM roles for service accounts (IRSA)](https://docs.aws.amazon.com/eks/latest/userguide/iam-roles-for-service-accounts.html) or can be attached directly to the worker node IAM roles. The best practice is using IRSA if you're using Amazon EKS. If you're using kOps or self-hosted Kubernetes, you must manually attach polices to node instances. +The IAM permissions can be setup using any of: -### Option A: Recommended, IAM roles for service accounts (IRSA) +- [Pod Identity](https://docs.aws.amazon.com/eks/latest/userguide/pod-identities.html) associations +- [IAM roles for service accounts (IRSA)](https://docs.aws.amazon.com/eks/latest/userguide/iam-roles-for-service-accounts.html) +- Attached IAM permissions directly to the worker node IAM roles. + +The best practice is using Pod Identity associations if you're using Amazon EKS. If you're using kOps or self-hosted Kubernetes, you must manually attach polices to node instances. + +### Required IAM policy + +The IAM policy that must be attached to a service account may differ based on the region. Download an IAM policy for AWS Load Balancer Controller for your region using one of the following commands:

+ If your cluster is in a US Gov Cloud region: + ``` + curl -o iam-policy.json https://raw.githubusercontent.com/kubernetes-sigs/aws-load-balancer-controller/v2.9.0/docs/install/iam_policy_us-gov.json + ``` + If your cluster is in a China region: + ``` + curl -o iam-policy.json https://raw.githubusercontent.com/kubernetes-sigs/aws-load-balancer-controller/v2.9.0/docs/install/iam_policy_cn.json + ``` + If your cluster is in any other region: + ``` + curl -o iam-policy.json https://raw.githubusercontent.com/kubernetes-sigs/aws-load-balancer-controller/v2.9.0/docs/install/iam_policy.json + ``` + +### Option A: Recommended, EKS Pod Identity + +Instructions are shown from the aws and eksctl CLIs, as well as with terraform. Terraform must be set up with the terrafrom aws provider (version `~>5.0`). Appropriate permissions for the CLI or terraform provider must be provisioned. + +1. Download an IAM policy as [defined above](#required-iam-policy). + +1. Create an IAM policy from the downloaded policy JSON document. If you downloaded a different policy, replace `iam-policy` with the name of the policy that you downloaded. + ```bash + aws iam create-policy \ + --policy-name AWSLoadBalancerControllerIAMPolicy \ + --policy-document file://iam-policy.json + ``` + The equivalent operation in Terrform is: + ```hcl + resource "aws_iam_policy" "albc_service_account" { + name = "albc-service-account" + policy = file("path/to/iam-policy.json") + } + ``` +1. Create an IAM role for the service account to assume, and set an assume policy for it. + ```bash + cat > assume-albc-service-account-role-policy.json < - If your cluster is in a US Gov Cloud region: - ``` - curl -o iam-policy.json https://raw.githubusercontent.com/kubernetes-sigs/aws-load-balancer-controller/v2.9.0/docs/install/iam_policy_us-gov.json - ``` - If your cluster is in a China region: - ``` - curl -o iam-policy.json https://raw.githubusercontent.com/kubernetes-sigs/aws-load-balancer-controller/v2.9.0/docs/install/iam_policy_cn.json - ``` - If your cluster is in any other region: - ``` - curl -o iam-policy.json https://raw.githubusercontent.com/kubernetes-sigs/aws-load-balancer-controller/v2.9.0/docs/install/iam_policy.json - ``` +1. Download an IAM policy as [defined above](#required-iam-policy). -3. Create an IAM policy named `AWSLoadBalancerControllerIAMPolicy`. If you downloaded a different policy, replace `iam-policy` with the name of the policy that you downloaded. +1. Create an IAM policy named `AWSLoadBalancerControllerIAMPolicy`. If you downloaded a different policy, replace `iam-policy` with the name of the policy that you downloaded. ``` aws iam create-policy \ --policy-name AWSLoadBalancerControllerIAMPolicy \ @@ -109,7 +222,7 @@ Example condition for cluster name resource tag: ``` Take note of the policy ARN that's returned. -4. Create an IAM role and Kubernetes `ServiceAccount` for the LBC. Use the ARN from the previous step. +1. Create an IAM role and Kubernetes `ServiceAccount` for the LBC. Use the ARN from the previous step. ``` eksctl create iamserviceaccount \ --cluster= \ @@ -121,7 +234,7 @@ Example condition for cluster name resource tag: --approve ``` -### Option B: Attach IAM policies to nodes +### Option C: Attach IAM policies to nodes If you're not setting up IAM roles for service accounts, apply the IAM policies from the following URL at a minimum. Please be aware of the possibility that the controller permissions may be assumed by other users in a pod after retrieving the node role credentials, so the best practice would be using IRSA instead of attaching IAM policy directly. ``` curl -o iam-policy.json https://raw.githubusercontent.com/kubernetes-sigs/aws-load-balancer-controller/v2.9.0/docs/install/iam_policy.json From 3c7074f012ba1168694cbef920ff7987742ce2ef Mon Sep 17 00:00:00 2001 From: Daniel Hartig Date: Tue, 15 Oct 2024 12:28:32 -0500 Subject: [PATCH 5/5] Trivial change to set new author --- docs/deploy/installation.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/deploy/installation.md b/docs/deploy/installation.md index f037804cd..33f8f3c7e 100644 --- a/docs/deploy/installation.md +++ b/docs/deploy/installation.md @@ -272,6 +272,7 @@ Review the [worker nodes security group](https://docs.aws.amazon.com/eks/latest/ If you use [eksctl](https://eksctl.io/usage/vpc-networking/), this is the default configuration. If you use custom networking, please refer to the [EKS Best Practices Guides](https://aws.github.io/aws-eks-best-practices/networking/custom-networking/#use-custom-networking-when) for network configuration. + ## Add controller to cluster We recommend using the Helm chart to install the controller. The chart supports Fargate and facilitates updating the controller.