CICD 배포/CICD 배포

helm, chartmuseum

김붕어87 2022. 5. 16. 15:41
반응형

helm 이란?

링크 : https://github.com/helm/helm


helm은 차트를 관리하기 위한 툴이다.

kubernetes에서 배포하기 위해서는 yaml로 배포해야한다.

배포하는 리소스와 배포 환경이 많아질 수록 yaml파일의 개수는 엄청나게 늘어난다.

배포할 때마다 yaml을 지정해서 배포하는 것도 일이다.

helm으로 yaml을 패키지화하면 1개의 패키지로 여러개의 환경을 배포할 수 있다.

 

 

chartmuseum 이란?

링크 : https://github.com/helm/chartmuseum


​helm으로 패키지한 파일을 chartmuseum repository에 관리 할 수 있다.

 

 

 

 

helm 설치


1. helm 다운로드

curl -sSL https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash

helm version --short

 

2. helm repository 등록하기 

helm repo list

helm repo add stable https://charts.helm.sh/stable

helm repo update

helm repo list

helm search repo stable

 

3. helm chart 생성하기

mkdir -p nginx/templates

cd ./nginx

vi Chart.yaml

apiVersion: v2
description: nginx
name: nginx1
version: 0.1

 

vi values.yaml

name: nginx1
version: 0.1
imagetag: 0.1

 

cd ./templates

vi deployment.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: web
    version: v{{ .Values.version }}
  name: {{ .Values.name }}
  namespace: dw
spec:
  replicas: 1
  selector:
    matchLabels:
      app: web
      version: v{{ .Values.version }}
  template:
    metadata:
      labels:
        app: web
        version: v{{ .Values.version }}
    spec:
      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
              - matchExpressions:
                  - key: kubernetes.io/arch
                    operator: In
                    values:
                      - amd64
                      - arm64
      containers:
        - image: "AccountID.dkr.ecr.ap-northeast-2.amazonaws.com/ekstest1:{{ .Values.imagetag }}"
          imagePullPolicy: IfNotPresent
          name: web
          ports:
            - containerPort: 80
              name: http
      nodeSelector:
        kubernetes.io/os: linux

 

cd ../../

helm package ./nginx

ls -l nginx-0.1.tgz 

 

 

chartmuseum 설치


1. chartmuseum 다운로드

curl -LO https://s3.amazonaws.com/chartmuseum/release/latest/bin/linux/amd64/chartmuseum

chmod +x chartmuseum

./chartmuseum --version

 

2. chartmuseum 사전 작업

> chartmuseum repository 저장소는 S3이다.

> AWS S3 생성 (test-bucket)

 

3. chartmuseum 실행 

/chartmuseum --debug --port8081 \
  --storage=amazon \
  --storage-amazon-bucket=test-bucket \
  --storage-amazon-prefix= \
  --storage-amazon-region=ap-northeast-2 &

 

4. chartmuseum repository 연결

helm repo add myrepo http://localhost:8081

helm repo update; 

helm search repo

 

 

5. chartmuseum repository 업로드 / 다운로드 

helm repo update 
> 작업 전/후 helm repo update으로 갱신 필요.

curl --data-binary "@nginx-0.1.tgz" http://localhost:8081/api/charts
> chartmuseum upload


curl -X DELETE http://localhost:8081/api/charts/nginx/0.1

> chartmuseum delete

 

반응형

'CICD 배포 > CICD 배포' 카테고리의 다른 글

[ ArgoCD ] application 생성  (0) 2023.02.08
[ ArgoCD ] 구성  (0) 2023.02.08
CI - Jenkins  (0) 2022.05.16
CI - Docker image  (0) 2022.05.06
CD - spinnaker  (0) 2022.05.06