-
Notifications
You must be signed in to change notification settings - Fork 36
feat: 채윤희의 서비스 컨테이너 이미지 제작 #83
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
Conversation
Signed-off-by: yhchae <[email protected]>
Signed-off-by: yhchae <[email protected]>
Signed-off-by: yhchae <[email protected]>
Signed-off-by: yhchae <[email protected]>
Signed-off-by: yhchae <[email protected]>
Signed-off-by: yhchae <[email protected]>
| create-cluster: | ||
| k3d cluster create ${CLUSTER_NAME} --port "30080:30080@loadbalancer" | ||
| k3d image import ${APP_NAME}:latest -c ${CLUSTER_NAME} | ||
| docker exec k3d-${CLUSTER_NAME}-server-0 sh -c 'echo "nameserver 8.8.8.8" > /etc/resolv.conf' |
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.
(스크린 샷: k3s 초기 DNS 설정 문제로 인한 외부 도메인 접근 실패)
k3d를 이용해 띄운 k3s 컨테이너에서 DNS 이슈로 인해 Docker Hub 접근이 안 되어서, 쿠버네티스 시스템 이미지 다운로드가 실패했습니다. 그래서 우선 임시방편으로 아래와 같이 Google DNS(8.8.8.8)로 수정했습니다.
docker exec k3d-${CLUSTER_NAME}-server-0 sh -c 'echo "nameserver 8.8.8.8" > /etc/resolv.conf'혹시 이런 DNS 문제의 더 깔끔한 해결 방법이 있다면 조언 부탁드립니다! (@Jack-R-lantern)
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.
해당 부분은 혹시 나중에 같이 진행해봐야할것 같습니다 저도 k3d는 잘 쓰지 않아서요
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.
감사합니다! 제가 환경을 자세히 설명드리지 않았는데, colima로 VM을 띄운 뒤, 그 안에서 docker를 사용하고 있었습니다.
문제의 원인은 colima가 호스트의 네트워크 스택과 연결되도록, DNS를 Google DNS 대신 내부 IP로 설정했기 때문이며, docker도 이 설정을 따라간 것으로 추정하고 있습니다.
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.
전체적으로 잘 작성해주셨습니다.
label & selector 부분이 큰 문제는 없지만 여러 Deployment가 존재하는 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.
CGO_ENABLED Option에 대해서 알아보면 좋을것 같아요.
공유 라이브러리와 정적 라이브러리에 따라서 다양한 차이가 존재하거든요.
해당 내용에 대해 학습하게 되면 정리해서 오프라인 미팅떄 다른 멘티분들 앞에서 짧게 공유하는 시간 가졌으면 좋겠습니다.
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.
좋은 제안 감사합니다!
덕분에 이전에는 놓쳤을 Go 빌드 동작에 대해 더 잘 이해할 수 있었습니다.
참고용으로 조사해본 내용은 다음과 같습니다.
- CGO_ENABLED 옵션이 1이면 Go는 C 코드나 C 라이브러리를 사용할 수 있습니다.
이때 Go 컴파일러는 시스템의 링커를 호출해 C 라이브러리들을 연결합니다. - 대부분의 Linux 배포판은 공유 라이브러리를 제공하므로, 특별히 정적 링크 옵션을 주지 않으면 실행 파일은 공유 라이브러리에 동적 링크됩니다.
따라서 scratch라는 빈 베이스 이미지에서 실행 가능하려면, CGO_ENABLED 옵션이 0이거나, 1일 때 정적 링크 옵션을 줘서 빌드 해야하는 것으로 이해했습니다.
| create-cluster: | ||
| k3d cluster create ${CLUSTER_NAME} --port "30080:30080@loadbalancer" | ||
| k3d image import ${APP_NAME}:latest -c ${CLUSTER_NAME} | ||
| docker exec k3d-${CLUSTER_NAME}-server-0 sh -c 'echo "nameserver 8.8.8.8" > /etc/resolv.conf' |
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.
해당 부분은 혹시 나중에 같이 진행해봐야할것 같습니다 저도 k3d는 잘 쓰지 않아서요
| - containerPort: {{ .Values.service.targetPort }} # 문서화용 데이터 | ||
| # List of ports to expose from the container. | ||
| # Not specifying a port here DOES NOT prevent that port from being exposed. |
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.
해당 containerPort는 values.service.targetport를 주입받고 있습니다.
즉 해당 값이 변경되면 Pod안의 컨테이너에서도 자연스럽게 env PORT 값을 변경해 주입해줘야합니다.
이와 관련된 부분을 추가하면 좋을것 같습니다.
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.
containers.env가 ports.containerPort와 동일하게, values.service.targetPort를 사용하도록 수정했습니다. (345b178)
Signed-off-by: yhchae <[email protected]>
Signed-off-by: yhchae <[email protected]>
Signed-off-by: yhchae <[email protected]>
|
리뷰 감사합니다. 말씀해주신 내용 반영했습니다. 혹시 부족한 점이 있으면 말씀 부탁드립니다! |
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
Description
웹서비스를 컨테이너화하고 Kubernetes 배포를 위한 Helm Chart를 작성했습니다. (resolve #77)