【Day 24】建立 EKS on Outpost 的步骤(上)

tags: 铁人赛 AWS Outposts EKS Kubernetes

前情提要

  • 昨天稍微提及了关於 EKS 和 EKS on Outpost 的限制
  • 今天我们会来纪录建立的步骤细节

EKS cluster build steps

切换到 EKS console

  • 因为这座 Outpost 直连网路接到东京的关系,所以 cluster 也要选择东京
  • 老样子,选橘色按钮!
    • CreateRegister 二个选择,选 Create
    • Register 是新功能,就是单纯使用 EKS

很重要的一点,这边特别提醒!!
如果你使用的是 root account 而非 iam user 的话、
赶快去建立一个并且切换过去!

不然之後再分配权限的时候,会很麻烦。
不确定我在说什麽的可以在下方提问,
或者是参考 Managing users or IAM roles for your cluster 文件

步骤 1: Configure cluster

  • 帮丛集取名字
  • 选择 K8S 的版本,关於版本的更新频率,可以参考 Updates to Amazon EKS Version Lifecycle

    A new Kubernetes version is released as generally available by the Kubernetes project every 70 and 130 days (we take the average of 90 days for simplicity).

  • 接着是帮这个服务本身,建立一组角色来,并且配置角色可以使用哪些服务喔。
    • 服务选择 EKS (Elastic Kubernetes Service) 的 Cluster
    • Policy 选择 AmazonEKSClusterPolicy
    • 可以点开来看这组 AWS 的所提供的政策包含哪些内容
      {
          "Version": "2012-10-17",
          "Statement": [
              {
                  "Effect": "Allow",
                  "Action": [
                      "autoscaling:DescribeAutoScalingGroups",
                      "autoscaling:UpdateAutoScalingGroup",
                      "ec2:AttachVolume",
                      "ec2:AuthorizeSecurityGroupIngress",
                      "ec2:CreateRoute",
                      "ec2:CreateSecurityGroup",
                      "ec2:CreateTags",
                      "ec2:CreateVolume",
                      "ec2:DeleteRoute",
                      "ec2:DeleteSecurityGroup",
                      "ec2:DeleteVolume",
                      "ec2:DescribeInstances",
                      "ec2:DescribeRouteTables",
                      "ec2:DescribeSecurityGroups",
                      "ec2:DescribeSubnets",
                      "ec2:DescribeVolumes",
                      "ec2:DescribeVolumesModifications",
                      "ec2:DescribeVpcs",
                      "ec2:DescribeDhcpOptions",
                      "ec2:DescribeNetworkInterfaces",
                      "ec2:DetachVolume",
                      "ec2:ModifyInstanceAttribute",
                      "ec2:ModifyVolume",
                      "ec2:RevokeSecurityGroupIngress",
                      "ec2:DescribeAccountAttributes",
                      "ec2:DescribeAddresses",
                      "ec2:DescribeInternetGateways",
                      "elasticloadbalancing:AddTags",
                      "elasticloadbalancing:ApplySecurityGroupsToLoadBalancer",
                      "elasticloadbalancing:AttachLoadBalancerToSubnets",
                      "elasticloadbalancing:ConfigureHealthCheck",
                      "elasticloadbalancing:CreateListener",
                      "elasticloadbalancing:CreateLoadBalancer",
                      "elasticloadbalancing:CreateLoadBalancerListeners",
                      "elasticloadbalancing:CreateLoadBalancerPolicy",
                      "elasticloadbalancing:CreateTargetGroup",
                      "elasticloadbalancing:DeleteListener",
                      "elasticloadbalancing:DeleteLoadBalancer",
                      "elasticloadbalancing:DeleteLoadBalancerListeners",
                      "elasticloadbalancing:DeleteTargetGroup",
                      "elasticloadbalancing:DeregisterInstancesFromLoadBalancer",
                      "elasticloadbalancing:DeregisterTargets",
                      "elasticloadbalancing:DescribeListeners",
                      "elasticloadbalancing:DescribeLoadBalancerAttributes",
                      "elasticloadbalancing:DescribeLoadBalancerPolicies",
                      "elasticloadbalancing:DescribeLoadBalancers",
                      "elasticloadbalancing:DescribeTargetGroupAttributes",
                      "elasticloadbalancing:DescribeTargetGroups",
                      "elasticloadbalancing:DescribeTargetHealth",
                      "elasticloadbalancing:DetachLoadBalancerFromSubnets",
                      "elasticloadbalancing:ModifyListener",
                      "elasticloadbalancing:ModifyLoadBalancerAttributes",
                      "elasticloadbalancing:ModifyTargetGroup",
                      "elasticloadbalancing:ModifyTargetGroupAttributes",
                      "elasticloadbalancing:RegisterInstancesWithLoadBalancer",
                      "elasticloadbalancing:RegisterTargets",
                      "elasticloadbalancing:SetLoadBalancerPoliciesForBackendServer",
                      "elasticloadbalancing:SetLoadBalancerPoliciesOfListener",
                      "kms:DescribeKey"
                  ],
                  "Resource": "*"
              },
              {
                  "Effect": "Allow",
                  "Action": "iam:CreateServiceLinkedRole",
                  "Resource": "*",
                  "Condition": {
                      "StringEquals": {
                          "iam:AWSServiceName": "elasticloadbalancing.amazonaws.com"
                      }
                  }
              }
          ]
      }
      
    • 上半部提到的,允许这个 eksClusterRole 去建立操作删除 EC2、ELB 等、读取 KMS 的行为都可以理解。
    • 而下半部的允许 iam:AWSServiceNameelasticloadbalancing.amazonaws.com 的资源,去建立 iam:CreateServiceLinkedRole 是因为建立 ELB 的时候,需要同时去建立那个 ELB 所对应的 Service Linked Role。不然的话,ELB 会建不起来。
  • 然後是额外的加密功能、帮 EKS cluster 打标签。
    • 加密这个功能感觉很重要,建议阅读Amazon EKS 使用 AWS KMS 为密码新增信封加密

      Enabling secrets encryption allows you to use AWS Key Management Service (KMS) keys to provide envelope encryption of Kubernetes secrets stored in etcd for your cluster. This encryption is in addition to the EBS volume encryption that is enabled by default for all data (including secrets) that is stored in etcd as part of an EKS cluster.

      Using secrets encryption for your EKS cluster allows you to deploy a defense in depth strategy for Kubernetes applications by encrypting Kubernetes secrets with a KMS key that you define and manage.

      Using Secrets Encryption

      • Use AWS KMS to create a KMS key in the same region as your cluster or use an existing key.
      • You cannot modify or remove encryption from a cluster once it has been enabled.
      • All Kubernetes secrets stored in the cluster where secrets encryption is enabled will be encrypted with the KMS key you provide.
    • 今天时间有限,以後专做文章给各位说明。

