

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

# AWS PCS에 대한 노드 수명 주기 작업 예제
<a name="cng-node-lifecycle-actions-examples"></a>

다음 예제에서는 AWS CLI 를 사용하여 노드 수명 주기 작업을 구성합니다. 를 사용하여 컴퓨팅 노드 그룹을 생성하거나 `create-compute-node-group`를 사용하여 기존 컴퓨팅 노드 그룹에서 추가 또는 변경할 때 수명 주기 작업을 정의할 수 있습니다`update-compute-node-group`. `--node-lifecycle-actions` 값은 두 명령에서 동일합니다.

## 여러 단계의 여러 스크립트
<a name="cng-node-lifecycle-actions-examples-multiple"></a>

이 예제에서는 두 수명 주기 단계의 스크립트를 서로 다른 실행 정책 및 오류 동작과 결합합니다.

```
aws pcs create-compute-node-group --region {{region}} \
  --cluster-identifier {{my-cluster}} \
  --compute-node-group-identifier {{my-cng}} \
  --subnet-ids {{subnet-ExampleID1}} \
  --custom-launch-template id={{lt-ExampleID1}},version='{{1}}' \
  --iam-instance-profile-arn={{arn:InstanceProfile}} \
  --scaling-config minInstanceCount={{0}},maxInstanceCount={{10}} \
  --instance-configs instanceType={{t3.large}} \
  --node-lifecycle-actions '{
    "stages": {
      "nodeBootstrapped": [
        { "name": "Mount FSx Lustre", "scriptSource": { "scriptLocation": "s3://{{my-bucket}}/mount-fsx.sh" }, "arguments": ["fs-{{0abc123}}", "/scratch"], "executionPolicy": "EVERY_BOOT" },
        { "name": "Join Active Directory", "scriptSource": { "scriptLocation": "s3://{{my-bucket}}/configure-ad.sh" }, "arguments": ["ad.example.com", "EXAMPLE"], "executionPolicy": "FIRST_BOOT_ONLY" }
      ],
      "nodeReady": [
        { "name": "Configure CloudWatch logging", "scriptSource": { "scriptLocation": "s3://{{my-bucket}}/setup-cloudwatch.sh" }, "arguments": ["/aws/pcs/{{my-cluster}}"], "onError": "CONTINUE" }
      ]
    }
  }'
```

## 혼합 오류 동작
<a name="cng-node-lifecycle-actions-examples-mixed-error"></a>

이 예제에서는 동일한 단계에서 중요한 스크립트와 선택적 스크립트를 사용합니다. 첫 번째 노드는 실패 시 종료되고 두 번째 노드는 계속됩니다.

```
aws pcs create-compute-node-group --region {{region}} \
  --cluster-identifier {{my-cluster}} \
  --compute-node-group-identifier {{my-cng}} \
  --subnet-ids {{subnet-ExampleID1}} \
  --custom-launch-template id={{lt-ExampleID1}},version='{{1}}' \
  --iam-instance-profile-arn={{arn:InstanceProfile}} \
  --scaling-config minInstanceCount={{0}},maxInstanceCount={{10}} \
  --instance-configs instanceType={{t3.large}} \
  --node-lifecycle-actions '{
    "stages": {
      "nodeBootstrapped": [
        { "name": "Install required packages", "scriptSource": { "scriptLocation": "s3://{{my-bucket}}/install-packages.sh" }, "onError": "TERMINATE" },
        { "name": "Install optional tools", "scriptSource": { "scriptLocation": "s3://{{my-bucket}}/install-optional.sh" }, "onError": "CONTINUE" }
      ]
    }
  }'
```

## 체크섬을 사용한 무결성 검증
<a name="cng-node-lifecycle-actions-examples-checksum"></a>

콘텐츠가 일치하지 않는 경우 에이전트가 스크립트를 거부하도록 SHA-256 체크섬을 추가합니다.

```
aws pcs update-compute-node-group \
  --cluster-identifier {{my-cluster}} \
  --compute-node-group-identifier {{my-cng}} \
  --node-lifecycle-actions '{
    "stages": {
      "nodeBootstrapped": [
        {
          "name": "Mount EFS",
          "scriptSource": {
            "scriptLocation": "s3://{{my-bucket}}/mount-efs.sh",
            "checksum": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
          },
          "arguments": ["fs-{{12345678}}", "/shared"]
        }
      ]
    }
  }'
```

## 재부팅 시 스크립트 새로 고침 활성화
<a name="cng-node-lifecycle-actions-examples-refresh"></a>

를 `scriptCachingPolicy`로 설정합니다`REFRESH_ON_REBOOT`. 이 `UpdateComputeNodeGroup` 호출은 구성 변경이므로 기존 인스턴스를 드레이닝하고 교체합니다. 교체가 완료되면 인스턴스는 재부팅할 때마다 스크립트를 다시 다운로드합니다. 그런 다음 Amazon S3에서 스크립트 콘텐츠를 업데이트할 수 있으며 인스턴스는 추가 API 호출 없이 다음 재부팅 시 변경 사항을 선택할 수 있습니다.

```
aws pcs update-compute-node-group \
  --cluster-identifier {{my-cluster}} \
  --compute-node-group-identifier {{my-cng}} \
  --node-lifecycle-actions '{
    "stages": { "nodeBootstrapped": [ { "name": "Mount EFS", "scriptSource": { "scriptLocation": "s3://{{my-bucket}}/mount-efs.sh" }, "arguments": ["fs-{{12345678}}", "/shared"], "executionPolicy": "EVERY_BOOT" } ] },
    "scriptCachingPolicy": "REFRESH_ON_REBOOT"
  }'
```

## AWS ParallelCluster 부트스트랩 작업에서 마이그레이션
<a name="cng-node-lifecycle-actions-examples-migrate"></a>

많은 기존 AWS ParallelCluster 부트스트랩 스크립트는 AWS PCS 수명 주기 작업과 함께 있는 그대로 작동합니다. AWS PCS는 스크립트별 오류 처리(`TERMINATE`, `STOP_SEQUENCE`또는 `CONTINUE`) 및 재부팅 제어(`FIRST_BOOT_ONLY` 또는 )를 제공합니다`EVERY_BOOT`. AWS PCS 기본값은 입니다`FIRST_BOOT_ONLY`. ParallelCluster 동작(매 부팅 시 실행)을 일치시키려면를 `executionPolicy`로 설정합니다`EVERY_BOOT`.


| **AWS ParallelCluster** | **AWS PCS** | 
| --- | --- | 
| `OnNodeStart` | `nodeBootstrapped` ( AWS PCS 구성 단계 후, 이전에서 실행`slurmd`됨) | 
| `OnNodeConfigured` | `nodeReady` (노드가 Slurm 컨트롤러에 등록된 후 실행됨) | 
| `OnNodeUpdated` |  AWS PCS에 상응하는 항목 없음 | 