본문 바로가기

쿠버네티스

백엔드(Spring Boot) 서버 3개 띄워보기

728x90
반응형

 

앞서 만들어 두었던 spring 프로젝트가 있다.

 

그것을 열어서 manifest 파일을 연다. 그러면 아래와 같은 것일텐데 

apiVersion: v1
kind: Pod

metadata:
  name: spring-pod-1

spec:
  containers:
    - name: spring-container
      image: spring-server:latest
      ports:
        - containerPort: 8080
      imagePullPolicy: IfNotPresent

 

위에 것 아래와 같이 바꿔준다

apiVersion: v1
kind: Pod

metadata:
  name: spring-pod-1

spec:
  containers:
    - name: spring-container
      image: spring-server:latest
      ports:
        - containerPort: 8080
      imagePullPolicy: IfNotPresent

---
apiVersion: v1
kind: Pod

metadata:
  name: spring-pod-2

spec:
  containers:
    - name: spring-container
      image: spring-server:latest
      ports:
        - containerPort: 8080
      imagePullPolicy: IfNotPresent

---
apiVersion: v1
kind: Pod

metadata:
  name: spring-pod-3

spec:
  containers:
    - name: spring-container
      image: spring-server:latest
      ports:
        - containerPort: 8080
      imagePullPolicy: IfNotPresent

 

위와 같이 작성 후

kubectl apply -f spring-pod.yaml

 

을 터미널에 입력해준다.

 

그럼 

이렇게 뜬다.

 

1개의 파드는 1개의 프로그램을 실행시키는 단위라고 보면 된다.

 

잘 되었는지 알기 위해

 

kubectl get pods

 

입력해주면

스프링 서버가 3개 띄워져 있음을 알게 된다.

728x90
반응형