-
Notifications
You must be signed in to change notification settings - Fork 36
feat: 이지원의 서비스 컨테이너 이미지 제작 #78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: 이지원의 서비스 컨테이너 이미지 제작 #78
Conversation
8b8f548 to
d763dff
Compare
d763dff to
0e35790
Compare
|
@Jack-R-lantern values.yaml 파일에 image 외에 정의하면 좋을 값들이 더 있는지 궁금합니다 |
kubernetes object간의 관계 매칭을 위해서
Helm Chart역시 values.yaml을 이용한 의존성 주입이라고 생각하고 chart를 만들면 좋을것 같습니다. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
질문해주신 부분에 대해선 리뷰로 코멘트를 남기지 않았습니다.
질문에 대한 답변 기반으로 한번더 chart를 수정하고 그 다음에 리뷰 하도록 하겠습니다.
2025/helm/jiwlee97/Dockerfile
Outdated
| FROM node:18-alpine | ||
|
|
||
| WORKDIR /app | ||
| COPY ./app/ . | ||
|
|
||
| RUN npm install | ||
| RUN npx tsc | ||
|
|
||
| ENV PORT=8080 | ||
| EXPOSE 8080 | ||
|
|
||
| CMD ["node", "dist/main.js"] No newline at end of file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Docker의 Multi-stage build를 적용 해보는게 좋을것 같습니다.
현재 Dockerfile 기반 이미지 크기와 Multi-Stage Build를 통해 생성된 이미지의 사이즈를 비교해서 남겨주세요.
npm의 경우 CI를 위한 command를 제공하고 있습니다.
이와 관련해 npm install과 어떤 차이가 있는지 확인해보면 좋을것 같습니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
multi-stage build를 통해 생성된 이미지의 사이즈가 더 작은 것을 확인했습니다.

npm install의 경우 개발환경에서 주로 사용되며 package.json과 package-lock.json의 내용이 다를 경우 package.json을 우선시하여 필요한 경우 lock 파일을 업데이트하고 새로운 버전의 패키지를 설치할 수 있습니다.
npm ci의 경우 package-lock.json을 정확히 따라서 설치하기 때문에 항상 동일한 버전의 설치가 보장됩니다. 따라서 프로덕션/CI 환경에서는 npm ci 명령어를 사용하는게 적절하다는 것을 알 수 있었습니다 😀
2e23925 to
32f5994
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
네 전체적으로 다 잘 구현해주셨습니다.
근데 저의 잘못된 의미전달로 인해 한가지 수정이 발생하게 되었습니다. 죄송합니다 ㅠㅠ
commit history를 보면 '으로 인해 type 문제가 발생한적이 있기에 '로 작성한 부분들은 다 "로 통일하면 좋을것 같습니다.
Dockerfile부분은 옵션이긴하지만 이미지 최적화를 진행해보면 좋을것 같아요.
| service: 8080 # Service 포트 | ||
| nodePort: 30080 # 외부 접근 포트 (NodePort 타입일 때만 사용) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
해당 정보는 port 관점에서 보면 ports 아래에 위치해도 괜찮지만
kubernetes Object 관점에서 보면 Service Object에서 쓰이는 값이기에
현재 values.yaml 구조를 생각한다면 Service 설정 부분으로 내려가는게 더 좋아보여요
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
service, nodePort의 위치를 service 설정 부분으로 변경했습니다
| labels: my-app | ||
| selector: my-app |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
labels와 selector를 통해 주입할수 있어서 커스텀하게 쓸수있게 되었습니다.
다만 labels와 selector가 달라지는 경우 지금 구조에서는 deployment, service가 정상작동하지 않을 위험이 있습니다.
label, selector를 처리할때 다양한 방법이 있지만
tpl을 이용한 기본값을 통한 label과 selector의 관계를 정의하고
custom label만 추가하는 경우가 많습니다.
제가 의도했던 label, selector를 values.yaml을 통해 주입한다는
한개의 값으로 labels, selector를 동시에 변경이었는데 제가 의미를 잘못전달했네요 죄송합니다.
아래는 kubernetes의 label, selector의 동작방식인데 한번 참고해보면 좋을것 같습니다.
https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#label-selectors
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
좋은 피드백 감사합니다! _helpers.tpl를 사용해 labels와 selector 불일치 위험을 제거했습니다. myapp.selectorLabels 템플릿으로 deployment와 service가 항상 동일한 selector를 사용하도록 수정했습니다
Jack-R-lantern
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check gpg sign
Signed-off-by: jiwlee <[email protected]>
Signed-off-by: jiwlee <[email protected]>
Signed-off-by: jiwlee <[email protected]>
Signed-off-by: jiwlee <[email protected]>
Signed-off-by: jiwlee <[email protected]>
Signed-off-by: jiwlee <[email protected]>
Signed-off-by: jiwlee <[email protected]>
…plates Signed-off-by: jiwlee <[email protected]>
Signed-off-by: jiwlee <[email protected]>
Signed-off-by: jiwlee <[email protected]>
Signed-off-by: jiwlee <[email protected]>
5fe8982 to
757a353
Compare
I’ve signed the commit with GPG. Thanks! |
close #65
기본 구조
2025/helm/jiwlee97디렉터리 생성Dockerfile위치charts/디렉터리 생성Dockerfile 및 웹서비스
docker build -t my-app .)PORT환경변수로 포트 변경 가능하게 설정docker run -d -p 30080:8080 my-app으로 정상 동작 확인/api/v1/jiwlee97API 구현/healthcheckAPI 구현Helm Chart 구성
/charts/Chart.yaml작성 (apiVersion,name,version)/charts/values.yaml작성 (image.name) 포함/charts/templates/deployment.yaml작성spec.containers[0].image가"{{ .Values.image.name }}"형태/charts/templates/services.yaml작성type: NodePortnodePort: 30080설정helm install my-app ./charts후localhost:30080에서 서비스 응답 확인PR & 커밋