步骤 2: Specify networking

  • 这边要注意,Control plane 不能建立在 Outpost 上的原因,上一篇已经说过,因为全托管服务,亚马逊他这个 console 网页伺服是 region 上的东西。
  • 所以这边要另外去建立新的子网段,放在 Tokyo region 而且至少要跨两个 AZ。

    Choose the subnets in your VPC where the control plane may place elastic network interfaces (ENIs) to facilitate communication with your cluster. The specified subnets must span at least two availability zones.

    • 建立新的子网段,为了避免夜长梦多,我先配三个分别放在不同 AZ!!
    • 记得指定 AZ,否则三个网段都抽到同一区
  • 建好网段如下
  • Endpoint 的部分昨天也提到罗,选混合模式。

步骤 3: Configure logging

  • 因为要额外收费,所以是财力决定要不要开

步骤 4: Review and create

  • 检查配置对不对的最後一步

小结

  • 建立过程大约需要消耗 5 ~ 20 分钟
  • 建议先去泡杯咖啡,等等再回来

其他补充

等待很重要

  • 如果丛集建立尚未完成的话,直接跑 CloudFormation 会失败
  • 到时候 EC2 建立起来之後,群龙无首,你势必还是得把他们砍掉再重建
  • 接下来要加入 Work Node 的方式,要透过 CloudFormation
  • 时间不早了,明天再来写後半部;这样摆着一小时会消耗 0.1 美金

<<:  [day-18] 认识Python的资料结构!(Part .5)

>>:  Grid 展开 Detail - day18

30天程序语言研究

今天是30天程序语言研究的第二十七天,由於最近写unix语言的东西用到很多,所以做了很多笔记,就想说...

第四章之三

续前面所述,这次要跟各位介绍的是档案上传与资料库功能,Filemanager应在其他平台有都会有类似...

Unity与Photon的新手相遇旅途 | Day22-Photon Lobby UI (下)

今天讲的内容为制作Lobby的一些基本简单UI(下集)。 ...

Day34 - 【实战篇-预告】使用iFrame实现Dialog弹跳登入

本系列文之後也会置於个人网站 oidc-client 提供了几种登入方式: 跳转页面登入 也就是先...

[Day27] - Django-REST-Framework API 期末专案实作 (二)

接续昨天的专案,创建好负责管理资料库的 model 之後,接着我们今天要来建立 Serializer...