OverView
久々にKubernetes(EKS)を弄ったとき、以下のエラーが出ました。
Unable to connect to the server: getting credentials: exec plugin is configured to use API version client.authentication.k8s.io/v1alpha1, plugin returned version client.authentication.k8s.io/v1beta1
その時の対処法です。
追記
eksctlを繰り返すたびにconfigがv1plpha1で設定されるため調べてみました。
Detection of the authenticator credential API version
eksctl のインストール
まとめるとeksctlのバージョンが古いときに発生するようです。
$ eksctl version
0.84.0
### アップデート後
$ eksctl version
0.86.0
0.86にすればOKです。
Environment
Machine : Mac M1
OS : Big Sur 11.2
$ kubectl version --client
Client Version: version.Info{Major:"1", Minor:"22", GitVersion:"v1.22.5", GitCommit:"5c99e2ac2ff9a3c549d9ca665e7bc05a3e18f07e", GitTreeState:"clean", BuildDate:"2021-12-16T08:38:33Z", GoVersion:"go1.16.12", Compiler:"gc", Platform:"darwin/arm64"}
$ aws --version
aws-cli/2.4.5 Python/3.8.8 Darwin/20.3.0 exe/x86_64 prompt/off
Action
エラー文言からkube configを見てみる
$ kubectl config view
apiVersion: v1
clusters:
- cluster:
certificate-authority-data: DATA+OMITTED
server: https://hoge.gr7.ap-northeast-1.eks.amazonaws.com
name: hoge.ap-northeast-1.eksctl.io
contexts:
- context:
cluster: hoge.ap-northeast-1.eksctl.io
user: hoge-eks.ap-northeast-1.eksctl.io
name: hoge-eks.ap-northeast-1.eksctl.io
current-context: hoge-eks.ap-northeast-1.eksctl.io
kind: Config
preferences: {}
users:
- name: hoge.ap-northeast-1.eksctl.io
user:
exec:
apiVersion: client.authentication.k8s.io/v1alpha1
args:
- token
- -i
- hoge
command: aws-iam-authenticator
env:
- name: AWS_STS_REGIONAL_ENDPOINTS
value: regional
- name: AWS_DEFAULT_REGION
value: ap-northeast-1
- name: AWS_PROFILE
value: hoge
interactiveMode: IfAvailable
provideClusterInfo: false
この部分です。
user:
exec:
apiVersion: client.authentication.k8s.io/v1alpha1
変更します。
vi ~/.kube/config
・・・
user:
exec:
apiVersion: client.authentication.k8s.io/v1beta1
・・・
確認します。
$ kubectl config view
apiVersion: v1
clusters:
- cluster:
・・・
users:
- name: hoge.ap-northeast-1.eksctl.io
user:
exec:
apiVersion: client.authentication.k8s.io/v1beta1
args:
- token
getコマンドでやってみます。
$ kubectl get pod,svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/kubernetes ClusterIP 10.100.0.1 <none> 443/TCP 109m
出来ました。
ご参考まで。