기본 콘텐츠로 건너뛰기

[GCP] 터미널에서 kubectl 사용하기

[GCP] 터미널에서 kubectl 사용하기

GKE에서 Kubernetes 클러스터를 생성했다면, Cloud Shell에서 바로 Kubectl을 이용해 Kubernetes 환경에 접근할 수 있다. 하지만, Cloud Shell 환경은 설치된 라이브러리나 소프트웨어가 향후에 사라질 수 있기 때문에, 인스턴스를 만들어 SSH연결이나 터미널 클라이언트를 사용하곤 한다.

터미널 클라이언트의 사용은 아래의 내용을 참고하면 된다.

터미널에서 Putty 사용하기

kubectl을 사용하기 위해서는 google cloud sdk를 설치해야하는데, 설치 방법도 위의 내용을 참고하면 된다. kubectl의 설치는 아래와 같이 한다.

sudo apt-get update && sudo apt-get install -y apt-transport-https curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add - echo "deb https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee -a /etc/apt/sources.list.d/kubernetes.list sudo apt-get update sudo apt-get install -y kubectl

kubectl을 사용해 control할 cluster를 지정하고 credential을 확보해주어야 하는데, gcloud 명령어로 가능하다. GCP Console에서 GKE 클러스터를 하나 생성하고 그 이름을 'CLUSTER_NAME'에 지정해 주면 된다.

gcloud container clusters get-credentials [CLUSTER_NAME]

아래와 같이 동작하면 성공.

ryu.gcloud2@flask-test:~$ kubectl get service NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE kubernetes ClusterIP 10.0.0.1 443/TCP 23h

※ AWS에서도 전체적인 맥락은 비슷한데, IAM과 RBAC간 계정 설정이 잘못되었는지, 아래와 같은 에러가 발생한다. 하루 동안 헤맸는데 아직 무슨 문제인지 모르겠다.

AWS Kubectl 설정 에러

from http://magoker.tistory.com/23 by ccl(A) rewrite - 2020-03-11 04:20:15

댓글

이 블로그의 인기 게시물

Flask 13. pythonanywhere에 배포하기

Flask 13. pythonanywhere에 배포하기 Login: PythonAnywhere It's always a pleasure to hear from you! Ask us a question, or tell us what you love or hate about PythonAnywhere. We'll get back to you over email ASAP. Sorry, there was an error connecting to the server. Please try again in a few moments... www.pythonanywhere.com from http://ohdowon064.tistory.com/124 by ccl(A) rewrite - 2020-03-11 15:54:10

외래어 정리

외래어 정리 [A] acacia 아카시아 academic 아카데믹 academy 아카데미 acanthus 아칸서스 accelerator 액셀러레이터 accent 악센트 acceptor 억셉터 access 액세스 accessory 액세서리 accordion 아코디언 ace 에이스 acetate 아세테이트 acetaldehyde 아세트알데히드 acetic acid 아세트(산) acetone 아세톤 acetyl 아세틸 acetylene 아세틸렌 Achilles tendon 아킬레스(건) acre 에이커 acrylic acid 아크릴(산) action 액션 active 액티브 acyl 아실 AD 에이디 adagio 아다지오 adapter 어댑터 ad + balloon 애드벌룬 address 어드레스 adenine 아데닌 adrenaline 아드레날린 advantage 어드밴티지 aerobic dance 에어로빅 댄스 aerofoil 에어로포일 aerosol 에어로졸 afghan 아프간 [편물] after + service 애프터서비스 agape 아가페 Ainu 아이누 air conditioner 에어컨(디셔너) airspray 에어스프레이 album 앨범 albumin 알부민 alcohol 알코올 aldehyde 알데히드 ALGOL 알골 algorism 알고리즘 alibi 알리바이 alkali 알칼리 alkaloid 알칼로이드 Allah 알라 allegory 알레고리 allegretto 알레그레토 allegro 알레그로 alleluia 알렐루야 Allergie 알레르기 alligator 앨리게이터 all-in-one 올인원 almond 아몬드 aloha 'oe 알로하 오에 Alpenhorn 알펜호른 alpha 알파 alphabet 알파벳 ...