티스토리 뷰

이미지 버젼 관리

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

공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2025/02   »
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28
글 보관함