首页 / 平台管理 / 集群管理 / 集群 / 常见问题 / EKS 集群部署 Prometheus 监控组件网络相关配置

EKS 集群部署 Prometheus 监控组件网络相关配置

配置 AWS VPC

操作步骤

为遵守 AWS EKS 的安全规范,接下来的步骤都需要使用 Cloud Shell 操作。

  1. 在搜索栏输入 cloudshell 关键词,打开 Cloud Shell 功能页

  2. 检查当前所在的地区是否是接入集群所在的地区,有必要的话需要先切换到集群所在地区。

  3. 等待 Cloud Shell 就绪后,清空命令行,执行如下命令:

    # 获得正在接入的 EKS 集群使用的子网 ID 列表
    IFS=$'\n' read -d "" -ra _subnets < \
        <(aws eks describe-cluster --name "<正在接入的 EKS 集群名称>" \
        --query "cluster.resourcesVpcConfig.subnetIds" --output text \
        | tr '\t\r\n' ' ' | sed -E 's/ +/\n/g')
    
    declare -p _subnets
    
    # 对所有子网添加必要的标签
    cluster_import_to="<纳管集群的名称>"
    
    for _net in "${_subnets[@]}"; do
        aws ec2 create-tags --resources "$_net" \
            --tags "Key=kubernetes.io/role/elb,Value=1"
        aws ec2 create-tags --resources "$_net" \
            --tags "Key=kubernetes.io/cluster/${cluster_import_to},Value=shared"
    done