728x90
목차
쿠버네티스 설치부터 서비스 배포까지 - 1.도커 설치
쿠버네티스 설치부터 서비스 배포까지 - 2.쿠버네티스 설치
쿠버네티스 설치부터 서비스 배포까지 - 2-1. 쿠버네티스 재설치
쿠버네티스 설치부터 서비스 배포까지 - 3.쿠버네티스 Ingress Nginx 생성
쿠버네티스 설치부터 서비스 배포까지 - 4.NFS 설치
쿠버네티스 설치부터 서비스 배포까지 - 5.데이터베이스 설정
쿠버네티스 설치부터 서비스 배포까지 - 6.프론트엔드 설정
쿠버네티스 설치부터 서비스 배포까지 - 7.백엔드 설정
쿠버네티스 설치부터 서비스 배포까지 - 8.결과화면
6.프론트엔드 설정
해당 파트 참고 URL
- https://docs.docker.com/engine/reference/builder/
- https://kubernetes.io/ko/docs/tasks/access-application-cluster/connecting-frontend-backend/
- https://ko.reactjs.org/tutorial/tutorial.html
프론트엔드는 제가 작성한 React Code를 사용했습니다.
돌아가게만 만든 것이기 때문에 퀄리티가 좋지 않긴 한데... 궁금하신 분은 https://github.com/kschoi93/k8s_frontend.git 확인하시면 될 것 같습니다
cd /home/kube
도커파일 생성
sudo vim Dockerfile-frontend
FROM ubuntu:20.04
EXPOSE 3000
RUN apt-get update \
&& apt-get install -y vim curl git
RUN curl -fsSL https://deb.nodesource.com/setup_16.x | bash -
RUN apt-get update \
&& apt-get install -y nodejs
WORKDIR /home
RUN git clone https://github.com/kschoi93/k8s_frontend.git
WORKDIR /home/k8s_frontend
RUN npm install
CMD ["npm","start"]
도커파일 이미지로 빌드
sudo docker build -t toy_frontend:1.0 -f Dockerfile-frontend .
이미지 생성 확인
docker images
쿠버네티스 service && deployment .yaml 파일 생성
sudo vim toy_frontend.yaml
apiVersion: v1
kind: Service
metadata:
name: frontend-service
spec:
selector:
app: toy
tier: frontend
type: NodePort
ports:
- protocol: TCP
port: 80
nodePort: 31001
targetPort: 3000
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: front-deployment
spec:
replicas: 1
selector:
matchLabels:
app: toy
tier: frontend
template:
metadata:
labels:
app: toy
tier: frontend
spec:
containers:
- name: toy
image: toy_frontend:1.0
ports:
- containerPort: 3000
쿠버네티스 deployment 생성
kubectl apply -f toy_frontend.yaml
쿠버네티스 파드 접속방법
kubectl exec -it front-deployment-5cc9cd6b67-kpnk5 -- bash
728x90
'Infrastructure > Docker & Kubernetes' 카테고리의 다른 글
쿠버네티스 설치부터 서비스 배포까지 - 8.결과화면 (0) | 2022.05.05 |
---|---|
쿠버네티스 설치부터 서비스 배포까지 - 7.백엔드 설정 (0) | 2022.05.05 |
쿠버네티스 설치부터 서비스 배포까지 - 5.데이터베이스 설정 (0) | 2022.05.05 |
쿠버네티스 설치부터 서비스 배포까지 - 4.NFS 설치 (0) | 2022.05.05 |
쿠버네티스 설치부터 서비스 배포까지 - 3.쿠버네티스 Ingress Nginx 생성 (0) | 2022.04.30 |