拨号tcp 127.0.0.1:8080:连接:连接被拒绝AWS CodeBuild EKS



我在尝试部署到EKS集群时遇到以下错误消息,即使我已经像一样将CodeBuild IAM角色添加到aws-auth.yaml

- rolearn: arn:aws:iam::<AWS_ACCOUNT_ID>:role/codebuild-eks
username: codebuild-eks
groups:
- system:masters 

错误:无法识别"yml":收到http://localhost:8080/api?timeout=32s:拨号tcp 127.0.0.1:8080:connect:连接被拒绝

这是我的代码构建命令:

version: 0.2
phases:
install:
commands:
- curl -o kubectl https://amazon-eks.s3-us-west-2.amazonaws.com/1.11.10/2019-06-21/bin/linux/amd64/kubectl
- chmod +x ./kubectl
- mkdir -p $HOME/bin && cp ./kubectl $HOME/bin/kubectl && export PATH=$HOME/bin:$PATH
- kubectl version --short --client
- curl -o aws-iam-authenticator https://amazon-eks.s3-us-west-2.amazonaws.com/1.13.7/2019-06-11/bin/linux/amd64/aws-iam-authenticator
- chmod +x ./aws-iam-authenticator
- mkdir -p $HOME/bin && cp ./aws-iam-authenticator $HOME/bin/aws-iam-authenticator && export PATH=$HOME/bin:$PATH
- aws-iam-authenticator help
pre_build:
commands:
- echo Entered the pre_build phase...
- echo Logging in to Amazon EKS...
- mkdir -p ~/.kube
- aws s3 cp s3://ppshein-eks/config ~/.kube/config
- export KUBECONFIG=$KUBECONFIG:~/.kube/config
- aws eks --region $AWS_DEFAULT_REGION update-kubeconfig --name $AWS_CLUSTER_NAME
build:
commands:
- echo Entered the build phase...
- echo Change directory to secondary source
- cd $CODEBUILD_SRC_DIR
- echo List directory
- ls -la
- kubectl get pods --kubeconfig ~/.kube/config
- kubectl apply -f deployment.yml

问题是,当CodeBuild运行这个kubectl apply -f deployment.yml语句时,我收到了错误消息,但上面的kubectl get pods --kubeconfig ~/.kube/config工作正常。

请让我知道我错过了要添加或配置的区域。谢谢

这些错误表明kubectl无法访问127.0.0.1:8080处的kubernetes服务器端点或本地主机。由于您已经使用命令update-kubeconfig配置了kubeconfig,似乎由于以下命令,多个配置正在合并1:

- export KUBECONFIG=$KUBECONFIG:~/.kube/config

要查看kubectl看到的结果配置,请在失败的命令之前运行以下命令:

- kubectl config view                      # Add this
- kubectl apply -f deployment.yml

要修复此问题,我建议在预构建阶段更改如下:

- export KUBECONFIG=~/.kube/config

或者,在kubectl中使用"--context"标志来选择正确的上下文。

- export KUBECONFIG=file1:file2
- kubectl get pods --context=cluster-1
- kubectl get pods --context=cluster-2

相关内容

  • 没有找到相关文章

最新更新