[Docker] E04.gcloud install
2021-09-11 # docker

gcloud 설치


GKE의 쿠버네티스 클러스터를 명령어로 손쉽게 생성하고 삭제할 수 있는 gcloud를 설치하려합니다.


윈도우 환경에서 아래와 같은 명령어를 통해 간편하게 설치해보려 했습니다.


1
$ curl https://sdk.cloud.google.com | bash

그러나, 다음과 같은 과정에서 입력이 아예 되질 않았습니다.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Installing Google Cloud SDK...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed

100 421 0 421 0 0 6353 0 --:--:-- --:--:-- --:--:-- 9790
Downloading Google Cloud SDK install script: https://dl.google.com/dl/cloudsdk/channels/rapid/install_google_cloud_sdk.bash

######################################################################## 100.0%
Running install script from: /tmp/tmp.6sVKRinztG/install_google_cloud_sdk.bash
which curl
curl -# -f https://dl.google.com/dl/cloudsdk/channels/rapid/google-cloud-sdk.tar.gz

######################################################################## 100.0%


Installation directory (this will create a google-cloud-sdk subdirectory) (/home/ubuntu/My-Repository):

다음과 같은 링크에서 해결방법이 환경변수에 CLOUDSDK_CORE_DISABLE_PROMPTS1로 세팅하라는 답변이 있었지만 저는 해결되지 않았습니다.


따라서, google cloud sdk 설치 프로그램을 사용했습니다.


1
2
3
(New-Object Net.WebClient).DownloadFile("https://dl.google.com/dl/cloudsdk/channels/rapid/GoogleCloudSDKInstaller.exe", "$env:Temp\GoogleCloudSDKInstaller.exe")

& $env:Temp\GoogleCloudSDKInstaller.exe

위와같은 명령어를 PowerShell에 입력하고 default값으로 설치할 경우 다음과 같이 cmd창이 뜹니다.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
---
Welcome! This command will take you through the configuration of gcloud.

Your current configuration has been set to: [default]

You can skip diagnostics next time by using the following flag:
gcloud init --skip-diagnostics

Network diagnostic detects and fixes local network connection issues.
Checking network connection...done.
Reachability Check passed.
Network diagnostic passed (1/1 checks passed).

You must log in to continue. Would you like to log in (Y/n)? y

y를 입력하면 구글 로그인 홈페이지로 포워딩되며 로그인시 잘 작동합니다.


1
2
3
4
5
6
7
You are logged in as: [csj7480@hanyang.ac.kr].

Pick cloud project to use:
[1] concrete-kayak-325508
[2] Create a new project
Please enter numeric choice or text value (must exactly match list
item): 1

기존의 GKE와 연동하고


1
Do you want to configure a default Compute Region and Zone? (Y/n)?  y

사용할 리전을 GKE 클러스터의 default인 us-central1-c를 선택했습니다.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
If you do not specify a zone via a command line flag while working
with Compute Engine resources, the default is assumed.
[1] us-east1-b
[2] us-east1-c
[3] us-east1-d
[4] us-east4-c
[5] us-east4-b
[6] us-east4-a
[7] us-central1-c
[8] us-central1-a
...

Did not print [36] options.
Too many options [86]. Enter "list" at prompt to print choices fully.
Please enter numeric choice or text value (must exactly match list
item): 7

gcloud container clusters list를 입력하여 연동됐는지 확인해봅니다.


1
2
3
C:\Program Files (x86)\Google\Cloud SDK>gcloud container clusters list
NAME LOCATION MASTER_VERSION MASTER_IP MACHINE_TYPE NODE_VERSION NUM_NODES STATUS
cluster-1 us-central1-c 1.20.9-gke.701 XX.XX.XXX.XXX e2-medium 1.20.9-gke.701 3 RUNNING

다음의 명령어를 통해 클러스터 접근 정보를 가져옵니다.


1
C:\Program Files (x86)\Google\Cloud SDK>gcloud container clusters get-credentials cluster-1 --zone us-central1-c

연동되었는지 확인해봅니다.


1
C:\Program Files (x86)\Google\Cloud SDK>kubectl get nodes

잘되네용!


1
2
3
4
NAME                                       STATUS   ROLES    AGE   VERSION
gke-cluster-1-default-pool-f5da48ba-3c1b Ready <none> 21h v1.20.9-gke.701
gke-cluster-1-default-pool-f5da48ba-l4vf Ready <none> 21h v1.20.9-gke.701
gke-cluster-1-default-pool-f5da48ba-qnh7 Ready <none> 21h v1.20.9-gke.701

Reference


시작하세요! 도커/쿠버네티스