마이그레이션 후 이미지 업데이트

migctl migration generate-artifacts 명령어로 만드는 컨테이너 아티팩트는 타겟 클러스터에 마이그레이션된 워크로드를 배포하는 용도로만 사용되지 않습니다. 애플리케이션 및 사용자 모드 OS 소프트웨어 업데이트, 보안 패치, 삽입된 구성 수정, 파일 추가 또는 교체, Migrate to Containers 런타임 소프트웨어 업데이트 등의 '2일차' 유지보수 작업에도 사용됩니다.

생성된 이미지 Dockerfile 검토

이러한 유지보수 작업은 생성된 Dockerfile과 캡처된 시스템 이미지 레이어를 활용합니다. 이들을 Migrate to Containers 런타임 레이어와 결합하여 실행 가능한 컨테이너 이미지에서 기본 제공할 수 있습니다.

생성된 컨테이너 아티팩트는 다음 다이어그램에 설명된 대로 CI/CD 파이프라인 빌드 단계 통합을 염두에 두고 만들어졌습니다.

CI/CD 파이프라인을 보여주는 다이어그램

Dockerfile은 이미지 확장을 막으면서 더 쉽게 유지보수 및 조작을 수행할 수 있도록 다단계 빌드로 구성되어 있습니다.

다음은 생성된 Dockerfile의 샘플입니다.

# Please refer to the documentation:
# https://cloud.google.com/migrate/anthos/docs/dockerfile-reference

FROM anthos-migrate.gcr.io/v2k-run-embedded:v1.6.0 as migrate-for-anthos-runtime

# Image containing data captured from the source VM
FROM gcr.io/myproject/myworkload-non-runnable-base:v1.0.0 as source-content

# If you want to update parts of the image, add your commands here.
# For example:
# RUN apt-get update
# RUN apt-get install -y \
#               package1=version \
#               package2=version \
#               package3=version
# RUN yum update
# RUN wget http://github.com

COPY --from=migrate-for-anthos-runtime / /

# Migrate for GKE Enterprise image includes entrypoint
ENTRYPOINT [ "/.v2k.go" ]

두 번째 FROM 지시문은 마이그레이션된 VM에서 캡처된 시스템 이미지 레이어를 참조합니다. 이 레이어는 단독으로 실행할 수 없으며 Migrate to Containers 런타임 레이어와 결합하여 실행 가능한 이미지를 빌드해야 합니다.

Cloud Build를 사용한 컨테이너 이미지 빌드에 대한 자세한 내용은 컨테이너 이미지 빌드를 참조하세요.

마이그레이션된 워크로드 구성요소 레이어 업데이트

마이그레이션된 워크로드 이미지 레이어에 적용할 업데이트 또는 수정 사항은 두 번째 FROM 지시문 다음에 적용해야 합니다.

다음 예시에서는 Cloud Build와 gcloud CLI를 사용하여 SLES(SUSE Enterprise Linux) VM에서 마이그레이션된 컨테이너 이미지를 업데이트합니다. 다음 예시에서는 SLES distro openssh 패키지를 업데이트합니다.

업데이트된 Dockerfile:

# Image containing data captured from the source VM
FROM anthos-migrate.gcr.io/v2k-run-embedded:v1.6.0 as migrate-for-anthos-runtime

# Image containing data captured from the source VM
FROM gcr.io/myproject/myworkload-non-runnable-base:v1.0.0 as source-content

# If you want to update parts of the image, add your commands here.
# For example:
# RUN apt-get update
# RUN apt-get install -y \
#               package1=version \
#               package2=version \
#               package3=version
# RUN yum update
# RUN wget http://github.com

RUN zypper ref -s && zypper -n in openssh
COPY --from=migrate-for-anthos-runtime / /

# Migrate to Containers image includes entrypoint
ENTRYPOINT [ "/.v2k.go" ]

업데이트된 이미지 빌드:

  1. 생성된 Dockerfile을 Cloud Storage 버킷에서 Cloud Shell 환경의 로컬 디렉터리로 다운로드합니다.
  2. Dockerfile을 수정하여 위의 예시와 같이 강조표시된 RUN 지시문을 추가합니다.
  3. 업데이트된 이미지를 빌드하고 업데이트된 버전 태그와 함께 Container Registry에 푸시하여 빌드가 완료될 때까지 기다립니다. 다음 예시에서는 이미지가 현재 디렉터리에 있습니다.

    gcloud builds submit --timeout 4h --tag gcr.io/myproject/mySUSEworkload:v1.0.1 .
    
  4. 새로 빌드된 이미지를 사용하여 기존 배포를 업데이트할 수 있습니다. 예를 들어 배포된 애플리케이션에서 롤링 업그레이드 수행합니다.

    kubectl set image deployment/myWorkload my-app=gcr.io/myproject/mySUSEworkload:v1.0.1 --record
    

Migrate to Containers 레이어 버전 업데이트

Migrate to Containers 소프트웨어의 새 버전이 출시되면 배포된 워크로드 이미지에서 해당 소프트웨어 버전을 업데이트할 수 있습니다. 이러한 업데이트에는 새로운 기능, 개선 사항 또는 버그 수정이 포함될 수 있습니다.

Migrate to Containers 소프트웨어 레이어를 업데이트하려면 Dockerfile을 수정하고 버전 태그를 적용하려는 업데이트된 버전으로 변경합니다.

이전 예시를 사용하면 FROM 지시문을 다음과 같이 수정하여 버전을 v1.6.0에서 가상 버전 v1.15.0으로 업데이트할 수 있습니다.

FROM anthos-migrate.gcr.io/v2k-run-embedded:v1.15.0 as migrate-for-anthos-runtime

Dockerfile을 업데이트한 후에는 새 워크로드 컨테이너 이미지 버전을 빌드하고 기존 배포에 적용하여 업데이트해야 합니다.

다음 단계