Skip to content

Conversation

@jiwlee97
Copy link
Contributor

@jiwlee97 jiwlee97 commented Jul 23, 2025

close #65

기본 구조

  • 2025/helm/jiwlee97 디렉터리 생성
  • 최상단에 Dockerfile 위치
  • charts/ 디렉터리 생성

Dockerfile 및 웹서비스

  • Dockerfile 작성 및 이미지 빌드 성공 (docker build -t my-app .)
  • 웹서비스가 8080 포트에서 동작
  • PORT 환경변수로 포트 변경 가능하게 설정
  • docker run -d -p 30080:8080 my-app으로 정상 동작 확인
  • /api/v1/jiwlee97 API 구현
  • /healthcheck API 구현
  • (Optional) 도커 이미지 최적화 (참고)

Helm Chart 구성

  • /charts/Chart.yaml 작성 (apiVersion, name, version)
  • /charts/values.yaml 작성 (image.name) 포함
  • /charts/templates/deployment.yaml 작성
    • spec.containers[0].image"{{ .Values.image.name }}" 형태
    • label/selector 일치
  • /charts/templates/services.yaml 작성
    • type: NodePort
    • nodePort: 30080 설정
  • helm install my-app ./chartslocalhost:30080 에서 서비스 응답 확인

PR & 커밋

  • PR 제목과 커밋 메시지에 의미 있는 메시지 작성
  • 이슈와 PR 자동 연결
  • DCO 서명 커밋

@jiwlee97 jiwlee97 force-pushed the jiwlee97-first-helm-chart branch from 8b8f548 to d763dff Compare July 23, 2025 12:44
@jiwlee97 jiwlee97 marked this pull request as ready for review July 23, 2025 12:44
@jiwlee97 jiwlee97 requested a review from Jack-R-lantern as a code owner July 23, 2025 12:44
@jiwlee97 jiwlee97 marked this pull request as draft July 23, 2025 12:46
@jiwlee97 jiwlee97 force-pushed the jiwlee97-first-helm-chart branch from d763dff to 0e35790 Compare July 23, 2025 12:57
@jiwlee97 jiwlee97 marked this pull request as ready for review July 23, 2025 12:59
@jiwlee97
Copy link
Contributor Author

jiwlee97 commented Jul 23, 2025

@Jack-R-lantern values.yaml 파일에 image 외에 정의하면 좋을 값들이 더 있는지 궁금합니다

@Jack-R-lantern
Copy link
Member

Jack-R-lantern commented Jul 23, 2025

@Jack-R-lantern values.yaml 파일에 image 외에 정의하면 좋을 값들이 더 있는지 궁금합니다

kubernetes object간의 관계 매칭을 위해서

  1. labels, selector 부분의 값들을 values.yaml을 통해 주입할수 있어야합니다.
  2. 서비스를 배포하고 노출하는 과정에서 port에 대한 정보 역시 values.yaml을 통해 주입할수 있어야합니다.
  3. Service Object의 경우 .spec.type에 따라 필요한 속성이 달라지기에 이에 대한 대응이 가능한 구조여야합니다.

Helm Chart역시 values.yaml을 이용한 의존성 주입이라고 생각하고 chart를 만들면 좋을것 같습니다.

Copy link
Member

@Jack-R-lantern Jack-R-lantern left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

질문해주신 부분에 대해선 리뷰로 코멘트를 남기지 않았습니다.

질문에 대한 답변 기반으로 한번더 chart를 수정하고 그 다음에 리뷰 하도록 하겠습니다.

Comment on lines 1 to 12
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
Copy link
Member

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과 어떤 차이가 있는지 확인해보면 좋을것 같습니다.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

multi-stage build를 통해 생성된 이미지의 사이즈가 더 작은 것을 확인했습니다.
image

npm install의 경우 개발환경에서 주로 사용되며 package.json과 package-lock.json의 내용이 다를 경우 package.json을 우선시하여 필요한 경우 lock 파일을 업데이트하고 새로운 버전의 패키지를 설치할 수 있습니다.
npm ci의 경우 package-lock.json을 정확히 따라서 설치하기 때문에 항상 동일한 버전의 설치가 보장됩니다. 따라서 프로덕션/CI 환경에서는 npm ci 명령어를 사용하는게 적절하다는 것을 알 수 있었습니다 😀

Copy link
Member

@Jack-R-lantern Jack-R-lantern left a 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부분은 옵션이긴하지만 이미지 최적화를 진행해보면 좋을것 같아요.

Comment on lines 9 to 10
service: 8080 # Service 포트
nodePort: 30080 # 외부 접근 포트 (NodePort 타입일 때만 사용)
Copy link
Member

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 설정 부분으로 내려가는게 더 좋아보여요

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

service, nodePort의 위치를 service 설정 부분으로 변경했습니다

Comment on lines 1 to 2
labels: my-app
selector: my-app
Copy link
Member

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

Copy link
Contributor Author

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를 사용하도록 수정했습니다

Copy link
Member

@Jack-R-lantern Jack-R-lantern left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@Jack-R-lantern Jack-R-lantern left a 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

@jiwlee97 jiwlee97 force-pushed the jiwlee97-first-helm-chart branch from 5fe8982 to 757a353 Compare September 28, 2025 10:51
@jiwlee97
Copy link
Contributor Author

Please check gpg sign

I’ve signed the commit with GPG. Thanks!

@Jack-R-lantern Jack-R-lantern merged commit 7c0ce86 into Argo-OSS:main Sep 28, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: 이지원의 서비스 컨테이너 이미지 제작

2 participants