我想将Route 53用作裸机k8s群集的DNS提供程序。我在互联网上找到了一些指南,但是它们都是针对k8s云集群的。
以前有人做过吗?
答案 0 :(得分:2)
我设法在本地K8s群集上进行了设置。我使用了“ external-dns”-在本地(https://github.com/kubernetes-sigs/external-dns)上运行,这是我在AWS方面所做的事情:
创建以下资源:
IAM user k8s-r53-user
IAM policy assume-role-policy (attached to the k8s-r53-user)
IAM policy allow-k8s-r53-connection
IAM role k8s-r53-role (allow-k8s-r53-connection policy attached to this role)
$ aws iam create-user --user-name k8s-r53-user
policy-document1.json
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"iam:ListRoles",
"sts:AssumeRole"
],
"Resource": "*"
}
]
}
运行:
$ aws iam create-policy --policy-name assume-role-policy --policy-document policy-document1.json
$ aws iam attach-user-policy --user-name k8s-r53-user --policy-arn "arn:aws:iam::${account_id}:policy/assume-role-policy"
检查:
$ aws iam list-attached-user-policies --user-name k8s-r53-user
policy-document2.json:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"route53:ChangeResourceRecordSets"
],
"Resource": "arn:aws:route53:::hostedzone/*"
},
{
"Effect": "Allow",
"Action": [
"route53:ListHostedZones",
"route53:ListResourceRecordSets"
],
"Resource": [
"*"
]
}
]
}
运行:
$ aws iam create-policy --policy-name allow-k8s-r53-connection --policy-document policy-document2.json
application-role-trust-policy.json:
{
"Version": "2012-10-17",
"Statement": {
"Effect": "Allow",
"Principal": { "AWS": "arn:aws:iam::<account_id>:root" },
"Action": "sts:AssumeRole"
}
}
运行:
$ aws iam create-role --role-name k8s-r53-role --assume-role-policy-document application-role-trust-policy.json
为k8s-r53-user创建访问密钥:
$ aws iam create-access-key --user-name k8s-r53-user
$ aws configure
AWS Access Key ID []: xxx
AWS Secret Access Key []: xxx
Default region name []:
Default output format [None]:
按照“外部Dns”页面上的指南的“本地运行”部分,唯一更改的部分是结尾:
运行:
$ builds/external-dns --registry txt --provider=aws --aws-assume-'role=arn:aws:iam::${account_id}:role/k8s-r53-role --source service --once --dry-run'
代替:
$ external-dns --registry txt --txt-owner-id my-cluster-id --provider google --google-project example-project --source service --once --dry-run
答案 1 :(得分:-1)
是的,external-dns的配置与运行Kubernetes的方式/位置完全分开。您要做的唯一不同的事情是创建一个具有正确权限的专用IAM用户,并将凭据插入正确的环境变量中。我们对GKE集群执行相同的操作。