初一下電腦課書做網(wǎng)站百度競價排名榜
1、創(chuàng)建AmazonEKSLoadBalancerControllerRole角色
亞馬遜文檔
創(chuàng)建文檔
2)、使用 eksctl 創(chuàng)建 IAM 角色
a、安裝eksctl eksctl安裝文檔
使用以下命令下載并提取最新版本的 eksctl
curl --silent --location "https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_$(uname -s)_amd64.tar.gz" | tar xz -C /tmp
將提取的二進制文件移動到 /usr/local/bin
sudo mv /tmp/eksctl /usr/local/bin
使用以下命令測試您的安裝是否成功。您必須使用 eksctl 0.34.0 版本或更高版本
[root@ip-172-93-1-174 ~]# eksctl version
0.176.0
b、創(chuàng)建AmazonEKSLoadBalancerControllerRole角色
報錯
Error: unable to create iamserviceaccount(s) without IAM OIDC provider enabled
啟用 IAM OIDC 提供程序,否則會報以上錯
如果2024-05-02 17:13:03 [!] no changes were applied, run again with '--approve' to apply the changes
,則加上--approve
[root@ip-172-93-1-174 ~]# eksctl utils associate-iam-oidc-provider --region ap-east-1 --cluster eks-test
2024-05-02 17:13:03 [?] (plan) would create IAM Open ID Connect provider for cluster "eks-test" in "ap-east-1"
2024-05-02 17:13:03 [!] no changes were applied, run again with '--approve' to apply the changes
[root@ip-172-93-1-174 ~]# eksctl utils associate-iam-oidc-provider --region ap-east-1 --cluster eks-test --approve
2024-05-02 17:13:30 [?] will create IAM Open ID Connect provider for cluster "eks-test" in "ap-east-1"
2024-05-02 17:13:31 [?] created IAM Open ID Connect provider for cluster "eks-test" in "ap-east-1"
創(chuàng)建AmazonEKSLoadBalancerControllerRole角色
根據(jù)各自的情況判斷是否需要覆蓋現(xiàn)有的
--override-existing-serviceaccounts
[root@ip-172-93-1-174 ~]# eksctl create iamserviceaccount \--cluster=eks-test \--namespace=kube-system \--name=aws-load-balancer-controller \--role-name AmazonEKSLoadBalancerControllerRole \--attach-policy-arn=arn:aws:iam::XXXXXXXXX:policy/AWSLoadBalancerControllerIAMPolicy \--approve \--override-existing-serviceaccounts
2024-05-02 17:17:14 [?] 1 existing iamserviceaccount(s) (kube-system/aws-load-balancer-controller) will be excluded
2024-05-02 17:17:14 [?] 1 iamserviceaccount (kube-system/aws-load-balancer-controller) was excluded (based on the include/exclude rules)
2024-05-02 17:17:14 [!] metadata of serviceaccounts that exist in Kubernetes will be updated, as --override-existing-serviceaccounts was set
2024-05-02 17:17:14 [?] no tasks
2、安裝 AWS Load Balancer Controller
1)添加 eks-charts Helm 圖表存儲庫。AWS 在 GitHub 上維護eks-charts
[root@ip-172-93-1-174 ~]# helm repo add eks https://aws.github.io/eks-charts
"eks" has been added to your repositories
2、更新本地存儲庫,以確保您擁有最新的圖表
[root@ip-172-93-1-174 ~]# helm repo update eks
Hang tight while we grab the latest from your chart repositories...
...Successfully got an update from the "eks" chart repository
Update Complete. ?Happy Helming!?
3、安裝 AWS Load Balancer Controller。
在以下命令中,aws-load-balancer-controller 是您在上一步中創(chuàng)建的 Kubernetes 服務賬戶。
有關(guān)配置 Helm 圖表的更多信息,請參閱 GitHub 上的values.yaml
[root@ip-172-93-1-174 ~]# helm delete aws-load-balancer-controller -n kube-system
release "aws-load-balancer-controller" uninstalled
[root@ip-172-93-1-174 ~]# helm install aws-load-balancer-controller eks/aws-load-balancer-controller \-n kube-system \--set clusterName=eks-test \--set serviceAccount.create=false \--set serviceAccount.name=aws-load-balancer-controller
NAME: aws-load-balancer-controller
LAST DEPLOYED: Thu May 2 17:24:15 2024
NAMESPACE: kube-system
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
AWS Load Balancer controller installed!
如果要將控制器部署到被限制訪問 Amazon EC2 實例元數(shù)據(jù)服務 (IMDS) 的 Amazon EC2 節(jié)點,或者部署到 Fargate 節(jié)點,則需要在以下 helm 命令中添加以下標志:
--set region=region-code
--set vpcId=vpc-xxxxxxxx
要查看 Helm 圖表和負載均衡器控制器的可用版本,請使用以下命令:
[root@ip-172-93-1-174 ~]# helm search repo eks/aws-load-balancer-controller --versions
NAME CHART VERSION APP VERSION DESCRIPTION
eks/aws-load-balancer-controller 1.7.2 v2.7.2 AWS Load Balancer Controller Helm chart for Kub...
eks/aws-load-balancer-controller 1.7.1 v2.7.1 AWS Load Balancer Controller Helm chart for Kub...
注意:
已部署的圖表不會自動接收安全更新。當新圖表可用時,您需要手動升級到新圖表。升級時,在上一個命令中將 install 更改為 upgrade。
helm install 命令會自動安裝控制器的自定義資源定義(CRDs)。helm upgrade 命令不會。如果您使用 helm upgrade,,則必須手動安裝 CRDs。運行以下命令來安裝 CRDs:
wget https://raw.githubusercontent.com/aws/eks-charts/master/stable/aws-load-balancer-controller/crds/crds.yaml
kubectl apply -f crds.yaml
3、驗證控制器是否已安裝
1)驗證控制器是否已安裝
[root@ip-172-93-1-174 ~]# kubectl get deployment -n kube-system aws-load-balancer-controller
NAME READY UP-TO-DATE AVAILABLE AGE
aws-load-balancer-controller 2/2 2 2 83s
如果使用 Helm 進行部署,則會收到之前的輸出結(jié)果。如果您使用 Kubernetes 清單進行部署,則只有一個副本。
2)在使用控制器預置AWS資源前,您的集群必須滿足特定要求。有關(guān)更多信息,請參閱 Amazon EKS 上的應用程序負載均衡和 Amazon EKS 上的網(wǎng)絡(luò)負載均衡