当前位置:网站首页>远程存储访问授权
远程存储访问授权
2022-07-06 07:58:00 【添香小铺】
本文详细描述了如何授权访问远程存储,以实现备份 TiDB 集群数据到远程存储或从远程存储恢复备份数据到 TiDB 集群。
AWS 账号授权
在 AWS 云环境中,不同的类型的 Kubernetes 集群提供了不同的权限授予方式。本文分别介绍以下三种权限授予配置方式。
通过 AccessKey 和 SecretKey 授权
AWS 的客户端支持读取进程环境变量中的 AWS_ACCESS_KEY_ID 以及 AWS_SECRET_ACCESS_KEY 来获取与之相关联的用户或者角色的权限。
创建 s3-secret secret,在以下命令中使用 AWS 账号的 AccessKey 和 SecretKey 进行授权。该 secret 存放用于访问 S3 兼容存储的凭证。
kubectl create secret generic s3-secret --from-literal=access_key=xxx --from-literal=secret_key=yyy --namespace=test1
通过 IAM 绑定 Pod 授权
通过将用户的 IAM 角色与所运行的 Pod 资源进行绑定,使 Pod 中运行的进程获得角色所拥有的权限,这种授权方式是由 kube2iam 提供。
注意
- 使用该授权模式时,可以参考 kube2iam 文档在 Kubernetes 集群中创建 kube2iam 环境,并且部署 TiDB Operator 以及 TiDB 集群。
- 该模式不适用于 hostNetwork 网络模式,请确保参数
spec.tikv.hostNetwork的值为false。
创建 IAM 角色:
可以参考 AWS 官方文档来为账号创建一个 IAM 角色,并且通过 AWS 官方文档为 IAM 角色赋予需要的权限。由于
Backup需要访问 AWS 的 S3 存储,所以这里给 IAM 赋予了AmazonS3FullAccess的权限。绑定 IAM 到 TiKV Pod:
在使用 BR 备份的过程中,TiKV Pod 和 BR Pod 一样需要对 S3 存储进行读写操作,所以这里需要给 TiKV Pod 打上 annotation 来绑定 IAM 角色。
kubectl patch tc demo1 -n test1 --type merge -p '{"spec":{"tikv":{"annotations":{"iam.amazonaws.com/role":"arn:aws:iam::123456789012:role/user"}}}}'等到 TiKV Pod 重启后,查看 Pod 是否加上了这个 annotation。
注意
arn:aws:iam::123456789012:role/user 为步骤 1 中创建的 IAM 角色。
通过 IAM 绑定 ServiceAccount 授权
通过将用户的 IAM 角色与 Kubeneters 中的 serviceAccount 资源进行绑定, 从而使得使用该 ServiceAccount 账号的 Pod 都拥有该角色所拥有的权限,这种授权方式由 EKS Pod Identity Webhook 服务提供。
使用该授权模式时,可以参考 AWS 官方文档创建 EKS 集群,并且部署 TiDB Operator 以及 TiDB 集群。
在集群上为服务帐户启用 IAM 角色:
可以参考 AWS 官方文档开启所在的 EKS 集群的 IAM 角色授权。
创建 IAM 角色:
可以参考 AWS 官方文档创建一个 IAM 角色,为角色赋予
AmazonS3FullAccess的权限,并且编辑角色的Trust relationships。绑定 IAM 到 ServiceAccount 资源上:
kubectl annotate sa tidb-backup-manager -n eks.amazonaws.com/role-arn=arn:aws:iam::123456789012:role/user --namespace=test1将 ServiceAccount 绑定到 TiKV Pod:
kubectl patch tc demo1 -n test1 --type merge -p '{"spec":{"tikv":{"serviceAccount": "tidb-backup-manager"}}}'将
spec.tikv.serviceAccount修改为 tidb-backup-manager,等到 TiKV Pod 重启后,查看 Pod 的serviceAccountName是否有变化。
注意
arn:aws:iam::123456789012:role/user 为步骤 2 中创建的 IAM 角色。
GCS 账号授权
通过服务账号密钥授权
创建 gcs-secret secret。该 secret 存放用于访问 GCS 的凭证。google-credentials.json 文件存放用户从 GCP console 上下载的 service account key。具体操作参考 GCP 官方文档。
kubectl create secret generic gcs-secret --from-file=credentials=./google-credentials.json -n test1
Azure 账号授权
在 Azure 云环境中,不同的类型的 Kubernetes 集群提供了不同的权限授予方式。本文分别介绍以下两种权限授予配置方式。
通过访问密钥授权
Azure 的客户端支持读取进程环境变量中的 AZURE_STORAGE_ACCOUNT 以及 AZURE_STORAGE_KEY 来获取与之相关联的用户或者角色的权限。
创建 azblob-secret secret,在以下命令中使用 Azure 账号的访问密钥进行授权。该 secret 存放用于访问 Azure Blob Storage 的凭证。
kubectl create secret generic azblob-secret --from-literal=AZURE_STORAGE_ACCOUNT=xxx --from-literal=AZURE_STORAGE_KEY=yyy --namespace=test1
通过 Azure AD 授权
Azure 的客户端支持读取进程环境变量中的 AZURE_STORAGE_ACCOUNT、AZURE_CLIENT_ID、AZURE_TENANT_ID、AZURE_CLIENT_SECRET 来获取与之相关联的用户或者角色的权限。
创建
azblob-secret-adsecret,在以下命令中使用 Azure 账号的 AD 进行授权。该 secret 存放用于访问 Azure Blob Storage 的凭证。kubectl create secret generic azblob-secret-ad --from-literal=AZURE_STORAGE_ACCOUNT=xxx --from-literal=AZURE_CLIENT_ID=yyy --from- literal=AZURE_TENANT_ID=zzz --from-literal=AZURE_CLIENT_SECRET=aaa --namespace=test1绑定 secret 到 TiKV Pod:
在使用 BR 备份的过程中,TiKV Pod 和 BR Pod 一样需要对 Azure Blob Storage 进行读写操作,所以这里需要给 TiKV Pod 绑定 secret。
kubectl patch tc demo1 -n test1 --type merge -p '{"spec":{"tikv":{"envFrom":[{"secretRef":{"name":"azblob-secret-ad"}}]}}}'等到 TiKV Pod 重启后,查看 Pod 是否加上了这些环境变量。
边栏推荐
- The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
- 数据治理:误区梳理篇
- [Yugong series] February 2022 U3D full stack class 011 unity section 1 mind map
- Esrally domestic installation and use pit avoidance Guide - the latest in the whole network
- wincc7.5下载安装教程(Win10系统)
- Opencv learning notes 9 -- background modeling + optical flow estimation
- Compliance and efficiency, accelerate the digital transformation of pharmaceutical enterprises, and create a new document resource center for pharmaceutical enterprises
- Solution: système de surveillance vidéo intelligent de patrouille sur le chantier
- 数据治理:主数据的3特征、4超越和3二八原则
- Iterator Foundation
猜你喜欢

