헬름 저장소(Helm Repository)

헬름 + 쿠버네티스 가이드북
이민석's avatar
May 25, 2024
헬름 저장소(Helm Repository)

헬름 + 쿠버네티스 가이드북은 Bharath Thippireddy의 Helm Kubernetes Packaging Manager for Developers and DevOps을 보고 작성되었습니다.

가이드북의 전체 목차 및 인덱싱은 헬름 + 쿠버네티스 가이드북 문서를 참고해주세요.

개요

헬름 저장소는 헬름이 사용하는 저장소입니다.

헬름 차트라는 패키지를 통해 쿠버네티스 어플리케이션을 정의, 설치 및 업그레이드 할 수 있습니다.

  1. 로컬 저장소 구성(Set up a local repository)

  2. 파이썬 설치하기(Install Python)

  3. 웹 서버 위에 저장소 호스트하기(Host the repository on a web server)

  4. 저장소 사용하기(Use the repository)

  5. 헬름 풀 사용하여 다운로드하기(Download using helm pull)

  6. 활용 사례(GOOD, 👍👍👍)

  7. 깃헙 페이지 사용하기

  8. HELM_EXPERIMENTAL_OCI란?

  9. OCI 저장소란?

  10. OCI 저장소 사용하기

로컬 저장소 구성(Set up a local repository)

  • 파일 구조

    chartsrepo/
    firstchart/

  • 명령어

    • 입력값

      helm repo index chartsrepo/
    • 출력 파일 (index.yaml)

      apiVersion: v1
      entries: {}
      generated: "2024-05-25T10:10:10.175555+09:00"
  • 핼름 패키징

    helm package firstchart -d chartsrepo

  • 명령어

    • 입력값

      helm repo index chartsrepo/
    • 출력 파일(index.yaml)

      apiVersion: v1
      entries:
        firstchart:
        - apiVersion: v2
          apiVersion: 1.16.0
          created: "2024-05-25T10:10:10.437694+09:00"
          dependenceis:
          - name: mysql
            repository: http://charts.bitnami.com/bitnami
            tags:
            - enabled
            version: 8.8.6
          description: A Helm chart for kubernetes
          digest: **********
          home: https://github.com/unchaptered
          icon: https://github.com/unchaptered/project.jpg
          maintainers:
          - email: workstation19961002@gmail.com
            name: unchaptered
          - email: workstation19961002@gmail.com
            name: unchaptered
      
      # ...
      # ...
      # ...

파이썬 설치하기(Install Python)

헬름 레포지토리를 우리 컴퓨터에서 로컬로 호스트하기 위해서는 웹 서버가 작동해야 합니다.

  • Python

    choco install python
  • Python3

    choco install python3.8

Python2와 Python3.9는 서버를 키는 방법이 다릅니다.

따라서 저는 Python3.13.x 버전을 설치했습니다.

choco install python3 --pre

설치하게 되면 C:\\Python313에 설치가 될 것입니다.

여기서 C:\\Python313\python.exe 파일의 이름을 C:\\Python313\python3.exe로 변경해주세요.

웹 서버 위에 저장소 호스트하기(Host the repository on a web server)

로컬 저장소를 개설하고 싶은 경로에서 아래 명령어를 입력합니다.

python3 -m http.server --bind 127.0.0.1 8080

이후 브라우저에서 127.0.0.1:8080으로 접속하면 폴더가 열립니다.

저장소 사용하기(Use the repository)

  • 로컬 저장소 추가하기

    • 입력

      helm repo add localrepo http://localhost:8080
    • 출력

      "localrepo" has beend added to your repositories

  • 헬름 저장소 확인하기

    • 입력

      helm repo list
    • 출력

      NAME        URL
      bitnami     https://charts.bitnami.com/bitnami
      localrepo   http://localhost:8080

  • 로컬 저장소에서 모듈 설치하기

    • 입력

      helm install firstapp localrepo/firstchart 

헬름 풀 사용하여 다운로드(Download using helm pull)

helm pull localrepo/firstchart

활용 사례 (GOOD, 👍👍👍)

핼름 패키지를 통해서 압축한 차트가 있다면 아래와 같이 특정한 버전을 설치할 수 있습니다.

helm install firstchart local/firstchart-0.10.1.tgz

예를 들어 아래와 같이 패키징을 하고 작업 폴더와 로컬 폴더 사이에서 패키징 파일을 주고 받을 수 있습니다.

  1. 헬름 차트 생성

    helm create secondchart

  2. 헬름 패키지 생성

    1. 입력값

      helm package secondchart -d chartsrepo
    2. 출력값

      Seccessfully packaged chart and saved it to: chartsrepo/secondchart-0.1.0.tgz

  3. 헬름 차트 업로드

    helm repo index chartsrepo/

깃헙 페이지 사용하기

헬름 차트와 핼름 패키지 파일들을 GitHub 저장소에 저장할 수 있습니다. 또한 GitHub Pages를 통해서 이런 파일들을 인터넷 세상에서 사용할 수 있습니다.

HELM_EXPERIMENTAL_OCI란?

헬름 3.8.0 에 실험적 기능으로 추가된 HELM_EXPERIMENTAL_OCI 설정과 이를 통해서 OCI 저장소 기능을 사용할 수 있습니다.

export HELM_EXPERIMENTAL_OCI=1 # 활성화
export HELM_EXPERIMENTAL_OCI=0 # 비활성화

OCI 저장소란?

OCI 저장소는 Open Container Initiative 저장소를 의미합니다.

기본적으로 헬름 차트는 헬름 저장소에서 관리가 됩니다.

하지만 OCI 지원을 통해서 헬름 차트를 OCI 이미지로 패키징하고 Docker Registry와 같은 OCI 호환 저장소에 저장할 수 있습니다.

이를 통해서 다음과 같은 이점을 누릴 수 있습니다.

  1. 중앙화된 저장소 : Docker Registry와 같은 기존의 OCI 호환 저장소를 사용할 수 있습니다.

  2. 통합 관리 : 이미지와 차트를 동일한 저장소에서 관리할 수 있습니다.

  3. 향상된 배포 : OCI 이미지로 배포를 표준화할 수 있습니다.

OCI 저장소 사용하기

docker run -d --name oci-registry -p 5000:5000 registry

helm package firstchart

helm push firstchart-0.1.0.tgz oci://localhost:5000/helm-charts

helm show all oci://localhost:5000/helm-charts/firstchart --version 0.1.0

helm pull oci://localhost:5000/helm-charts/firstchart --version 0.1.0

helm template myrelease oci://localhost:5000/helm-charts/firstchart --version 0.1.0

helm install myrelease oci://localhost:5000/helm-charts/firstchart --version 0.1.0

helm upgrade myrelease oci://localhost:5000/helm-charts/firstchart --version 0.2.0

helm registry login -u myuser <oci registry>

helm registry logout <oci registry url>
Share article
RSSPowered by inblog