kubectl version mismatch server/client

재로미·2022년 10월 11일
0

k8s

목록 보기
1/1
post-thumbnail

회사에서 주로 개발하고 있는 서비스 애플리케이션들이 kubernetes 환경에서 돌아가고 있고, AWS EKS(Elastic Kubernetes Service)를 사용하여 멀티 클러스터 인프라 환경을 구축해두고 있다.

그렇다보니 로컬에 kubectl을 install 해두고 k9s 툴을 사용하여 클러스터 관리를 하고 있었는데, 며칠 전부터 아래와 같은 에러가 출력되기 시작했다.

Kubeconfig user entry is using deprecated API version client.authentication.k8s.io/v1alpha1. Run 'aws eks update-kubeconfig' to update.

이 출력문 대로 $ aws eks update-kubeconfig 를 하면 또 다음과 같은 에러를 마주할 것이다.

usage: aws [options] <command> <subcommand> [<subcommand> ...] [parameters]
To see help text, you can run:

  aws help
  aws <command> help
  aws <command> <subcommand> help

aws: error: the following arguments are required: --name

그래서 --name 옵션을 주어 클러스터 명을 명시해주어도 arn:aws:eks ~ 이런식으로 클러스터명이 시작된다면 특수문자로 인한 다음 에러가 출력되며 곤란하게 할 것이다.

An error occurred (InvalidParameterException) when calling the DescribeCluster operation: The name parameter contains invalid characters. It should begin with letter or digit and can have any of the following characters: the set of Unicode letters, digits, hyphens and underscores.

먼저 이 에러는 쿠버네티스 버전이 클러스터 환경과 접속하고 있는 로컬 환경이 크게 달라서 발생하는 에러이다.
현재 kubernetes cluster context가 에러를 내뱉고 있는 컨텍스트가 맞다면, 해당 컨텍스트에서 $ kubectl version 명령어로 버전을 확인해본다.

$ kubectl version
Kubeconfig user entry is using deprecated API version client.authentication.k8s.io/v1alpha1. Run 'aws eks update-kubeconfig' to update.
Client Version: version.Info{Major:"1", Minor:"23", GitVersion:"v1.23.5", GitCommit:"c285e781331a3785a7f436042c65c5641ce8a9e9", GitTreeState:"clean", BuildDate:"2022-03-16T15:51:05Z", GoVersion:"go1.17.8", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"21+", GitVersion:"v1.21.14-eks-6d3986b", GitCommit:"8877a3e28d597e1184c15e4b5d543d5dcdddddd", GitTreeState:"clean", BuildDate:"2022-07-20T22:05:32Z", GoVersion:"go1.16.15", Compiler:"gc", Platform:"linux/amd64"}
WARNING: version difference between client (1.23) and server (1.21) exceeds the supported minor version skew of +/-1

즉 server(eks cluster)와 client(local kubectl)의 버전이 +/-1 넘게 차이나서 warning이 뜨는 것인데, 이는 ~/.kube/config를 열어 환경변수를 약간 조작해줌으로써 해결할 수 있다.

편집기를 통해 열어보면 apiVersion에서 /v1alpha1 라고 되어 있는 부분이 있을 것이다.
이걸 /v1beta1로 변경하고 저장해보자.

이제 더이상의 warning은 뜨지 않게 되어 해결됨을 확인할 수 있다.

Reference

profile
정확하고 체계적인 지식을 가진 개발자 뿐만 아니라, 가진 지식을 사람들과 함께 나눌 수 있는 계발자가 되고 싶습니다

0개의 댓글