티스토리 뷰

728x90
반응형

앞선 포스팅에서는 Harbor Docker & Helm Repository를 구축하고 구성하는 방법과 Docker Repository로써 활용하기 위한 Docker Registry, Garbage Collection 그리고 취약점 분석 방법에 대해 살펴보았다. 이번 포스팅에서는 Harbor를 활용하여 Helm Chart를 관리하는 방법에 대해 알아보자.

 Harbor Helm Repository 

Harbor는 Helm Chart를 관리하는 Repository로써의 역할을 함께 담당하여 Docker Image와 Chart를 하나의 Project에 관리할 수 있도록 제공한다.

Helm Chart를 생성하는 과정은 다음 포스팅을 참고한다.

 

Helm3 Chart 커스터마이징 : https://waspro.tistory.com/628

 

Chart 생성이 완료되면, Chart를 관리하기 위한 Repository를 구축해야 하는데, 이때 Harbor를 활용할 수 있다.

먼저 현재 테스트에서 사용할 Helm Chart이다.

[root@ciserver test-helm-chart]# ls -la
total 12
drwxr-xr-x. 3 root root   79 Aug  2 09:34 .
drwxr-xr-x. 3 root root   29 Aug  2 09:36 ..
-rwxr-xr-x. 1 root root  342 Aug  2 09:21 .helmignore
-rwxr-xr-x. 1 root root  111 Aug  2 09:21 Chart.yaml
drwxr-xr-x. 3 root root  146 Aug  2 09:34 templates
-rwxr-xr-x. 1 root root 1513 Aug  2 09:21 values.yaml
[root@ciserver test-helm-chart]#

해당 Chart를 Helm Repository에 배포 후 이후 빌드 과정에서 참고할 수 있도록 관리할 예정이다.

 Chart 패키징 

먼저 Chart를 패키징하는 과정이다.

[root@ciserver helm]# ls
test-helm-chart
[root@ciserver helm]# helm package ./test-helm-chart/
Successfully packaged chart and saved it to: /root/helm/test-helm-chart-0.1.0.tgz
[root@ciserver helm]# ls -la
total 8
drwxr-xr-x.  3 root root   62 Aug  2 09:42 .
dr-xr-x---. 21 root root 4096 Aug  2 09:34 ..
drwxr-xr-x.  3 root root   79 Aug  2 09:34 test-helm-chart
-rw-r--r--.  1 root root 3260 Aug  2 09:42 test-helm-chart-0.1.0.tgz
[root@ciserver helm]#

다음과 같이 helm package 명령어로 손쉽게 chart를 패키징할 수 있다.

helm package [chart_path] --version [version]으로 세부버전을 명시할 수도 있다.

 Chart Push 

다음으로 Harbor에 Packaging한 Chart를 Push해 보도록 하자.

Helm으로 Harbor에 Chart를 Push하기 위해서는 chartmuseum이 제공하는 Plugin을 설치해야 push 명령어를 사용할 수 있다.

1) helm plugin install

[root@ciserver helm]# helm plugin install https://github.com/chartmuseum/helm-push
Downloading and installing helm-push v0.8.1 ...
https://github.com/chartmuseum/helm-push/releases/download/v0.8.1/helm-push_0.8.1_linux_amd64.tar.gz
Installed plugin: push
[root@ciserver helm]# 

위와 같이 helm plugin install [install_url]을 입력하면 손쉽게 plugin을 설치할 수 있다.

위는 helm push 명령어를 설치하는 과정이며, helm으로 chartmuseum 관련 다양한 plugin을 손쉽게 설치할 수 있다. chartmuseum의 대표적인 오픈소스 플러그인은 다음과 같다.

