티스토리 뷰
CLOUD/CICD
[ArgoCD/GitLab] gitlab-ci.yml파일, 이미지 version 태깅하여 관리 및 helm 파일에 최신화
헐리 2021. 10. 5. 15:02이미지 버젼 관리
stages:
- build
- test
- deploy
variables:
IMAGE_NAME: <레지스트리 주소/project이름/레포지토리>
build:
stage: build
script:
- docker login <레지스트리 서버> --username <id> --password-stdin < <비번파일 경로>
- ls -al
- docker build . -t $IMAGE_NAME:$CI_COMMIT_SHA
- docker push $IMAGE_NAME:$CI_COMMIT_SHA
when: manual
test:
stage: test
script:
- docker login <레지스트리 서버> --username <id> --password-stdin < <비번파일 경로>
- docker run -tid $IMAGE_NAME:$CI_COMMIT_SHA
- docker ps
- curl $IMAGE_NAME:$CI_COMMIT_SHA
when: manual
deploy:
stage: deploy
image: alpine/helm:latest
script:
- helm install <deploy이름> <install 경로>
when: manual
- $IMAGE_NAME:$CI_COMMIT_SHA : commit할 때마다 생기는 sha값을 변수 $CI_COMMIT_SHA 로 tagging을 한다.
helm 파일 최신화 (feat. 이미지 최신화)
- harbor에서 pull command를 써야하는 줄 알았는데 <하버 서버>/<프로젝트>/<레포지토리>:<tag> 로도 배포가된다
- 그렇다면 helm-chart.templates.deployment의 이미지 명을 위의 변수로 바꿔주면 될 것이다.
- helm 차트가 기존에 update가 안되고 exist하다고 에러가 나서 지우고 다시깔아야 하는 문제도 이참에 해결할 것이다.
stages:
- build
- test
- deploy
variables:
IMAGE_NAME: <레지스트리 주소/project이름/레포지토리>
build:
stage: build
script:
- docker login <레지스트리 서버> --username <id> --password-stdin < <비번파일 경로>
- ls -al
- docker build . -t $IMAGE_NAME:$CI_COMMIT_SHA
- docker push $IMAGE_NAME:$CI_COMMIT_SHA
when: manual
test:
stage: test
script:
- docker login <레지스트리 서버> --username <id> --password-stdin < <비번파일 경로>
- docker run -tid $IMAGE_NAME:$CI_COMMIT_SHA
- docker ps
- curl $IMAGE_NAME:$CI_COMMIT_SHA
when: manual
deploy:
stage: deploy
image: alpine/helm:latest
script:
- helm update <deploy이름> <install 경로> --version $CI_COMMIT_SHA --set image.name=$IMAGE_NAME:$CI_COMMIT_SHA
when: manual
git clone https://github.com/example/hello-config.git cd hello-config kubectl patch --local -f config-deployment.yaml -p '{"spec":{"template":{"spec":{"containers":[{"name":"hello","image":"example/hello:v2.0"}]}}}}' -o yaml git add . -m "Update hello to v2.0" git push
'CLOUD > CICD' 카테고리의 다른 글
에러해결 error: src refspec main does not match any (0) | 2021.10.19 |
---|---|
[ArgoCD/GitLab] ArgoCD 설치부터 셋팅까지 (0) | 2021.10.06 |
[ArgoCD/GitLab] ArgoCD 와 gitlab CI사용하여 CICD구축 (0) | 2021.10.05 |
에러해결 rescue in irb_binding (0) | 2021.08.31 |
[Git 명령어 및 에러해결 정리] branch, merge, checkout (0) | 2021.07.26 |