Nexus Helm 설치
+ cert-manager로 https 적용
+ private docker repo 생성
+ private helm repo 생성
※ yaml파일 등의 소스코드는 https://github.com/choisungwook/portfolio/wiki/nexus에서 볼 수 있습니다.
Nexus helm 설치
 준비
▪ 쿠버네티스 설치와 클러스터 구성
▪ helm3 설치
▪ cert-manager 설치와 사용방법 이해
▪ https://youtu.be/jkAlpv4WAUg 참고
▪ 외부 도메인/네임서버
▪ 실습에서는 네임서버를 cloudflare사용
▪ 동적 프로비저닝 활성화
 설치 - cert manager 설정
▪ namespace 생성
apiVersion: v1
kind: Secret
metadata:
name: cloudflare-api-token-secret
namespace: nexus
type: Opaque
stringData:
api-token: <your-token>
▪ cert-manager 네임서버 access-token 생성
kubectl create ns nexus
kubectl apply -f token.yaml
 설치 - cert manager 설정
▪ cert-manager issuer생성
apiVersion: cert-manager.io/v1
kind: Issuer
metadata:
name: nexus-prodissuser
namespace: nexus
spec:
acme:
# The ACME server URL
server: https://acme-v02.api.letsencrypt.org/directory
# Email address used for ACME registration
email: <your email>
# Name of a secret used to store the ACME account private key
privateKeySecretRef:
name: nexus-prodissuser
# Enable the challenge provider
solvers:
- dns01:
cloudflare:
email: <your email>
apiTokenSecretRef:
name: cloudflare-api-token-secret #cloudflare api token
key: api-token
kubectl apply -f issuer.yaml
 설치 - cert manager 설정
▪ 네임서버 dns설정
 nexus helm 설치
▪ helm 저장소 추가
helm repo add sonatype https://sonatype.github.io/helm3-charts/
helm repo update
▪ override_values.yaml 파일생성
nexus:
docker:
enabled: true
registries:
- port: 5000
host: docker.choilab.xyz
secretName: docker-tls
ingress:
enabled: true
annotations:
kubernetes.io/ingress.class: nginx
cert-manager.io/issuer: "nexus-prodissuser"
nginx.ingress.kubernetes.io/proxy-body-size: "0"
hostPath: /
# nexus domain
hostRepo: nexus.choilab.xyz
tls:
- hosts:
- docker.choilab.xyz
secretName: docker-tls
- hosts:
- nexus.choilab.xyz
secretName: nexus-tls
 nexus helm 설치
▪ 설치
helm install -n nexus nexus -f override_values.yaml sonatype/nexus-repository-manager
▪ 인증서 발급 확인
설치 확인
 설치확인 - 대시보드 접속
▪ 웹페이지 방문과 http적용 확인
 설치확인 - 대시보드 접속
▪ 관리자 비밀번호 변경
▪ 첫 로그인 시 자동비밀번호 변경 창으로 이동
private docker repo
 private docker repo
▪ docker hosted repo 생성
①
②
① 설정버튼 클릭
② repositories 메뉴 클릭
③ docker hosted 클릭
③
 private docker repo
▪ docker hosted repo 생성
① repo 이름을 docker로 설정
② http 포트 설정
• nginx ingres가 https 통신중계
①
②
 private docker repo
▪ login 테스트
 private docker repo
▪ docker push 테스트
▪ nginx:latest 이미지 다운로드
▪ docker tag로 이미지 복사
# docker tag nginx:latest docker.choilab.xyz/nginx:latest
 private docker repo
▪ docker push 테스트
▪ docker push
docker tag nginx:latest docker.choilab.xyz/nginx:latest
 private docker repo
▪ docker push 테스트
▪ nexus 확인
helm repo 생성
 private helm repo 생성
▪ hosted유형 helm repo 추가
 private helm repo 생성
▪ 이름입력
 helm 저장소 생성
▪ helm repo 추가
helm repo add nexus (옵션: --insecure-skip-tls)<your helm repo url> --username admin --password password1234
※ nexus helm 공식문서: https://help.sonatype.com/repomanager3/formats/helm-repositories
 helm 저장소 생성
▪ helm repo 추가 예제
▪ helm repo 추가 확인
테스트용 nginx helm 패키지 생성
 helm 패키지 생성
▪ nginx helm 패키지 생성
helm create nginxdemo
①
②
③
① chart 명세
② yaml파일과 helm관리파일(_helpers.tpl, NOTES.txt, tests디렉터리)
③ template 관리
 helm 패키지 생성
