참조
1
https://kubernetes.io/ko/docs/tutorials/hello-minikube/
Hello Minikube
이 튜토리얼에서는 Minikube와 Katacoda를 이용하여 쿠버네티스에서 샘플 애플리케이션을 어떻게 실행하는지 살펴본다. Katacode는 무료로 브라우저에서 쿠버네티스 환경을 제공한다. 참고: 로컬에서
kubernetes.io
https://kubernetes.io/docs/concepts/workloads/controllers/deployment/
Deployments
A Deployment provides declarative updates for Pods and ReplicaSets. You describe a desired state in a Deployment, and the Deployment Controller changes the actual state to the desired state at a controlled rate. You can define Deployments to create new Rep
kubernetes.io
2
https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#port-forward
Kubectl Reference Docs
kubernetes.io
https://kubernetes.io/docs/tasks/access-application-cluster/service-access-application-cluster/
Use a Service to Access an Application in a Cluster
This page shows how to create a Kubernetes Service object that external clients can use to access an application running in a cluster. The Service provides load balancing for an application that has two running instances. Before you begin You need to have
kubernetes.io
1. 배포
마스터와 워커 머신 설치가 완료 되었다면 애플리케이션을 배포하여 보자
* 도커이미지를 통해 배포
* yaml( 배포 메타데이터 )파일을 통해 배포
위처럼 일반적인 방법 두가지 중 첫번째 방법인 도커 이미지를 통한 배포
# 쿠버네티스에서 제공해주는 공용이미지(테스트)로 배포 생성
kubectl create deployment hello-node --image=k8s.gcr.io/echoserver:1.4
# 배포, 레플리카셋, 파드 등 기본 구성이 생성된다
kubectl get deploy
kubectl get rs
kubectl get pod
# 2부 파드 네트워크 설치시 머신에 네트워크 인더페이스(터널)가 생성 되는데 파드 생성시 터널 대역대가 할당되어 서비스를 생성하지 않아도 해당 대역대로 어플리케이션에 접근이 가능하다
kubectl get pod -o wide
curl <주소>
2. 노출
# 포트 포워딩으로 외부 노출
# 파드를 외부에 노출 시키기 위해서는 일반적으로 서비스가 필요하지만 포트 포워딩으로도 노출이 가능하다
# 구글 클라우드에서 테스트중(머신=10.178.0.11, 외부=34.64.208.25) 수신포트는 미지정 시 자동 할당
kubectl port-forward --address < listen ip > pod/< pod name > < listen port >:< target port >
# 서비스 노드포트 타입으로 외부노출
# hello-node( k8s.gcr.io/echoserver:1.4 )로 테스트 할 경우 배포 구성에는 컨테이너포트가 명시되어 있지 않아 kubectl edit 통해 수정시 deploy sepc.containers.ports(경로) containerPort 추가 또는 서비스 노출 시 --port=<target port> 옵션을 지정
kubectl expose deploy < deploy name > --type=NodePort --port=8080(선택)
# 서비스 로드 밸랜서 타입으로 외부노출
# 위에서 edit로 포트 명시해줘서 포트는 생략
# 로드 밸랜서 타입을 선언해도 노드포트가 생성되기때문에 해당 공인 아이피와 노드포트(30173)로 외부에서 접근이 가능하다
# GKE 같은 쿠버네티스 서비스를 사용 시 EXTERNAL-IP 자동할당 받아 해당 포트(8080)로 외부 접근이 가능하다
kubectl expose deploy < deploy name > --type=Loadbalancer
기타
# 외부 아이피 수정
kubectl patch service <service name> -p '{"spec":{"externalIPs":[“< IP >"]}}'
'docker & kubernetes' 카테고리의 다른 글
kubernetes web/was 구성 (0) | 2021.06.29 |
---|---|
kubernetes deshboard 외부 접근 (0) | 2021.06.11 |
쿠버네티스 인그레스 설정 (0) | 2021.06.04 |
쿠버네티스 설치 및 설정 2부 (0) | 2021.05.11 |
쿠버네티스 설치 및 설정 1부 (0) | 2021.05.03 |