使用一个由地形创建的eks集群。我在使用aws-eks terraform模块。当将aws csi-驱动程序指定为集群添加-addon时,我得到
cluster_addons = {
coredns = {
addon_version = "v1.8.7-eksbuild.3"
resolve_conflicts = "OVERWRITE"
}
kube-proxy = {
addon_version = "v1.24.7-eksbuild.2"
resolve_conflicts = "OVERWRITE"
}
vpc-cni = {
addon_version = "v1.12.0-eksbuild.1"
resolve_conflicts = "OVERWRITE"
}
aws-ebs-csi-driver = {
addon_version = "v1.13.0-eksbuild.2"
resolve_conflicts="PRESERVE"
}
}aws_eks_addon.this["aws-ebs-csi-driver"]: Modifying... [id=it-tooling-eks-8fmuw5:aws-ebs-csi-driver]
╷
│ Error: error updating EKS Add-On (it-tooling-eks-8fmuw5:aws-ebs-csi-driver): InvalidParameter: 1 validation error(s) found.
│ - minimum field size of 1, UpdateAddonInput.ServiceAccountRoleArn.发布于 2022-12-01 21:58:57
简短的回答是使用以下方法:
cluster_addons = {
aws-ebs-csi-driver = {
service_account_role_arn = "arn:aws:iam::123456789012:role/amazon-eks-ebs-csi-driver-role-8fmuw5"
addon_version = "v1.13.0-eksbuild.2"
resolve_conflicts="PRESERVE"
}
}您需要该角色和相关策略才能使事物正常工作。我包括terragrunt脚本(使用terraform模块的terragrunt=terraform包装器),希望这对某人有所帮助。
角色
terraform {
source = "${format("%s%s", dirname(get_parent_terragrunt_dir()), "/..//modules/terraform-aws-iam/modules/iam-assumable-role-with-oidc")}"
}
include {
path = find_in_parent_folders()
}
dependencies {
paths = [
"../../../../once-per-account/policies/ebs-csi-driver-policy",
"../../../../once-per-account/policies/ebs-csi-kms-encryption-policy",
"../../random-string-env",
"../../eks"
]
}
dependency "ebs-csi-driver-policy" {
config_path = "../../../../once-per-account/policies/ebs-csi-driver-policy"
}
dependency "ebs-csi-kms-encryption-policy" {
config_path = "../../../../once-per-account/policies/ebs-csi-kms-encryption-policy"
}
dependency "random-string" {
config_path = "../../random-string-env"
}
dependency "eks" {
config_path = "../../eks"
}
inputs = {
create_role = true
role_requires_mfa = false
role_name = "amazon-eks-ebs-csi-driver-role-${dependency.random-string.outputs.random_suffix}"
tags = {
Role = "amazon-eks-ebs-csi-driver-role-${dependency.random-string.outputs.random_suffix}"
}
provider_url = dependency.eks.outputs.cluster_oidc_issuer_url
role_policy_arns = [dependency.ebs-csi-driver-policy.outputs.arn,dependency.ebs-csi-kms-encryption-policy.outputs.arn]
oidc_fully_qualified_audiences = [ "sts.amazonaws.com" ]
oidc_fully_qualified_subjects = ["system:serviceaccount:kube-system:ebs-csi-controller-sa"]
}政策
terraform {
source = "${format("%s%s", dirname(get_parent_terragrunt_dir()), "/..//modules/terraform-aws-iam/modules/iam-policy")}"
}
include {
path = find_in_parent_folders()
}
inputs = {
name = "AmazonEBSCSIDriverPolicyNew"
policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ec2:CreateSnapshot",
"ec2:AttachVolume",
"ec2:DetachVolume",
"ec2:ModifyVolume",
"ec2:DescribeAvailabilityZones",
"ec2:DescribeInstances",
"ec2:DescribeSnapshots",
"ec2:DescribeTags",
"ec2:DescribeVolumes",
"ec2:DescribeVolumesModifications"
],
"Resource": "*"
},
{
"Effect": "Allow",
"Action": [
"ec2:CreateTags"
],
"Resource": [
"arn:aws:ec2:*:*:volume/*",
"arn:aws:ec2:*:*:snapshot/*"
],
"Condition": {
"StringEquals": {
"ec2:CreateAction": [
"CreateVolume",
"CreateSnapshot"
]
}
}
},
{
"Effect": "Allow",
"Action": [
"ec2:DeleteTags"
],
"Resource": [
"arn:aws:ec2:*:*:volume/*",
"arn:aws:ec2:*:*:snapshot/*"
]
},
{
"Effect": "Allow",
"Action": [
"ec2:CreateVolume"
],
"Resource": "*",
"Condition": {
"StringLike": {
"aws:RequestTag/ebs.csi.aws.com/cluster": "true"
}
}
},
{
"Effect": "Allow",
"Action": [
"ec2:CreateVolume"
],
"Resource": "*",
"Condition": {
"StringLike": {
"aws:RequestTag/CSIVolumeName": "*"
}
}
},
{
"Effect": "Allow",
"Action": [
"ec2:CreateVolume"
],
"Resource": "*",
"Condition": {
"StringLike": {
"aws:RequestTag/kubernetes.io/cluster/*": "owned"
}
}
},
{
"Effect": "Allow",
"Action": [
"ec2:DeleteVolume"
],
"Resource": "*",
"Condition": {
"StringLike": {
"ec2:ResourceTag/ebs.csi.aws.com/cluster": "true"
}
}
},
{
"Effect": "Allow",
"Action": [
"ec2:DeleteVolume"
],
"Resource": "*",
"Condition": {
"StringLike": {
"ec2:ResourceTag/CSIVolumeName": "*"
}
}
},
{
"Effect": "Allow",
"Action": [
"ec2:DeleteVolume"
],
"Resource": "*",
"Condition": {
"StringLike": {
"ec2:ResourceTag/kubernetes.io/cluster/*": "owned"
}
}
},
{
"Effect": "Allow",
"Action": [
"ec2:DeleteSnapshot"
],
"Resource": "*",
"Condition": {
"StringLike": {
"ec2:ResourceTag/CSIVolumeSnapshotName": "*"
}
}
},
{
"Effect": "Allow",
"Action": [
"ec2:DeleteSnapshot"
],
"Resource": "*",
"Condition": {
"StringLike": {
"ec2:ResourceTag/ebs.csi.aws.com/cluster": "true"
}
}
}
]
}
EOF
}https://stackoverflow.com/questions/74648632
复制相似问题