Kubernetes

쿠버네티스 apiVersion이란?

라온클 2023. 1. 15. 16:13

쿠버네티스 apiVersion이란?

한줄 요약하면 오브젝트를 포함하는 API의 버전이다.

  • apiVersion은 "group/version" 형태다.
  • 쿠버네티스 버전에 따라 사용 가능한 apiVersion이 다르다.
  • 일반적으로 alpha, beta 버전은 안정적이진 않지만, 그만큼 풍부한 기능을 갖고있기도 하다
  • 쿠버네티스에서 사용 가능한 apiVersion은 kubectl api-versions 명령어로 확인할 수 있다.

 

 

 

 

오브젝트의 apiVersion 확인하는 방법

kubectl explain {오브젝트 종류}

 

예시 : kubectl explain cronjob 했을 때, 'VERSION:  batch/v1' 이 cronjob의 apiVersion 이다.

controlplane ~ ➜  kubectl explain cronjob
KIND:     CronJob
VERSION:  batch/v1

DESCRIPTION:
     CronJob represents the configuration of a single cron job.

FIELDS:
   apiVersion   <string>
     APIVersion defines the versioned schema of this representation of an
     object. Servers should convert recognized schemas to the latest internal
     value, and may reject unrecognized values. More info:
     https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources

   kind <string>
     Kind is a string value representing the REST resource this object
     represents. Servers may infer this from the endpoint the client submits
     requests to. Cannot be updated. In CamelCase. More info:
     https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds

   metadata     <Object>
     Standard object's metadata. More info:
     https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata

   spec <Object>
     Specification of the desired behavior of a cron job, including the
     schedule. More info:
     https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status

   status       <Object>
     Current status of a cron job. More info:
     https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status


controlplane ~ ➜

 

 

 

 apiVersion 활성화/비활성화 하는 방법

API서버 manifest파일에서 --runtime-config 설정으로 활성화 또는 비활성화할 수 있다. 

  • batch/v2alpha1 을 활성화하려면, --runtime-config=batch/v2alpha1 으로 설정한다.(true가 기본값)
  • batch/v1을 비활성화하려면, --runtime-config=batch/v1=false 로 설정한다.

 

# 1단계 : 기존 apiserver의 manifest파일을 백업하기
cp -v /etc/kubernetes/manifests/kube-apiserver.yaml /root/kube-apiserver.yaml.backup

# 2단계 : apiserver의 manifest파일을 변경하기
vi /etc/kubernetes/manifests/kube-apiserver.yaml
~~~~
 - command:
    - kube-apiserver
    - --advertise-address=10.18.17.8
    - --allow-privileged=true
    - --authorization-mode=Node,RBAC
    ..
    - --runtime-config={API그룹}/{버전}
~~~~

# 3단계 : 확인하기
kubectl get po -n kube-system

 

 

참고 링크