文章目录
小结
在Linux环境中对AWS CLI和EKSCTL的客户端进行了设置。
过程
安装AWS CLI
使用以下指令安装:
shell
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install
安装EKSCTL
使用以下指令安装:
shell
# for ARM systems, set ARCH to: `arm64`, `armv6` or `armv7`
ARCH=amd64
PLATFORM=$(uname -s)_$ARCH
curl -sLO "https://github.com/eksctl-io/eksctl/releases/latest/download/eksctl_$PLATFORM.tar.gz"
# (Optional) Verify checksum
curl -sL "https://github.com/eksctl-io/eksctl/releases/latest/download/eksctl_checksums.txt" | grep $PLATFORM | sha256sum --check
tar -xzf eksctl_$PLATFORM.tar.gz -C /tmp && rm eksctl_$PLATFORM.tar.gz
sudo mv /tmp/eksctl /usr/local/bin
在两个Kubernetes Cluster之间切换
在本地环境中的一个Kubernetes Cluster,在AWS中也有一个Kubernetes Cluster,两个环境之间进行切换:
查看两个环境:
shell
[root@Master ~]# kubectl config get-contexts
CURRENT NAME CLUSTER AUTHINFO NAMESPACE
* kubernetes-admin@kubernetes kubernetes kubernetes-admin
xxx@yyy@john-1-cluster.ap-southeast-1.eksctl.io john-1-cluster.ap-southeast-1.eksctl.io xxx@yyy@john-1-cluster.ap-southeast-1.eksctl.io
目前是本地环境,切换至AWS:
shell
[root@Master ~]# kubectl config use-context xxx@yyy@john-1-cluster.ap-southeast-1.eksctl.io
Switched to context "xxx@yyy@john-1-cluster.ap-southeast-1.eksctl.io".
[root@Master ~]#
查看AWS Kubernetes运行状态:
shell
[root@Master ~]# kubectl get nodes
NAME STATUS ROLES AGE VERSION
ip-192-168-42-199.ap-southeast-1.compute.internal Ready <none> 3m15s v1.27.7-eks-e71965b
ip-192-168-7-243.ap-southeast-1.compute.internal Ready <none> 3m11s v1.27.7-eks-e71965b
[root@Master ~]# kubectl get pods -o wide -A
NAMESPACE NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
kube-system aws-node-9nzj5 1/1 Running 0 36m 192.168.7.243 ip-192-168-7-243.ap-southeast-1.compute.internal <none> <none>
kube-system aws-node-wl6h4 1/1 Running 0 36m 192.168.42.199 ip-192-168-42-199.ap-southeast-1.compute.internal <none> <none>
kube-system coredns-66dddcb88c-lv9hb 1/1 Running 0 44m 192.168.44.60 ip-192-168-42-199.ap-southeast-1.compute.internal <none> <none>
kube-system coredns-66dddcb88c-r2vh9 1/1 Running 0 44m 192.168.45.98 ip-192-168-42-199.ap-southeast-1.compute.internal <none> <none>
kube-system kube-proxy-9sd55 1/1 Running 0 36m 192.168.7.243 ip-192-168-7-243.ap-southeast-1.compute.internal <none> <none>
kube-system kube-proxy-9tmjs 1/1 Running 0 36m 192.168.42.199 ip-192-168-42-199.ap-southeast-1.compute.internal <none> <none>
[root@Master ~]# kubectl top nodes
NAME CPU(cores) CPU% MEMORY(bytes) MEMORY%
ip-192-168-42-199.ap-southeast-1.compute.internal 18m 0% 448Mi 6%
ip-192-168-7-243.ap-southeast-1.compute.internal 20m 1% 425Mi 6%
参考
Install or update the latest version of the AWS CLI
Getting started with Amazon EKS -- eksctl
EKSCTL安装
Kubenetes Configure Access to Multiple Clusters