iT邦幫忙

2021 iThome 鐵人賽

DAY 24
0
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 23】建立 EKS on Outpost 的前置作業
下一篇
【Day 25】建立 EKS on Outpost 的步驟(下)
系列文
運用皮毛技術與 AWS 平台、打造雲端蘿蔔服務三十天30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 則留言

0
chui2361
iT邦新手 5 級 ‧ 2022-03-19 11:26:57

你建立給control plane 是public 還是 private subnet?

control plane 只要放在 region 上就行
至於 internet gateway 倒不是必要

You can use Amazon EKS to run Kubernetes applications on-premises with AWS Outposts. Amazon EKS on AWS Outposts supports extended clusters, with the Kubernetes control plane running in the parent AWS Region, and worker nodes running on AWS Outposts.

Ref: https://docs.aws.amazon.com/eks/latest/userguide/eks-on-outposts.html

我要留言

立即登入留言