▪ nginx-test helm 패키지 생성
▪ tgz파일이 생성됨
helm create nginxdemo
helm 패키지 push
 helm 패키지 업로드
▪ nexus 관리자 계정과 비밀번호를 환경변수로 초기화
curl -F file=@nginxdemo-0.1.0.tgz 
-u $nexus_user:$nexus_password 
https://nexus.choilab.xyz/service/rest/v1/components?repository=custom-helm1
① 업로드할 helm 패키지 경로
② nexus admin 계정과 비밀번호
③ nexus api 주소
①
③
②
nexus_user=admin
nexus_password=<your_password>
▪ nexus api를 이용하여 helm 패키지 push
※ nexus helm 공식문서: https://help.sonatype.com/repomanager3/formats/helm-repositories
 helm 패키지 업로드
▪ nexus 웹 대시보드에서 helm 패키지가 업로드되었는지 확인
helm 패키지를 이용한 서비스 배포
 helm 패키지를 이용한 서비스 배포
▪ helm 저장소 업데이트
helm search repo nginxdemo
helm repo update
▪ helm 패키지 검색
 helm 패키지를 이용한 서비스 배포
▪ 업로드한 helm package를 이용하여 nginx 설치
helm install -n test --create-namespace nginx nexus/nginxdemo
 helm 패키지를 이용한 서비스 배포
▪ helm upgrade를 이용하여 서비스 유형을 nodeport로 변경
helm upgrade -n test --create-namespace nginx --set service.type=NodePort nexus/nginxdemo
▪ 서비스 유형이 nodeport로 변경되었는지 확인
 helm 패키지를 이용한 서비스 배포
▪ nginx default index.html가 뜨는지 확인
 helm 패키지를 이용한 서비스 배포
▪ helm 삭제
helm uninstall -n test nginx
kubectl create delete ns test
springboot helm package 생성
 springboot helm package
▪ helm 패키지 템플릿 생성
helm create springboot
▪ 편집을 편하게 하기 위한 vscode ssh 원격접속
▪ ctrl + shift + p > Remote-SSH: Add New SSh Host
 springboot helm package
▪ 편집을 편하게 하기 위한 vscode ssh 원격접속
▪ extension 설치
 springboot helm package
▪ 편집을 편하게 하기 위한 vscode ssh 원격접속
▪ ctrl + shift + p > Remote-SSH: Add New SSh Host
 springboot helm package
▪ 편집을 편하게 하기 위한 vscode ssh 원격접속
▪ ctrl + shift + p > Remote-SSH: Add New SSh Host
 springboot helm package
▪ 편집을 편하게 하기 위한 vscode ssh 원격접속
▪ <계정>@<IP>
▪ ssh연결정보 저장
 springboot helm package
▪ 편집을 편하게 하기 위한 vscode ssh 원격접속
▪ ctrl + shift + p > Connect to Host
 springboot helm package
▪ 편집을 편하게 하기 위한 vscode ssh 원격접속
▪ Open Folder > springboot helm 패키지 디렉터리경로 선택
 springboot helm package
▪ 편집을 편하게 하기 위한 vscode ssh 원격접속
▪ 연결 성공 > vscode로 원격 편집
 springboot helm package
▪ git history를 참고하여 helm 패키지 수정
▪ history 주소: https://github.com/choisungwook/portfolio/commits/master/kubernetes/helm/custom-springboot
▪ 이미지이름/tag, port, liveness 수정
 springboot helm package
▪ helm 패키지 생성
helm package springboot
▪ helm 패키지를 nexus helm repo에 push
curl -F file=@springboot-0.1.0.tgz 
-u $nexus_user:$nexus_password 
https://nexus.choilab.xyz/service/rest/v1/components?repository=custom-helm1
 springboot helm package
▪ helm repo 업데이트
helm repo update
▪ helm install 실행
helm install -n test --create-namespace --set service.type=NodePort springboot-demo nexus/springboot
 springboot helm package
▪ pod 상태 확인
▪ 웹페이지 접속

