1. GCP 설정
- Compute Engine 활성화
- https://console.cloud.google.com/compute
- https:// cloud.google.com/compute/docs/?hl=ko (공식문서)
- Instance 5개 살리기
- OS : Ubuntu 16.04 LTS

유저는 SSH를 통해 Instance1에 접속하게 할것이며
나머지 Instance는 Instance1을 통해 접속하게 할것이다
- SSH 공개 키 등록 및 접속하기
- Instance에 Key 생성 및 Public Key 등록
- ssh-keygen -t rsa
- cat .ssh/id_rsa.pub을 통해 공개키 복사
- Instance 2~5에 public key만들기
- 설정을 모두 정상적으로 맞춰놨다면 Instance1을 통해 Instance2~5에 접속이 가능할것이다.
2. Kubespray 설치
Instance1 서버에서
- sudo apt update
- sudo apt -y install python-pip
- git clone https://github.com/kubernetes-sigs/kubespray.git
- cd kubespray -> cat rquirements.txt -> sudo pip install -r requirements.txt(ansible 및 다른 필요 패킷 설치)
3. Kubespray 설정
- 샘플 템플릿 복사해서 mycluster 만들기
- cp -rfp inventory/sample inventory/mycluster
- group_vars 는 클러스터 설치에 필요한 설정 내용이 있다
- all: 어느 환경에 어느 설정을 적용할지 설정
- etcd.yml: etcd설치에 필요한 상세 설정 내용
- k8s-cluster: 쿠버네티스 관련 설정
- inventory.ini 설치 대상 서버들의 정보를 설정한다 (아래 Code Block 참고)
- 쿠버네티스 클러스터 구성 명령어
- ansible-palybook -i inventory/mycluster/inventory.ini -v --become --become-user=root cluster.yml
- group_vars 는 클러스터 설치에 필요한 설정 내용이 있다
- cp -rfp inventory/sample inventory/mycluster
# Nodes to be
[all]
instance-1 ansible_ssh_host=10.128.0.2 ip=10.128.0.2 etcd_member_name=etcd1
instance-2 ansible_ssh_host=10.128.0.3 ip=10.128.0.3 etcd_member_name=etcd2
instance-3 ansible_ssh_host=10.128.0.4 ip=10.128.0.4 etcd_member_name=etcd3
instance-4 ansible_ssh_host=10.128.0.5 ip=10.128.0.5
instance-5 ansible_ssh_host=10.150.0.2 ip=10.150.0.2
# Master Node
[kube-master]
instance-1
instance-2
instance-3
# Etcd Node where Kube's Cluster Data will be saved
[etcd]
instance-1
instance-2
instance-3
# Worker Node
[kube-node]
instance-4
instance-5
[calico-rr]
# Node where Kube will be installed
# As a default, every node except etcd node will be assigned
[k8s-cluster:children]
kube-master
kube-node
calico-rr
모든 설치가 완료되었다면 Root로 들어가 노드정보를 한번 확인해 보자
- sudo -i
- kubectl get node
- 모든 Node의 STATUS가 Ready라면 준비 끝
NAME STATUS ROLES AGE VERSION
instance-1 Ready master 6m58s v1.18.3
instance-2 Ready master 6m12s v1.18.3
instance-3 Ready master 6m12s v1.18.3
instance-4 Ready <none> 5m13s v1.18.3
instance-5 Ready <none> 5m13s v1.18.3
'Infra > Kubernetes' 카테고리의 다른 글
3. 쿠버네티스 개념 (0) | 2020.06.05 |
---|---|
2. 쿠버네티스로 컨테이너 실행하기 (0) | 2020.06.04 |
4. 파드와 노드 (0) | 2020.05.24 |
3. Kubectl을 사용해서 디플로이먼트 생성하기 (0) | 2020.05.24 |
2. Minikube를 사용해서 클러스터 생성하기 (0) | 2020.05.21 |