- 실습 간 슬랙을 활용합니다.
- 가입링크 : http://34.94.33.120/ 를 클릭하여 이메일을 기재하시면 초대메일이 발송됩니다.
- 슬랙 주소 : https://peanut-butter-group.slack.com
- Channels >
#k8s-the-hard-way채널 조인
- 참석 전에 반드시, 쿠버네티스 클러스터를 설치할 VM을 미리 구성해주시기 바랍니다.
- 이하 절차 수행
- 문의 사항은 슬랙에 올려주세요.
- 사이트 가입 : https://console.cloud.google.com/
- 필요 사항 : 해외 결제 가능한 신용 카드 등록
- 본 가이드는 1년간 무료로 주어지는 $300 크래딧 내에서 진행합니다.
- AWS에서 VM을 띄우셔도 상관없습니다. 단 방화벽 작업은 이하 내용을 참고하여 해제해주세요.
- Select a project > New Project
Project name기입 후CREATE버튼 클릭Cloud Shell버튼 클릭하여 이하 진행 (https://cloud.google.com/shell/)- 프로젝트ID 확인 (기입한 프로젝트명과 다를 수 있음)
- 프로젝트ID 변수화
PROJECT_ID="프로젝트ID"- 리전 설정 및 GCP API 활성화
{
gcloud config set project ${PROJECT_ID}
gcloud config set compute/region us-west2
gcloud config set compute/zone us-west2-c
gcloud services enable compute.googleapis.com
}- config-update.sh
mkdir setup
cd setup
vi config-update.shPROJECT_ID="프로젝트ID"
gcloud config set project ${PROJECT_ID}
gcloud config set compute/region us-west2
gcloud config set compute/zone us-west2-c저장후
chmod +x config-update.sh
{
gcloud compute networks create kubernetes-the-hard-way --subnet-mode custom
gcloud compute networks subnets create kubernetes \
--network kubernetes-the-hard-way \
--range 10.240.0.0/24
gcloud compute firewall-rules create kubernetes-the-hard-way-allow-internal \
--allow tcp,udp,icmp \
--network kubernetes-the-hard-way \
--source-ranges 10.240.0.0/24,10.200.0.0/16
gcloud compute firewall-rules create kubernetes-the-hard-way-allow-external \
--allow tcp:22,tcp:6443,icmp \
--network kubernetes-the-hard-way \
--source-ranges 0.0.0.0/0
}gcloud compute firewall-rules list --filter="network:kubernetes-the-hard-way"for i in 0 1; do
gcloud compute instances create controller-${i} \
--async \
--boot-disk-size 10GB \
--can-ip-forward \
--image-family ubuntu-1804-lts \
--image-project ubuntu-os-cloud \
--machine-type n1-standard-1 \
--private-network-ip 10.240.0.1${i} \
--scopes compute-rw,storage-ro,service-management,service-control,logging-write,monitoring \
--subnet kubernetes \
--tags kubernetes-the-hard-way,controller
donefor i in 0 1; do
gcloud compute instances create worker-${i} \
--async \
--boot-disk-size 10GB \
--can-ip-forward \
--image-family ubuntu-1804-lts \
--image-project ubuntu-os-cloud \
--machine-type n1-standard-1 \
--metadata pod-cidr=10.200.${i}.0/24 \
--private-network-ip 10.240.0.2${i} \
--scopes compute-rw,storage-ro,service-management,service-control,logging-write,monitoring \
--subnet kubernetes \
--tags kubernetes-the-hard-way,worker
done- VM 생성
gcloud compute instances create load-balancer \
--async \
--boot-disk-size 10GB \
--can-ip-forward \
--image-family ubuntu-1804-lts \
--image-project ubuntu-os-cloud \
--machine-type n1-standard-1 \
--private-network-ip 10.240.0.30 \
--scopes compute-rw,storage-ro,service-management,service-control,logging-write,monitoring \
--subnet kubernetes \
--tags kubernetes-the-hard-way,load-balancer- 정적 Public IP 생성
gcloud compute addresses create kubernetes-the-hard-way \
--region $(gcloud config get-value compute/region)- IP 확인
gcloud compute addresses list --filter="name=('kubernetes-the-hard-way')"- 정적 IP를 로드밸런서 VM에 붙이기
gcloud compute instances delete-access-config load-balancer --access-config-name "external-nat"
gcloud compute instances add-access-config load-balancer --access-config-name "external-nat" --address [바로위에 확인된 IP 기입]gcloud compute instances list- start.sh
for instance in controller-0 controller-1 load-balancer worker-0 worker-1 ; do
gcloud compute instances start ${instance}
done- stop.sh
for instance in controller-0 controller-1 load-balancer worker-0 worker-1 ; do
gcloud compute instances stop ${instance}
done- init.sh
gcloud config set project {프로젝트명}
gcloud config set compute/region us-west2
gcloud config set compute/zone us-west2-c
wget -q --show-progress --https-only --timestamping \
https://pkg.cfssl.org/R1.2/cfssl_linux-amd64 \
https://pkg.cfssl.org/R1.2/cfssljson_linux-amd64
chmod +x cfssl_linux-amd64 cfssljson_linux-amd64
sudo mv cfssl_linux-amd64 /usr/local/bin/cfssl
sudo mv cfssljson_linux-amd64 /usr/local/bin/cfssljson
./start.sh- CLEAN UP
- 방법1
for instance in controller-0 controller-1 load-balancer worker-0 worker-1 ; do
gcloud compute instances delete ${instance}
donegcloud compute addresses delete kubernetes-the-hard-way \
--region $(gcloud config get-value compute/region)- 방법2 : 콘솔에서 프로젝트를 delete 하면 생성한 자원들이 모두 삭제됩니다.