nexus helm 설치, docker/helm repo 설정과 예제

  • 1.
    Nexus Helm 설치 +cert-manager로 https 적용 + private docker repo 생성 + private helm repo 생성 ※ yaml파일 등의 소스코드는 https://github.com/choisungwook/portfolio/wiki/nexus에서 볼 수 있습니다.
  • 2.
  • 3.
     준비 ▪ 쿠버네티스설치와 클러스터 구성 ▪ helm3 설치 ▪ cert-manager 설치와 사용방법 이해 ▪ https://youtu.be/jkAlpv4WAUg 참고 ▪ 외부 도메인/네임서버 ▪ 실습에서는 네임서버를 cloudflare사용 ▪ 동적 프로비저닝 활성화
  • 4.
     설치 -cert manager 설정 ▪ namespace 생성 apiVersion: v1 kind: Secret metadata: name: cloudflare-api-token-secret namespace: nexus type: Opaque stringData: api-token: <your-token> ▪ cert-manager 네임서버 access-token 생성 kubectl create ns nexus kubectl apply -f token.yaml
  • 5.
     설치 -cert manager 설정 ▪ cert-manager issuer생성 apiVersion: cert-manager.io/v1 kind: Issuer metadata: name: nexus-prodissuser namespace: nexus spec: acme: # The ACME server URL server: https://acme-v02.api.letsencrypt.org/directory # Email address used for ACME registration email: <your email> # Name of a secret used to store the ACME account private key privateKeySecretRef: name: nexus-prodissuser # Enable the challenge provider solvers: - dns01: cloudflare: email: <your email> apiTokenSecretRef: name: cloudflare-api-token-secret #cloudflare api token key: api-token kubectl apply -f issuer.yaml
  • 6.
     설치 -cert manager 설정 ▪ 네임서버 dns설정
  • 7.
     nexus helm설치 ▪ helm 저장소 추가 helm repo add sonatype https://sonatype.github.io/helm3-charts/ helm repo update ▪ override_values.yaml 파일생성 nexus: docker: enabled: true registries: - port: 5000 host: docker.choilab.xyz secretName: docker-tls ingress: enabled: true annotations: kubernetes.io/ingress.class: nginx cert-manager.io/issuer: "nexus-prodissuser" nginx.ingress.kubernetes.io/proxy-body-size: "0" hostPath: / # nexus domain hostRepo: nexus.choilab.xyz tls: - hosts: - docker.choilab.xyz secretName: docker-tls - hosts: - nexus.choilab.xyz secretName: nexus-tls
  • 8.
     nexus helm설치 ▪ 설치 helm install -n nexus nexus -f override_values.yaml sonatype/nexus-repository-manager ▪ 인증서 발급 확인
  • 9.
  • 10.
     설치확인 -대시보드 접속 ▪ 웹페이지 방문과 http적용 확인
  • 11.
     설치확인 -대시보드 접속 ▪ 관리자 비밀번호 변경 ▪ 첫 로그인 시 자동비밀번호 변경 창으로 이동
  • 12.
  • 13.
     private dockerrepo ▪ docker hosted repo 생성 ① ② ① 설정버튼 클릭 ② repositories 메뉴 클릭 ③ docker hosted 클릭 ③
  • 14.
     private dockerrepo ▪ docker hosted repo 생성 ① repo 이름을 docker로 설정 ② http 포트 설정 • nginx ingres가 https 통신중계 ① ②
  • 15.
     private dockerrepo ▪ login 테스트
  • 16.
     private dockerrepo ▪ docker push 테스트 ▪ nginx:latest 이미지 다운로드 ▪ docker tag로 이미지 복사 # docker tag nginx:latest docker.choilab.xyz/nginx:latest
  • 17.
     private dockerrepo ▪ docker push 테스트 ▪ docker push docker tag nginx:latest docker.choilab.xyz/nginx:latest
  • 18.
     private dockerrepo ▪ docker push 테스트 ▪ nexus 확인
  • 19.
  • 20.
     private helmrepo 생성 ▪ hosted유형 helm repo 추가
  • 21.
     private helmrepo 생성 ▪ 이름입력
  • 22.
     helm 저장소생성 ▪ helm repo 추가 helm repo add nexus (옵션: --insecure-skip-tls)<your helm repo url> --username admin --password password1234 ※ nexus helm 공식문서: https://help.sonatype.com/repomanager3/formats/helm-repositories
  • 23.
     helm 저장소생성 ▪ helm repo 추가 예제 ▪ helm repo 추가 확인
  • 24.
    테스트용 nginx helm패키지 생성
  • 25.
     helm 패키지생성 ▪ nginx helm 패키지 생성 helm create nginxdemo ① ② ③ ① chart 명세 ② yaml파일과 helm관리파일(_helpers.tpl, NOTES.txt, tests디렉터리) ③ template 관리
  • 26.
     helm 패키지생성 ▪ nginx-test helm 패키지 생성 ▪ tgz파일이 생성됨 helm create nginxdemo
  • 27.
  • 28.
     helm 패키지업로드 ▪ nexus 관리자 계정과 비밀번호를 환경변수로 초기화 curl -F file=@nginxdemo-0.1.0.tgz -u $nexus_user:$nexus_password https://nexus.choilab.xyz/service/rest/v1/components?repository=custom-helm1 ① 업로드할 helm 패키지 경로 ② nexus admin 계정과 비밀번호 ③ nexus api 주소 ① ③ ② nexus_user=admin nexus_password=<your_password> ▪ nexus api를 이용하여 helm 패키지 push ※ nexus helm 공식문서: https://help.sonatype.com/repomanager3/formats/helm-repositories
  • 29.
     helm 패키지업로드 ▪ nexus 웹 대시보드에서 helm 패키지가 업로드되었는지 확인
  • 30.
  • 31.
     helm 패키지를이용한 서비스 배포 ▪ helm 저장소 업데이트 helm search repo nginxdemo helm repo update ▪ helm 패키지 검색
  • 32.
     helm 패키지를이용한 서비스 배포 ▪ 업로드한 helm package를 이용하여 nginx 설치 helm install -n test --create-namespace nginx nexus/nginxdemo
  • 33.
     helm 패키지를이용한 서비스 배포 ▪ helm upgrade를 이용하여 서비스 유형을 nodeport로 변경 helm upgrade -n test --create-namespace nginx --set service.type=NodePort nexus/nginxdemo ▪ 서비스 유형이 nodeport로 변경되었는지 확인
  • 34.
     helm 패키지를이용한 서비스 배포 ▪ nginx default index.html가 뜨는지 확인
  • 35.
     helm 패키지를이용한 서비스 배포 ▪ helm 삭제 helm uninstall -n test nginx kubectl create delete ns test
  • 36.
  • 37.
     springboot helmpackage ▪ helm 패키지 템플릿 생성 helm create springboot ▪ 편집을 편하게 하기 위한 vscode ssh 원격접속 ▪ ctrl + shift + p > Remote-SSH: Add New SSh Host
  • 38.
     springboot helmpackage ▪ 편집을 편하게 하기 위한 vscode ssh 원격접속 ▪ extension 설치
  • 39.
     springboot helmpackage ▪ 편집을 편하게 하기 위한 vscode ssh 원격접속 ▪ ctrl + shift + p > Remote-SSH: Add New SSh Host
  • 40.
     springboot helmpackage ▪ 편집을 편하게 하기 위한 vscode ssh 원격접속 ▪ ctrl + shift + p > Remote-SSH: Add New SSh Host
  • 41.
     springboot helmpackage ▪ 편집을 편하게 하기 위한 vscode ssh 원격접속 ▪ <계정>@<IP> ▪ ssh연결정보 저장
  • 42.
     springboot helmpackage ▪ 편집을 편하게 하기 위한 vscode ssh 원격접속 ▪ ctrl + shift + p > Connect to Host
  • 43.
     springboot helmpackage ▪ 편집을 편하게 하기 위한 vscode ssh 원격접속 ▪ Open Folder > springboot helm 패키지 디렉터리경로 선택
  • 44.
     springboot helmpackage ▪ 편집을 편하게 하기 위한 vscode ssh 원격접속 ▪ 연결 성공 > vscode로 원격 편집
  • 45.
     springboot helmpackage ▪ git history를 참고하여 helm 패키지 수정 ▪ history 주소: https://github.com/choisungwook/portfolio/commits/master/kubernetes/helm/custom-springboot ▪ 이미지이름/tag, port, liveness 수정
  • 46.
     springboot helmpackage ▪ helm 패키지 생성 helm package springboot ▪ helm 패키지를 nexus helm repo에 push curl -F file=@springboot-0.1.0.tgz -u $nexus_user:$nexus_password https://nexus.choilab.xyz/service/rest/v1/components?repository=custom-helm1
  • 47.
     springboot helmpackage ▪ helm repo 업데이트 helm repo update ▪ helm install 실행 helm install -n test --create-namespace --set service.type=NodePort springboot-demo nexus/springboot
  • 48.
     springboot helmpackage ▪ pod 상태 확인 ▪ 웹페이지 접속