svi*_*lim 6 elasticsearch kubernetes amazon-eks
当我尝试将在 Kubernetes 中运行的 Elasticsearch 7.8.0 实例连接到 S3 存储桶作为备份存储时遇到了一个问题。安装如下。
有一个部署为自定义资源 ( ECK )的 Elasticsearch 。然后在用于执行此资源部署的 pod 的 ServiceAccount 与有权访问目标存储桶进行备份的 IAM 角色之间存在信任关系。然后我创建了一个 AWS S3 类型的快照存储库,并提供该存储桶作为目标。但是当我尝试验证存储库时,我收到了拒绝访问错误。
据我所见,根据 ECK 原始文档创建自动快照,假设访问存储桶的凭据是通过 Keystore 存储的。但我也看到我的 Elasticsearch 版本使用的 AWS SDK 应该支持从 ServiceAccount 获取凭证:https : //github.com/elastic/elasticsearch/blob/v7.8.0/plugins/repository-s3/build.gradle#L31(使用受支持的 AWS 开发工具包)
因此我想知道为什么这些组件没有按预期工作。有没有人尝试建立类似的配置?Elasticsearch 中是否存在任何阻止其从 ServiceAccount 获取凭据的基本问题?
由于涉及的实体数量比较多,我试图概括地描述这个案例。请让我知道这种情况是否需要有关实体配置的额外详细信息。
--- 更新
以下是 pod 规范的示例:
kind: Pod
apiVersion: v1
metadata:
name: logging-elasticsearch-es-default-0
generateName: logging-elasticsearch-es-default-
namespace: elastic-logging
selfLink: /api/v1/namespaces/elastic-logging/pods/logging-elasticsearch-es-default-0
uid: 29ff69cc-9c01-448d-821e-d0da26cd2ba6
resourceVersion: '1950203'
creationTimestamp: '2020-07-15T15:38:40Z'
labels:
common.k8s.elastic.co/type: elasticsearch
controller-revision-hash: logging-elasticsearch-es-default-78fd9d9d45
elasticsearch.k8s.elastic.co/cluster-name: logging-elasticsearch
elasticsearch.k8s.elastic.co/config-hash: '2541120219'
elasticsearch.k8s.elastic.co/http-scheme: https
elasticsearch.k8s.elastic.co/node-data: 'true'
elasticsearch.k8s.elastic.co/node-ingest: 'true'
elasticsearch.k8s.elastic.co/node-master: 'true'
elasticsearch.k8s.elastic.co/node-ml: 'true'
elasticsearch.k8s.elastic.co/statefulset-name: logging-elasticsearch-es-default
elasticsearch.k8s.elastic.co/version: 7.8.0
statefulset.kubernetes.io/pod-name: logging-elasticsearch-es-default-0
annotations:
co.elastic.logs/module: elasticsearch
kubernetes.io/psp: eks.privileged
update.k8s.elastic.co/timestamp: '2020-07-15T15:42:46.115776158Z'
ownerReferences:
- apiVersion: apps/v1
kind: StatefulSet
name: logging-elasticsearch-es-default
uid: 34a0109c-708b-402c-96b9-89c3e292a6a6
controller: true
blockOwnerDeletion: true
spec:
volumes:
- name: aws-iam-token
projected:
sources:
- serviceAccountToken:
audience: sts.amazonaws.com
expirationSeconds: 86400
path: token
defaultMode: 420
containers:
- name: elasticsearch
image: 'docker.elastic.co/elasticsearch/elasticsearch:7.8.0'
env:
- name: AWS_ROLE_ARN
value: 'arn:aws:iam::<account_id>:role/AWSS3ElkSnapshotBucket'
- name: AWS_WEB_IDENTITY_TOKEN_FILE
value: /var/run/secrets/eks.amazonaws.com/serviceaccount/token
volumeMounts:
- name: aws-iam-token
readOnly: true
mountPath: /var/run/secrets/eks.amazonaws.com/serviceaccount
Run Code Online (Sandbox Code Playgroud)
--- 更新 2
这是用于执行 pod 的 ServiceAccount 示例。
kind: ServiceAccount
apiVersion: v1
metadata:
name: default
namespace: elastic-logging
selfLink: /api/v1/namespaces/elastic-logging/serviceaccounts/default
uid: 7e97ac47-d893-4425-9da7-ef87848714e8
resourceVersion: '1894373'
creationTimestamp: '2020-07-07T13:08:01Z'
annotations:
eks.amazonaws.com/role-arn: 'arn:aws:iam::<account_id>:role/AWSS3ElkSnapshotBucket'
secrets:
- name: default-token-q5qft
Run Code Online (Sandbox Code Playgroud)
因此,看起来官方文档展示了如何使用 GCS 将其与服务帐户绑定,这是有道理的,因为 GCP 也有服务帐户的概念。
对于 AWS 来说,情况略有不同,您通常会关联一个角色或承担一个具有正确权限的角色。这是关于如何在 Kubernetes 中使用它以及它现在如何得到官方支持的很好的指南。我相信 ECK 操作员还不支持它,因为文档说S3 存储插件使用 EC2 或 ECS IAM 角色。这很奇怪,因为您想要使用 S3 类型的角色来访问 S3。
文档中介绍了如何使用 AWS 用户而不是角色来访问 S3:
如果您以这种方式配置插件,那么您应该能够访问 S3,前提是用户对您要存储快照的 S3 存储桶具有写入权限。
| 归档时间: |
|
| 查看次数: |
520 次 |
| 最近记录: |