본문 바로가기
개발공부/Helm

1. Helm을 알아보고 설치하기

by theguywholivethatgeneration 2022. 9. 20.
반응형

2022.09.20 - [개발공부/Helm] - 1. Helm을 알아보고 설치하기

2022.09.20 - [개발공부/Istio] - 2.Helm 동적 으로 yaml 수정 사용하기

2022.09.20 - [개발공부/Helm] - 3. Helm chart relase 이름 변경하기, namespace 설정하기

Helm 이란, Kubernetes 패키지 관리를 도와주는것 (패키지매니저)으로, yaml 파일의 모음이라고 할 수 있다. 차트(Charts)는 쿠버네티스의 리소스 yaml 파일을 1) 템플릿으로 만들고, 2) 메타 정보파일 등으로 압축한 파일이다.

 

Helm charts 기본구조
Helm charts 기본구조

 

 

기본 구조와 파일

이름 형태 설명
Chart.yaml 파일 Chart에 대한 이름, 버전, 설명 등이 정의된 파일
requirements.yaml 파일 Chart에 대한 종속 Chart 정보를 정의한파일
values.yaml 파일 Chart설치시 사용할 환경 변수를 정의한 파일
charts/ 폴더 Chart에서 사용하는 종속 Chart들이 압축파일(tgz)로 존재함. helm dep up 명령 수행하면 requirements.yaml 참조하여 repository에서 다운받아 생성함
templates/ 폴더 설치할 resource들의 기본 틀을 정의한 manifest yaml 파일
helpers.tpl 파일 templates manifest파일들에서 공유하는 변수 정의

 

Helm 차트만 있나면 누구나 쿠버네티스에 배포가 가능하다

 

 

helm chart를 통한 배포
helm chart를 통한 배포

 

Helm 설치하기

curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
chmod 700 get_helm.sh
./get_helm.sh

brew 를 이용해서 설치 가능

brew install helm

 

테스트용 디렉토리 생성 후 해당 폴더로 이동, templates 폴더를 생성해 준다.

templates 디렉토리는 배포할 쿠버네티스 리소스의 yaml 파일들이 있다.

mkdir helm_test

cd helm_test

mkdir templates

cd templates

 

폴더 안에 deployment.yaml 파일과 service.yaml 파일을 만들어준다.

touch deployment.yaml
touch service.yaml

templates 디렉토리 생성 deployment.yaml 파일과 service.yaml 존재
templates 디렉토리 생성

배포를 위한 test yaml 파일을 작성해 준다.

# deployment.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-test
  labels:
    app: nginx-test
spec:
  replicas: 2
  selector:
    matchLabels:
      app: nginx-test
  template:
    metadata:
      labels:
        app: nginx-test
    spec:
      containers:
      - name: nginx
        image: nginx:latest
        ports:
        - containerPort: 80
#service.yaml

apiVersion: v1
kind: Service
metadata:
  name: nginx-test
spec:
  selector:
    app: nginx-test
  ports:
  - port: 80
    targetPort: 80
  type: NodePort

 

 

Chart.yaml 파일 생성해서 내용 채워 주기

vi Chart.yaml

트리구조에 Chart.yaml 추가
Chart.yaml 추가

# Chart.yaml

apiVersion : v2                   # helm api 버전
name : test-charts                # helm 차트 이름
version : 0.0.1                   # helm 차트 버전  (SemVer 규칙을 준수) - Semantic Versioning의 줄임말로 , 버전 형식에 의미를 부여하여 좀 더 체계적인 버전관리 제안

 

해당 파일을 통해 helm 설치하기

helm install [Release name] [경로]

helm 설치 결과 화면
helm 설치 결과

설치 확인하기 

helm list

명령어 helm list 결과
helm list

 

설치 삭제하기

# helm delete <Release 이름>

helm delete ttt

 

 

2022.09.20 - [개발공부/Helm] - 1. Helm을 알아보고 설치하기

2022.09.20 - [개발공부/Istio] - 2.Helm 동적 으로 yaml 수정 사용하기

2022.09.20 - [개발공부/Helm] - 3. Helm chart relase 이름 변경하기, namespace 설정하기

반응형

댓글