728x90

안녕하세요! Devfest Cloud Hero 세션에 오신 여러분 환영합니다.

이번 실습을 통해 Kubernetes를 경험해 보는 시간을 갖겠습니다.

 

리전 세팅하기

gcloud config set compute/zone us-central1-b

클러스터 생성하기

gcloud container clusters create io

 

Github 저장소 클론하기

gsutil cp -r gs://spls/gsp021/* .

디렉토리 변경하기

cd orchestrate-with-kubernetes/kubernetes

파일 확인하기

ls

디플로이먼트 만들기

kubectl create deployment nginx --image=nginx:1.10.0

파드 확인하기

kubectl get pods

컨테이너 외부로 노출하기

kubectl expose deployment nginx --port 80 --type LoadBalancer

서비스 확인하기

kubectl get services

 

파드 만들기

kubectl create –f pods/monolith.yaml

파드 확인하기

kubectl get pods

파드 내용 확인하기

kubectl describe pods monolith

 

두 번째 터미널 : 포트 포워딩 설정하기

kubectl port-forward monolith 10080:80

 

로그인 하기

curl -u user http://127.0.0.1:10080/login

토큰 인자 전달하기

TOKEN=$(curl http://127.0.0.1:10080/login -u user|jq -r '.token')

재확인

curl -H "Authorization: Bearer $TOKEN" 
http://127.0.0.1:10080/secure

모노리스 파드 로그 확인하기

kubectl logs monolith

로그 업데이트 확인하기

curl http://127.0.0.1:10080

모놀리스 파드에서 대화형 셸 실행하기

kubectl exec monolith --stdin --tty -c monolith /bin/sh

ping을 통해서 외부 통신 확인하기

ping -c 3 google.com

나가기

exit

 

파드 생성하기

cd ~/orchestrate-with-Kubernetes/kubernetes

서비스 구성 파일 확인하기

cat pods/secure-monolith.yaml

보안 구성된 모놀리식 파드와 구성 데이터 만들기

kubectl create secret generic tls-certs --from-file tls/
kubectl create configmap nginx-proxy-conf --from-file nginx/proxy.conf
kubectl create -f pods/secure-monolith.yaml

모놀리식 서비스 구성 파일로 서비스 생성하기

kubectl create –f services/monolith.yaml

NodePort 모놀리식 서비스로 트래픽 보내기

gcloud compute firewall-rules create allow-monolith-nodeport \
  --allow=tcp:31000

노드 1개의 외부 IP 주소 가져오기

gcloud compute instances list

명령어 수행하기

curl –k https://<External_IP>:31000

파드에 라벨 추가하기

kubectl get pods –l “app=monolith”
kubectl get pods –l “app=monolith, secure=enabled”
kubectl label pods secure-monolith 'secure=enabled'
kubectl get pods secure-monolith --show-labels

엔드포인트 목록 조회하기

kubectl describe services monolith | grep Endpoints

인스턴스 목록 불러오기

gcloud compute instances list

엔드포인트 테스트하기

curl -k https://<EXTERNAL_IP>:31000

 

디플로이먼트 객체 만들기

kubectl create –f deployments/auth.yaml

auth 서비스 만들기

kubectl create –f services/auth.yaml

hello 디플로이먼트 생성 / 서비스 생성

kubectl create -f deployments/hello.yaml
kubectl create -f services/hello.yaml

frontend 디플로이먼트 생성 / 서비스 생성

kubectl create configmap nginx-frontend-conf --from-file=nginx/frontend.conf
kubectl create -f deployments/frontend.yaml
kubectl create -f services/frontend.yaml

프론트엔드 서비스 가져오기

kubectl get services frontend

 

프론트 엔드 서비스 확인하기

curl –k https://<EXTERNAL-IP>

 

감사합니다.

728x90
반응형