Create a autoscaling IAM role for Testing Farm's EKS clusters #12761
Labels
No labels
announcement
anubis
authentication
aws
backlog
blocked
bodhi
ci
cloud
communishift
copr
database
day-to-day
dc-move
deprecated
dev
discourse
dns
downloads
easyfix
epel
firmitas
forgejo_migration
Gain
High
Gain
Low
Gain
Medium
gitlab
greenwave
hardware
help wanted
high-trouble
koji
koschei
lists
low-trouble
medium-trouble
mirrorlists
monitoring
Needs investigation
odcs
OpenShift
ops
outage
packager_workflow_blocker
pagure
permissions
Priority
Needs Review
Priority
Next Meeting
Priority
🔥 URGENT 🔥
Priority
Waiting on Assignee
Priority
Waiting on External
Priority
Waiting on Reporter
rabbitmq
release-monitoring
releng
request-for-resources
s390x
security
SMTP
sprint-0
sprint-1
src.fp.o
staging
unfreeze
waiverdb
websites-general
wiki
Backlog Status
Needs Review
Backlog Status
Ready
chore
documentation
points
01
points
02
points
03
points
05
points
08
points
13
Priority
High
Priority
Low
Priority
Medium
Sprint Status
Blocked
Sprint Status
Done
Sprint Status
In Progress
Sprint Status
Review
Sprint Status
To Do
Technical Debt
Work Item
Bug
Work Item
Epic
Work Item
Spike
Work Item
Task
Work Item
User Story
No milestone
No project
No assignees
4 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
infra/tickets#12761
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Please add this IAM role for Testing Farm, we need it to autoscale our EKS clusters.
name:
fedora-ci-eks-autoscalerdescription: IAM role for k8s cluster autoscaler - https://docs.aws.amazon.com/eks/latest/best-practices/cas.html
Documentation: https://docs.aws.amazon.com/eks/latest/best-practices/cas.html
Metadata Update from @smoliicek:
Metadata Update from @kevin:
Done. Can you please test?
@kevin hmm, I cannot see it?
https://us-east-1.console.aws.amazon.com/iam/home?region=us-east-2#/roles/details/fedora-ci-eks-autoscaler?section=permissions
Oh, I set it up as a policy instead of a role.
https://us-east-1.console.aws.amazon.com/iam/home?region=us-east-2#/policies/details/arn%3Aaws%3Aiam%3A%3A125523088429%3Apolicy%2Ffedora-ci-testing-farm-autoscaler?section=permissions
I'm not sure how to add a role for this. I guess I'll read over the docs more.
it should be simple:
Custom trust policyShould be done
ah, I see...
well, it doesn't like it. ;)
Any ideas? I can't get past the syntaxt errors with the proposed one (even from their docs)... so I am surely doing something wrong. ;(
Any ideas what to try here?
Asked @mwinters if he can try to help here.
Thanks for ringing me in. Happy to help! I've included the above details in this post so you should be able to just follow it top to bottom.
Preface: Use Karpenter
First, I highly recommend using Karpenter to autoscale your clusters instead of the vanilla Cluster Autoscaler. It is slightly more complex and another tool to learn, but it simplifies many other admin tasks including cluster upgrades, cost optimization, and security.
But, I'll assume here that we want to use Cluster Autoscaler anyway for simplicity.
Pod IAM Credentials with PIA
There are several ways to get AWS credentials into a pod. I'm operating entirely blind here -- I have no access to Fedora AWS and no idea what our preferences / policies / norms are. But the modern recommended approach is to use the "Pod Identity Agent", aka PIA, which is both a Kubernetes add-on and a set of AWS IAM features. This allows you to explicitly and easily create a chain of IAM Policy -> IAM Role -> k8s Service Account -> My Pod.
My assumptions
Based on what I've gathered from random convos, I'll assume:
Step 1: Setup PIA in your cluster
With EKS Auto Mode
If you're using EKS Auto Mode then you are probably already done, unless your cluster is very old. PIA is installed by default into Auto Mode clusters. You can check this with
kubectl get pods -n kube-system | grep 'eks-pod-identity-agent'.Without Auto Mode
Step 1.1: Grant the worker node's IAM role permissions
AmazonEKSWorkerNodePolicythen you are already done.Step 1.2: Enable PIA in the EKS console
1. AWS Console -> EKS -> Clusters -> My Cluster
2. Add-ons -> Get more add-ons -> EKS Pod Identity Agent -> Next
3. If necessary, fill out any additional config that a k8s Service Account in your cluster would need, e.g.
ImagePullSecrets.4. Next. Wait a few minutes and you should see PIA running with
kubectl get pods -n kube-system | grep 'eks-pod-identity-agent'.Step 2: Create an IAM Policy with the permissions needed by your pod
1. AWS Console -> IAM -> Policies -> Create Policy -> JSON mode
2. Paste the following and click Next:
3. Name the policy something like
foocluster_autoscaling-> set Tags (because you do this on everything, right? right??!!!) -> Create Policy.Step 3: Attach the Policy to a new IAM Role
1. AWS Console -> IAM -> Roles -> Create Role -> Custom Trust Policy
2. Paste the following trust policy and click Next:
3. Search for the
foocluster_autoscalingpolicy we just created -> click the checkbox next to it -> Next4. Name the role something like
foocluster_autoscaling(yes, the role name is the same as the policy name) -> set tags -> Create role.Step 4. Create a Service Account for this app in your Kubernetes cluster
Note: You don't have to do this just yet. But if you do, then it will show up in the GUI in the next step instead of requiring you to type it.
kubectl -n kube-system create serviceaccount cluster-autoscalerStep 5. Associate the k8s Service Account with the AWS IAM Role
1. AWS Console -> EKS -> Clusters -> My Cluster
2. Access tab -> Pod identity associations -> Create
3. Select the
foocluster_autoscalingrole, the Kubernetes namespace (kube-systemin this case, I think), and thecluster-autoscalerService Account from that namespace.- If step 4 above isn't done yet, you can just hardcode these values and they'll apply whenever someone does that step.
Step 6. Make sure the pod isn't using the default Service Account
#HMU
You know where to find me if you have questions! And what FAS groups to add me to if you don't any more! ;)
I can do the IAM parts of this... but I don't have access to the eks cluster at all, so I can't see those parts of it.
@mvadkert Thoughts? Do you want to look at Karpenter? it looks interesting... but of course up to you.
My $0.02: if you have time to apply the change, this shouldn't break anything since Cluster Autoscaler already can't work. So I'd say: go for it. You'll just have to type the namespace and serviceaccount in Step 5 instead of selecting them in the GUI.
@mvadkert is this still needed? can you answer my queries from #12761 (comment) ?
@kevin we definitely are deploying karpenter this year, will recheck again the requirements, sorry for the delay.
Any news here?