chartmuseum/helm-push - Helm plugin to push chart package to ChartMuseum
chartmuseum/storage - Go library providing common interface for working across multiple cloud storage backends
chartmuseum/auth - Go library for generating ChartMuseum JWT Tokens, authorizing HTTP requests, etc.
chartmuseum/auth-server-example - Example server providing JWT tokens for ChartMuseum auth
chartmuseum/testbed - Docker testbed for continuous integration
chartmuseum/www - chartmuseum.com static site source code
chartmuseum/ui - ChartMuseum frontend UI

 

다음과 같이 설치가 완료되면 helm push를 사용할 수 있다.

Helm Chart를 Push하는 과정은 두가지 Step으로 나뉘어져 있다.

먼저 Helm Repository를 추가해야 한다. Helm Repository는 Helm Chart를 관리하는 Harbor URL이 그 대상이 되며, 다음과 같은 형태로 url을 입력한다.

(helm repo add [REPOSITORY_NAME] --username admin --password [PASSWORD] http://[IP]:[PORT]/chartrepo/[PROJECT_NAME])

[root@ciserver helm]# helm repo add test-helm-chart --username admin --password [PASSWORD] http://192.168.56.100/chartrepo/docker-project          
"test-helm-chart" has been added to your repositories
[root@ciserver helm]# helm repo list
NAME            URL                                           
test-helm-chart http://192.168.56.100/chartrepo/docker-project
[root@ciserver helm]#

- helm repo add는 helm에서 관리할 repository를 추가하는 명령어이다.

- helm repo list는 helm repository를 확인하는 명령어이다.

위와 같이 repository 추가가 완료되면, packaging한 chart를 push한다. push 명령어는 다음과 같이 작성한다.

(helm push --username admin --password [PASSWORD] [CHART_PACKAGE_NAME] [REPOSITORY_NAME])

[root@ciserver helm]# helm push --username admin --password [PASSWORD] test-helm-chart-0.1.0.tgz test-helm-chart
Pushing test-helm-chart-0.1.0.tgz to test-helm-chart...
Done.
[root@ciserver helm]#

위와 같이 chart가 추가되면 다음과 같이 Harbor 대시보드에서 확인할 수 있다.

 

 

chart를 선택하고, version을 선택하면 다음과 같은 화면으로 이동하게 되며,

 

 

Commands를 활용하여 Repository를 추가하고 Install하는 과정을 수행하게 된다.

- Add Repo : helm repo add --ca-file <ca file> --cert-file <cert file> --key-file <key file>     --username <username> --password <password> <repo name> http://192.168.56.100/chartrepo/docker-project

- Install Chart : helm install --ca-file <ca file> --cert-file <cert file> --key-file <key file>     --username=<username> --password=<password> --version 0.1.0 <repo name>/test-helm-chart

- Fetch Repo Chart : helm fetch <repo_name>/test/helm-chart --untar

 Harbor User 관리 

 

 

Harbor는 admin 사용자 외에 User를 생성하여 권한이 구분된 접속을 제공할 수 있다.

developer 로그인 시 다음과 같이 제한된 화면만 접근이 가능하다.

 

 

물론 각 유저가 생성한 Project는 admin과 동일한 Project 접근 권한을 갖는다.

 

 

위는 developer 사용자가 devproject를 생성한 화면이며, 해당 project에 대해서는 모든 권한을 부여하고 적용할 수 있다.

지금까지 Harbor의 주요 기능에 대해 살펴보았다.

Harbor는 Docker Repository이자, Helm Repository로 사용되는 대표적인 오픈소스 Registry이다. 특히 단순히 저장소이자 버전을 관리하는 용도를 벗어나, 취약점을 점검하거나, 버전별 불필요한 요소를 제거하는 방법 등을 함께 제공한다.

Harbor를 Hosting, Proxy, Maven 등의 역할로써는 적용해 보지는 않았지만, Docker, Helm Chart로써의 용도로써는 Nexus에 뒤쳐지지 않는 수준의 편의성과 접근성을 제공해 주는 완성형 레지스트리라 할 수 있다.

728x90
반응형