

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

# 리소스를 최신 연산자로 마이그레이션
<a name="kubernetes-sagemaker-operators-migrate"></a>

[Kubernetes용 SageMaker Operators ](https://github.com/aws/amazon-sagemaker-operator-for-k8s/tree/master)오리지널 버전의 개발 및 기술 지원을 중단합니다.

현재 `v1.2.2`버전 이하의 [Kubernetes용 SageMaker Operators](https://github.com/aws/amazon-sagemaker-operator-for-k8s/tree/master)를 사용하고 있다면 [Amazon SageMaker용 ACK 서비스 컨트롤러](https://github.com/aws-controllers-k8s/sagemaker-controller)로 리소스를 마이그레이션하는 것이 좋습니다. ACK 서비스 컨트롤러는 [Kubernetes용AWS 컨트롤러(ACK)](https://aws-controllers-k8s.github.io/community/)를 기반으로 하는 차세대 Kubernetes용 SageMaker Operators입니다.

Kubernetes용 SageMaker Operators 오리지널 버전의 지원 종료에 대한 자주 묻는 질문에 대한 답변은 [Kubernetes용 SageMaker AI Operators 오리지널 버전 지원 종료 발표](kubernetes-sagemaker-operators-eos-announcement.md)섹션을 참조하세요.

Amazon SageMaker AI를 사용하여 기계 학습 모델을 훈련, 조정 및 배포하기 위해 리소스를 마이그레이션하고 ACK를 사용하려면 다음 단계를 사용하세요.

**참고**  
최신 Kubernetes용 SageMaker AI Operators는 이전 버전과 호환되지 않습니다.

**Topics**
+ [사전 조건](#migrate-resources-to-new-operators-prerequisites)
+ [리소스 채택](#migrate-resources-to-new-operators-steps)
+ [이전 리소스 정리](#migrate-resources-to-new-operators-cleanup)
+ [새로운 Kubernetes용 SageMaker AI Operators 사용](#migrate-resources-to-new-operators-tutorials)

## 사전 조건
<a name="migrate-resources-to-new-operators-prerequisites"></a>

리소스를 최신 SageMaker AI Operators로 성공적으로 마이그레이션하려면 다음을 수행해야 합니다.

1. 최신 Kubernetes용 SageMaker AI Operators를 설치합니다. 단계별 지침은 *Machine Learning with the ACK SageMaker AI Controller*의 [Setup](https://aws-controllers-k8s.github.io/community/docs/tutorials/sagemaker-example/#setup)을 참조하세요.

1. [호스팅 오토 스케일링 리소스](#migrate-resources-to-new-operators-hap)을 사용하는 경우 새 애플리케이션 오토 스케일링 연산자를 설치하세요. 단계별 지침은 *Scale SageMaker AI Workloads with Application Auto Scaling*의 [Setup](https://aws-controllers-k8s.github.io/community/docs/tutorials/autoscaling-example/#setup)을 참조하세요. 호스팅 오토 스케일링 정책 리소스를 사용하지 않는 경우 이 단계는 선택 사항입니다.

권한이 올바르게 구성된 경우 ACK SageMaker AI 서비스 컨트롤러는 AWS 리소스의 사양과 상태를 확인하고 ACK 컨트롤러가 원래 생성한 것처럼 리소스를 조정할 수 있습니다.

## 리소스 채택
<a name="migrate-resources-to-new-operators-steps"></a>

새로운 Kubernetes용 SageMaker AI Operators는 원래 ACK 서비스 컨트롤러에서 생성하지 않은 리소스를 채택할 수 있는 기능을 제공합니다. 자세한 내용은 ACK 설명서의 [기존 AWS 리소스 채택](https://aws-controllers-k8s.github.io/community/docs/user-docs/adopted-resource/)을 참조하세요.

다음 단계는 새로운 Kubernetes용 SageMaker AI Operators가 기존 SageMaker AI 엔드포인트를 채택할 수 있는 방법을 보여줍니다. 다음 샘플을 `adopt-endpoint-sample.yaml`이라는 파일에 저장합니다.

```
apiVersion: services.k8s.aws/v1alpha1
kind: AdoptedResource
metadata:
  name: adopt-endpoint-sample
spec:  
  aws:
    # resource to adopt, not created by ACK
    nameOrID: xgboost-endpoint
  kubernetes:
    group: sagemaker.services.k8s.aws
    kind: Endpoint
    metadata:
      # target K8s CR name
      name: xgboost-endpoint
```

`kubectl apply`를 사용하여 사용자 지정 리소스(CR)를 제출합니다.

```
kubectl apply -f adopt-endpoint-sample.yaml
```

`kubectl describe`를 사용하여 채택한 리소스의 상태를 확인합니다.

```
kubectl describe adoptedresource adopt-endpoint-sample
```

`ACK.Adopted` 조건이 `True`인지 확인합니다. 출력은 다음 예시와 비슷해야 합니다.

```
---
kind: AdoptedResource
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: '{"apiVersion":"services.k8s.aws/v1alpha1","kind":"AdoptedResource","metadata":{"annotations":{},"name":"xgboost-endpoint","namespace":"default"},"spec":{"aws":{"nameOrID":"xgboost-endpoint"},"kubernetes":{"group":"sagemaker.services.k8s.aws","kind":"Endpoint","metadata":{"name":"xgboost-endpoint"}}}}'
  creationTimestamp: '2021-04-27T02:49:14Z'
  finalizers:
  - finalizers.services.k8s.aws/AdoptedResource
  generation: 1
  name: adopt-endpoint-sample
  namespace: default
  resourceVersion: '12669876'
  selfLink: "/apis/services.k8s.aws/v1alpha1/namespaces/default/adoptedresources/adopt-endpoint-sample"
  uid: 35f8fa92-29dd-4040-9d0d-0b07bbd7ca0b
spec:
  aws:
    nameOrID: xgboost-endpoint
  kubernetes:
    group: sagemaker.services.k8s.aws
    kind: Endpoint
    metadata:
      name: xgboost-endpoint
status:
  conditions:
  - status: 'True'
    type: ACK.Adopted
```

클러스터에 리소스가 있는지 확인합니다.

```
kubectl describe endpoints.sagemaker xgboost-endpoint
```

### 호스팅 오토 스케일링 리소스
<a name="migrate-resources-to-new-operators-hap"></a>

`HostingAutoscalingPolicy`(HAP) 리소스는 여러 애플리케이션 오토 스케일링 리소스인 `ScalableTarget`및 `ScalingPolicy`로 구성됩니다. ACK가 있는 HAP 리소스를 채택할 때는 먼저 [애플리케이션 오토 스케일링 컨트롤러](https://github.com/aws-controllers-k8s/applicationautoscaling-controller)를 설치합니다. HAP 리소스를 채택하려면 `ScalableTarget`및 `ScalingPolicy`리소스를 모두 채택해야 합니다. `HostingAutoscalingPolicy` 리소스(`status.ResourceIDList`)의 상태에서 이러한 리소스의 리소스 식별자를 찾을 수 있습니다.

### 호스팅 배포 리소스
<a name="migrate-resources-to-new-operators-hosting-deployment"></a>

`HostingDeployment` 리소스는 여러 SageMaker AI 리소스인 `Endpoint`, `EndpointConfig` 및 각 `Model`로 구성되어 있습니다. ACK에서 SageMaker AI 엔드포인트를 채택하는 경우, `Endpoint`, `EndpointConfig` 및 각 `Model`을 개별적으로 채택해야 합니다. `Endpoint`, `EndpointConfig`및 `Model`이름은 `HostingDeployment`리소스의 상태(`status.endpointName`, `status.endpointConfigName`, 및`status.modelNames`)에서 찾을 수 있습니다.

지원되는 모든 SageMaker AI 리소스 목록은 [ACK API Reference](https://aws-controllers-k8s.github.io/community/reference/)를 참조하세요.

## 이전 리소스 정리
<a name="migrate-resources-to-new-operators-cleanup"></a>

새로운 Kubernetes용 SageMaker AI Operators가 리소스를 채택한 후에는 기존 운영자를 제거하고 기존 리소스를 정리할 수 있습니다.

### 1단계: 기존 연산자 제거
<a name="migrate-resources-to-new-operators-uninstall"></a>

이전 연산자를 제거하려면 [연산자 삭제](kubernetes-sagemaker-operators-end-of-support.md#delete-operators)섹션을 참조하세요.

**주의**  
기존 리소스를 삭제하기 전에 이전 연산자를 제거하세요.

### 2단계: 파이널라이저 제거 및 기존 리소스 삭제
<a name="migrate-resources-to-new-operators-delete-resources"></a>

**주의**  
기존 리소스를 삭제하기 전에 이전 연산자를 제거해야 합니다.

이전 연산자를 제거한 후에는 파이널라이저를 명시적으로 제거하여 기존 연산자 리소스를 삭제해야 합니다. 다음 샘플 스크립트는 지정된 네임스페이스에서 이전 연산자가 관리하는 모든 훈련 작업을 삭제하는 방법을 보여줍니다. 새 연산자가 리소스를 채택한 후 유사한 패턴을 사용하여 추가 리소스를 삭제할 수 있습니다.

**참고**  
리소스를 가져오려면 전체 리소스 이름을 사용해야 합니다. 예를 들어 `kubectl get trainingjob`대신 `kubectl get trainingjobs.sagemaker.aws.amazon.com`을 사용합니다.

```
namespace=sagemaker_namespace
training_jobs=$(kubectl get trainingjobs.sagemaker.aws.amazon.com -n $namespace -ojson | jq -r '.items | .[] | .metadata.name')
 
for job in $training_jobs
do
    echo "Deleting $job resource in $namespace namespace"
    kubectl patch trainingjobs.sagemaker.aws.amazon.com $job -n $namespace -p '{"metadata":{"finalizers":null}}' --type=merge
    kubectl delete trainingjobs.sagemaker.aws.amazon.com $job -n $namespace
done
```

## 새로운 Kubernetes용 SageMaker AI Operators 사용
<a name="migrate-resources-to-new-operators-tutorials"></a>

새로운 Kubernetes용 SageMaker AI Operators 사용에 대한 심층 가이드는 [Kubernetes용 SageMaker AI Operators 사용](kubernetes-sagemaker-operators-ack.md#kubernetes-sagemaker-operators-ack-use) 섹션을 참조하세요.