Inspiration from the recruitment of bioinformatics analysts in the Department of laboratory medicine, Zhujiang Hospital, Southern Medical University

【T31ZL智能视频应用处理器资料】

Understanding of law of large numbers and central limit theorem

继电反馈PID控制器参数自整定

Wireshark grabs packets to understand its word TCP segment

. Net 6 learning notes: what is NET Core

How to prevent Association in cross-border e-commerce multi account operations?

Linked list interview questions (Graphic explanation)

Machine learning - decision tree

Parameter self-tuning of relay feedback PID controller
随机推荐
Circuit breaker: use of hystrix
解决方案:智慧工地智能巡檢方案視頻監控系統
What are the ways to download network pictures with PHP
octomap averageNodeColor函数说明
edge浏览器 路径获得
Simulation of Teman green interferometer based on MATLAB
Entity class design for calculating age based on birthday
数据治理:微服务架构下的数据治理
MySQL view tablespace and create table statements
数据治理:主数据的3特征、4超越和3二八原则
Esrally domestic installation and use pit avoidance Guide - the latest in the whole network
Make learning pointer easier (3)
08- [istio] istio gateway, virtual service and the relationship between them
数据治理:误区梳理篇
649. Dota2 Senate
Easy to use tcp-udp_ Debug tool download and use
MEX有关的学习
[count] [combined number] value series
Webrtc series-h.264 estimated bit rate calculation
[非线性控制理论]9_非线性控制理论串讲