TL;DR(요약)
# 설치
kubectl krew install konfig
# config 추가하기
kubectl konfig import new-cfg
# config 합치기
kubectl konfig merge cfg1 cfg2 > merged-cfg
# config 추출하기
kubectl konfig export minikube > minikube.config
# 삭제
kubectl krew uninstall konfig
Kubectl 프로처럼 다루기 시리즈
- Kubectl Namespace 빠르게 변경하기 (kubens)
- Kubectl Context 빠르게 변경하기 (Kubectx)
- Kubectl Config, Context 편하게 관리하기 (Konfig)
konfig
kubernetes를 사용하다 보면 멀티 클러스터를 사용할 일이 자주 생긴다. 그럴 때마다 config를 추가하고 바꿔주어야 하는데 클러스터가 많아지면 상당히 귀찮은 일이 된다. konfig는 이런 귀찮은 일을 아주 간편하게 명령어 한줄로 할 수 있어서 편리하다.
konfig는 Kubernetes의 kubeconfig를 관리하는 도구로 가져오기(import), 내보내기(export) 뿐만 아니라 기존의 kubeconfig를 병합(merge), 분할(split) 하는 기능을 제공한다.
konfig 설치
0. kubectl 플러그인 관리자인 krew를 설치한다. 설치 방법
012. kubectl 플러그인 매니저 Krew 설치하기
TL;DR(요약) # Krew 설치 ( set -x; cd "$(mktemp -d)" && OS="$(uname | tr '[:upper:]' '[:lower:]')" && ARCH="$(uname -m | sed -e 's/x86_64/amd64/' -e 's/\(arm\)\(64\)\?.*/\1\2/' -e 's/aarch64$/arm64/'..
bongjasee.tistory.com
1. 아래 명령으로 설치한다.
kubectl krew install konfig
2. 정상적으로 설치 되었는지 확인한다.
kubectl konfig
konfig 사용법
새로운 config 추가하기 (import)
konfig import --save new-cfg
new-cfg 로 저장된 새로운 context가 .kube/config에 자동으로 합쳐지고 저장된다.
주의! 다음과 같이 사용하지 말것 .kube/config 파일이 삭제될 수 있음
# WRONG, don't do this!
konfig import new-cfg > ~/.kube/config
여러개의 kubeconfig 병합하기 (merge)
konfig merge config1 config2 > merged-config
config1 과 config2 가 병합되어 stdout으로 출력되는데 리다이렉션을 통해 merged-config 로 저장한다.
병합을 하면 모든 credential이 kubeconfig 파일에 인라인 형식으로 저장됩니다. 기존 구조를 유지하고 credentials을 따로 관리하고 싶다면 --preserve-structure 옵션을 사용할 것.
kubeconfig 추출하기 (export)
# extract context minikube from the default kubeconfig
konfig export minikube > minikube.config
.kube/config에서 minikube config 파일을 분리하여 minikube.config 파일로 저장한다.
konfig 삭제하기
kubectl krew uninstall konfig
konfig: https://github.com/corneliusweig/konfig
GitHub - corneliusweig/konfig: konfig helps to merge, split or import kubeconfig files
konfig helps to merge, split or import kubeconfig files - GitHub - corneliusweig/konfig: konfig helps to merge, split or import kubeconfig files
github.com
더 읽어보기
kubectl을 더 쉽게 만들기! 플러그인 관리 툴: krew
2022.07.12 - [Infrastructure, MLOps/Kubernetes] - 012. kubectl 플러그인 매니저 Krew 설치하기
012. kubectl 플러그인 매니저 Krew 설치하기
TL;DR(요약) # Krew 설치 ( set -x; cd "$(mktemp -d)" && OS="$(uname | tr '[:upper:]' '[:lower:]')" && ARCH="$(uname -m | sed -e 's/x86_64/amd64/' -e 's/\(arm\)\(64\)\?.*/\1\2/' -e 's/aarch64$/arm64/'..
bongjasee.tistory.com
kubernetes namespace 쉽고 빠르게 변경하기: kubens
004. [토막글] Kubectl 기본 namespace 변경하기 (kubectl, kubectx, kubens)
TL;DR(요약) # kubens(kubectx) 설치 # krew 이용하여 설치 $ kubectl krew install ns # apt (Debian, Ubuntu) $ sudo apt install kubectx # Home brew (MacOS) $ brew install kubectx # namespace 변경 $ kube..
bongjasee.tistory.com
kubernetes context 쉽고 빠르게 변경하기: kubectx
014. kubectl kubernetes context, cluster 바꾸기 (kubectx)
TL;DR(요약) # kubectx 설치 $ kubectl krew install ctx # context 리스팅 $ kubectl ctx # context 변경 $ kubectl ctx new-context 1. Kubectl 사용하기 # context 확인 $ kubectl config get-contexts CURRENT..
bongjasee.tistory.com
'개발 > Kubernetes' 카테고리의 다른 글
014. kubectl kubernetes context, cluster 바꾸기 (kubectx) (0) | 2022.07.12 |
---|---|
012. kubectl 플러그인 매니저 Krew 설치하기 (0) | 2022.07.12 |
004. Kubectl 기본 namespace 변경하기 (kubectl, kubectx, kubens) (0) | 2021.03.03 |