跳转至

AWS 服务器配置

本地安装AWS CLI

AWS CLI + Kubectl Installation in Local Machine

__AWS CLI

  • https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html
  • Learner Lab CLI’s AWS CLI is outdated! Cannot use it for EKS setup
  • Do make sure to download the latest version of AWS CLI in your local machine.
  • Do make sure to download the same version of kubectl with your EKS (e.g. v1.30)

aws macOS

Bash
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
 curl "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "AWSCLIV2.pkg"
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 38.0M  100 38.0M    0     0  17.3M      0  0:00:02  0:00:02 --:--:-- 17.3M
  ~                                                                                                                                                                            13:47:19
❯ sudo installer -pkg AWSCLIV2.pkg -target /
Password:
installer: Package name is AWS Command Line Interface
installer: Installing at base path /
installer: The install was successful.
  ~                                                                                                                                                                      21s  13:47:51
❯ curl "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "AWSCLIV2.pkg"
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 38.0M  100 38.0M    0     0  5350k      0  0:00:07  0:00:07 --:--:-- 4507k
  ~                                                                                                                                                                       7s  13:48:09
❯ sudo installer -pkg ./AWSCLIV2.pkg -target /
installer: Package name is AWS Command Line Interface
installer: Upgrading at base path /
installer: The upgrade was successful.
  ~                                                                                                                                                                      18s  13:48:28
❯ which aws
/usr/local/bin/aws
  ~                                                                                                                                                                            13:48:33
❯ aws --version
aws-cli/2.17.7 Python/3.11.8 Darwin/23.3.0 exe/x86_64

update kubectl

AWS Configure

Configure required credential details using the information obtained in Learner Lab CLI

  • Execute “aws configure”
  • Execute “aws configure set aws_session_token ${aws_session_token}”

you can get these detailed info in your AWS canvas > AWS details

image-20240703135923034.png

Create EKS Cluster

Create EKS - Click green button to go to AWS Console - Search for eks !!!!!!

image-20240703140112739.png

image-20240703140525898.png

Provision an EKS Cluster

No special configurations, just use default settings

image-20240703140657617.png

子网记得要删除4个,保留两个(系统默认会给6个,需要删除)

后面一路默认就行

最后我们会得到:

image-20240703140751860.png

Deploy Worker Nodes - Create Node Group

这一步得等上一步“正在创建”变成“活动/Active”才可以继续进行(预计10min左右)

image-20240703142107323.png

image-20240703142127968.png

No special configuraions, just use default settings

image-20240703142400365.png

Final EKS Cluster Overview

image-20240703142431328.png

image-20240703142505365.png

Connect to EKS

  • Bind to your EKS Cluster with [region-code] + [Cluster Name]
    • aws eks --region us-east-1 update-kubeconfig --name MyEKS
  • Verify the setup
    • kubectl version
    • kubectl get nodes
Bash
1
2
 aws eks --region us-east-1 update-kubeconfig --name MyEKS
Added new context arn:aws:eks:us-east-1:034901485801:cluster/MyEKS to /Users/huluobo/.kube/config
Bash
1
2
3
4
5
6
 kubectl version
WARNING: This version information is deprecated and will be replaced with the output from kubectl version --short.  Use --output=yaml|json to get the full version.
Client Version: version.Info{Major:"1", Minor:"27", GitVersion:"v1.27.4", GitCommit:"fa3d7990104d7c1f16943a67f11b154b71f6a132", GitTreeState:"clean", BuildDate:"2023-07-19T12:20:54Z", GoVersion:"go1.20.6", Compiler:"gc", Platform:"darwin/arm64"}
Kustomize Version: v5.0.1
Server Version: version.Info{Major:"1", Minor:"30+", GitVersion:"v1.30.1-eks-1de2ab1", GitCommit:"3f9ff295e4a3ba61685af19aca70ac5cdddcd59b", GitTreeState:"clean", BuildDate:"2024-06-18T22:44:45Z", GoVersion:"go1.22.2", Compiler:"gc", Platform:"linux/amd64"}
WARNING: version difference between client (1.27) and server (1.30) exceeds the supported minor version skew of +/-1
Bash
1
2
3
4
 kubectl get nodes
NAME                            STATUS   ROLES    AGE     VERSION
ip-172-31-65-224.ec2.internal   Ready    <none>   2m54s   v1.30.0-eks-036c24b
ip-172-31-7-8.ec2.internal      Ready    <none>   2m49s   v1.30.0-eks-036c24b

Deploy a Echo Server Service on EKS

image-20240703163808132.png

  • kubectl apply -f server-pod.yaml
  • kubectl apply -f service-nodeport.yaml

Configure EKS Nodes Security Group

Until now, NodePort is not accessible because EC2 instances reject all inbound requests by default.

Solution: Configure a Security Group for EC2 instances of your EKS Nodes

image-20240703143337396.png

Create a Security Group that allow all inbound requests

image-20240703143720743.png

Create a Security Group that allow all inbound requests

image-20240703143738931.png

image-20240703143814279.png

Change Security Group for all EKS EC2 Nodes

image-20240703143751255.png

需要修改的是具有公有IP_Addr的Interface

image-20240703144233727.png

image-20240703144242900.png

记得点击 Add security group

image-20240703144258442.png

Test NodePort

image-20240703164409225.png