Step 1: Karpenter controller role create and attach policy
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Karpenter",
"Effect": "Allow",
"Action": [
"ssm:GetParameter",
"ec2:DescribeImages",
"ec2:RunInstances",
"ec2:DescribeSubnets",
"ec2:DescribeSecurityGroups",
"ec2:DescribeLaunchTemplates",
"ec2:DescribeInstances",
"ec2:DescribeInstanceTypes",
"ec2:DescribeInstanceTypeOfferings",
"ec2:DeleteLaunchTemplate",
"ec2:CreateTags",
"ec2:CreateLaunchTemplate",
"ec2:CreateFleet",
"ec2:DescribeSpotPriceHistory",
"pricing:GetProducts"
],
"Resource": "*"
},
{
"Sid": "ConditionalEC2Termination",
"Effect": "Allow",
"Action": "ec2:TerminateInstances",
"Resource": "*",
"Condition": {
"StringLike": {
"ec2:ResourceTag/karpenter.sh/nodepool": "*"
}
}
},
{
"Sid": "PassNodeIAMRole",
"Effect": "Allow",
"Action": "iam:PassRole",
"Resource": "arn:aws:iam::961489959441:role/Axis-MF-MSIL-PRE-PROD-CLUSTER-NodeInstanceRole"
},
{
"Sid": "EKSClusterEndpointLookup",
"Effect": "Allow",
"Action": "eks:DescribeCluster",
"Resource": "arn:aws:eks:ap-south-1:961489959441:cluster/Axis-MF-MSIL-PRE-PROD-CLUSTER"
},
{
"Sid": "AllowScopedInstanceProfileCreationActions",
"Effect": "Allow",
"Action": [
"iam:CreateInstanceProfile"
],
"Resource": "*",
"Condition": {
"StringEquals": {
"aws:RequestTag/kubernetes.io/cluster/Axis-MF-MSIL-PRE-PROD-CLUSTER": "owned",
"aws:RequestTag/topology.kubernetes.io/region": "ap-south-1"
},
"StringLike": {
"aws:RequestTag/karpenter.k8s.aws/ec2nodeclass": "*"
}
}
},
{
"Sid": "AllowScopedInstanceProfileTagActions",
"Effect": "Allow",
"Action": [
"iam:TagInstanceProfile"
],
"Resource": "*",
"Condition": {
"StringEquals": {
"aws:ResourceTag/kubernetes.io/cluster/Axis-MF-MSIL-PRE-PROD-CLUSTER": "owned",
"aws:ResourceTag/topology.kubernetes.io/region": "ap-south-1",
"aws:RequestTag/kubernetes.io/cluster/Axis-MF-MSIL-PRE-PROD-CLUSTER": "owned",
"aws:RequestTag/topology.kubernetes.io/region": "ap-south-1"
},
"StringLike": {
"aws:ResourceTag/karpenter.k8s.aws/ec2nodeclass": "*",
"aws:RequestTag/karpenter.k8s.aws/ec2nodeclass": "*"
}
}
},
{
"Sid": "AllowScopedInstanceProfileActions",
"Effect": "Allow",
"Action": [
"iam:AddRoleToInstanceProfile",
"iam:RemoveRoleFromInstanceProfile",
"iam:DeleteInstanceProfile"
],
"Resource": "*",
"Condition": {
"StringEquals": {
"aws:ResourceTag/kubernetes.io/cluster/Axis-MF-MSIL-PRE-PROD-CLUSTER": "owned",
"aws:ResourceTag/topology.kubernetes.io/region": "ap-south-1"
},
"StringLike": {
"aws:ResourceTag/karpenter.k8s.aws/ec2nodeclass": "*"
}
}
},
{
"Sid": "AllowInstanceProfileReadActions",
"Effect": "Allow",
"Action": "iam:GetInstanceProfile",
"Resource": "*"
}
]
}
Step2: Tag security group of cluster:
aws ec2 create-tags --tags "Key=karpenter.sh/discovery,Value=MF-MS-PRE-PROD-CLUSTER" --resources "sg-06ee27bb7de43cf6e"
Top comments (0)