메인 콘텐츠로 건너뛰기
W&B는 W&B Multi-tenant Cloud 또는 W&B 전용 클라우드 배포 유형과 같은 완전 관리형 배포 옵션을 권장합니다. W&B 완전 관리형 서비스는 설정이 거의 또는 전혀 필요하지 않아 사용이 간편하고 안전합니다.
W&B는 AWS에 플랫폼을 배포하기 위해 W&B Server AWS Terraform Module 사용을 권장합니다. 시작하기 전에, W&B는 Terraform에서 State File을 저장하는 데 사용할 수 있는 원격 백엔드 중 하나를 선택할 것을 권장합니다. State File은 모든 구성 요소를 다시 생성하지 않고 배포 업그레이드를 수행하거나 변경 사항을 적용하는 데 필요한 자원입니다. Terraform Module은 다음의 필수 구성 요소를 배포합니다.
  • Load Balancer
  • AWS Identity & Access Management (IAM)
  • AWS Key Management System (KMS)
  • Amazon Aurora MySQL
  • Amazon VPC
  • Amazon S3
  • Amazon Route53
  • Amazon Certificate Manager (ACM)
  • Amazon Elastic Load Balancing (ALB)
  • Amazon Secrets Manager
다른 배포 옵션에는 다음과 같은 선택적 구성 요소가 포함될 수 있습니다.
  • Elastic Cache for Redis
  • SQS

사전 필수 권한

Terraform을 실행하는 계정은 도입부에서 설명한 모든 구성 요소를 생성할 수 있어야 하며, IAM PoliciesIAM Roles를 생성하고 자원에 역할을 할당할 수 있는 권한이 있어야 합니다.

일반 단계

이 섹션의 단계는 이 문서에서 다루는 모든 배포 옵션에 공통적으로 적용됩니다.
  1. 개발 환경을 준비합니다.
    • Terraform 설치
    • W&B는 버전 관리를 위해 Git 저장소를 생성할 것을 권장합니다.
  2. terraform.tfvars 파일을 생성합니다. tvfars 파일 내용은 설치 유형에 따라 맞춤 설정할 수 있지만, 최소 권장 구성은 아래 예시와 같습니다.
    namespace                  = "wandb"
    license                    = "xxxxxxxxxxyyyyyyyyyyyzzzzzzz"
    subdomain                  = "wandb-aws"
    domain_name                = "wandb.ml"
    zone_id                    = "xxxxxxxxxxxxxxxx"
    allowed_inbound_cidr       = ["0.0.0.0/0"]
    allowed_inbound_ipv6_cidr  = ["::/0"]
    eks_cluster_version        = "1.29"
    
    배포하기 전에 tvfars 파일에 변수를 정의해야 합니다. namespace 변수는 Terraform에 의해 생성되는 모든 자원의 접두사로 사용되는 문자열이기 때문입니다. subdomaindomain의 조합은 W&B가 구성될 FQDN을 형성합니다. 위의 예시에서 W&B FQDN은 wandb-aws.wandb.ml이 되며, zone_id는 FQDN 레코드가 생성될 DNS 영역 ID입니다. allowed_inbound_cidrallowed_inbound_ipv6_cidr 설정도 필수입니다. 모듈에서 이는 필수 입력 값입니다. 위 예시는 모든 소스에서 W&B 설치 환경으로의 엑세스를 허용합니다.
  3. versions.tf 파일을 생성합니다. 이 파일에는 AWS에 W&B를 배포하는 데 필요한 Terraform 및 Terraform 공급자 버전 정보가 포함됩니다.
    provider "aws" {
      region = "eu-central-1"
    
      default_tags {
        tags = {
          GithubRepo = "terraform-aws-wandb"
          GithubOrg  = "wandb"
          Enviroment = "Example"
          Example    = "PublicDnsExternal"
        }
      }
    }
    
    AWS 공급자 설정에 대해서는 Terraform 공식 문서를 참조하세요. 선택 사항이지만, 이 문서의 시작 부분에서 언급한 원격 백엔드 설정을 추가하는 것을 적극 권장합니다.
  4. variables.tf 파일을 생성합니다. terraform.tfvars에 설정된 모든 옵션에 대해 Terraform은 해당 변수 선언이 필요합니다.
    variable "namespace" {
      type        = string
      description = "Name prefix used for resources"
    }
    
    variable "domain_name" {
      type        = string
      description = "Domain name used to access instance."
    }
    
    variable "subdomain" {
      type        = string
      default     = null
      description = "Subdomain for accessing the Weights & Biases UI."
    }
    
    variable "license" {
      type = string
    }
    
    variable "zone_id" {
      type        = string
      description = "Domain for creating the Weights & Biases subdomain on."
    }
    
    variable "allowed_inbound_cidr" {
     description = "CIDRs allowed to access wandb-server."
     nullable    = false
     type        = list(string)
    }
    
    variable "allowed_inbound_ipv6_cidr" {
     description = "CIDRs allowed to access wandb-server."
     nullable    = false
     type        = list(string)
    }
    
    variable "eks_cluster_version" {
     description = "EKS cluster kubernetes version"
     nullable    = false
     type        = string
    }
    

권장 배포 옵션

이것은 모든 필수 구성 요소를 생성하고 Kubernetes 클러스터에 최신 버전의 W&B를 설치하는 가장 간단한 배포 옵션 설정입니다.
  1. main.tf를 생성합니다. 일반 단계에서 파일을 생성한 것과 동일한 디렉토리에 다음 내용으로 main.tf 파일을 생성합니다.
    module "wandb_infra" {
      source  = "wandb/wandb/aws"
      version = "~>7.0"
    
      namespace   = var.namespace
      domain_name = var.domain_name
      subdomain   = var.subdomain
      zone_id     = var.zone_id
    
      allowed_inbound_cidr           = var.allowed_inbound_cidr
      allowed_inbound_ipv6_cidr      = var.allowed_inbound_ipv6_cidr
    
      public_access                  = true
      external_dns                   = true
      kubernetes_public_access       = true
      kubernetes_public_access_cidrs = ["0.0.0.0/0"]
      eks_cluster_version            = var.eks_cluster_version
    }
    
     data "aws_eks_cluster" "eks_cluster_id" {
       name = module.wandb_infra.cluster_name
     }
    
     data "aws_eks_cluster_auth" "eks_cluster_auth" {
       name = module.wandb_infra.cluster_name
     }
    
     provider "kubernetes" {
       host                   = data.aws_eks_cluster.eks_cluster_id.endpoint
       cluster_ca_certificate = base64decode(data.aws_eks_cluster.eks_cluster_id.certificate_authority.0.data)
       token                  = data.aws_eks_cluster_auth.eks_cluster_auth.token
     }
    
    
     provider "helm" {
       kubernetes {
         host                   = data.aws_eks_cluster.eks_cluster_id.endpoint
         cluster_ca_certificate = base64decode(data.aws_eks_cluster.eks_cluster_id.certificate_authority.0.data)
         token                  = data.aws_eks_cluster_auth.eks_cluster_auth.token
       }
     }
    
     output "url" {
       value = module.wandb_infra.url
     }
    
     output "bucket" {
       value = module.wandb_infra.bucket_name
     }
    
  2. W&B 배포 W&B를 배포하려면 다음 코맨드를 실행하세요.
    terraform init
    terraform apply -var-file=terraform.tfvars
    

REDIS 활성화

또 다른 배포 옵션은 SQL 쿼리를 캐시하고 Experiments를 위한 메트릭을 로드할 때 애플리케이션 응답 속도를 높이기 위해 Redis를 사용하는 것입니다. 캐시를 활성화하려면 권장 배포 옵션 섹션에서 설명한 동일한 main.tf 파일에 create_elasticache_subnet = true 옵션을 추가해야 합니다.
module "wandb_infra" {
  source  = "wandb/wandb/aws"
  version = "~>7.0"

  namespace   = var.namespace
  domain_name = var.domain_name
  subdomain   = var.subdomain
  zone_id     = var.zone_id
	**create_elasticache_subnet = true**
}
[...]

메시지 브로커(큐) 활성화

배포 옵션 3은 외부 메시지 브로커를 활성화하는 것입니다. W&B에 브로커가 내장되어 있으므로 이는 선택 사항입니다. 이 옵션이 성능 향상을 가져다주지는 않습니다. 메시지 브로커를 제공하는 AWS 자원은 SQS이며, 이를 활성화하려면 권장 배포 옵션 섹션에서 설명한 것과 동일한 main.tfuse_internal_queue = false 옵션을 추가해야 합니다.
module "wandb_infra" {
  source  = "wandb/wandb/aws"
  version = "~>7.0"

  namespace   = var.namespace
  domain_name = var.domain_name
  subdomain   = var.subdomain
  zone_id     = var.zone_id
  **use_internal_queue = false**

[...]
}

기타 배포 옵션

모든 설정을 동일한 파일에 추가하여 세 가지 배포 옵션을 모두 조합할 수 있습니다. Terraform Module은 표준 옵션 및 배포 - 권장에서 찾을 수 있는 최소 설정과 함께 조합할 수 있는 여러 옵션을 제공합니다.

수동 설정

Amazon S3 버킷을 W&B의 파일 스토리지 백엔드로 사용하려면 다음 작업이 필요합니다. 버킷을 생성하고, 해당 버킷의 오브젝트 생성 알림을 받도록 구성된 SQS 큐를 만들어야 합니다. 인스턴스에는 이 큐에서 읽을 수 있는 권한이 필요합니다.

Amazon S3 버킷 및 버킷 알림 생성

다음 절차에 따라 Amazon S3 버킷을 생성하고 버킷 알림을 활성화합니다.
  1. AWS 콘솔에서 Amazon S3로 이동합니다.
  2. Create bucket을 선택합니다.
  3. Advanced settings 내의 Events 섹션에서 Add notification을 선택합니다.
  4. 모든 오브젝트 생성 이벤트가 이전에 구성한 SQS 큐로 전송되도록 구성합니다.
Enterprise file storage settings
CORS 엑세스를 활성화합니다. CORS 설정은 다음과 같아야 합니다.
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
    <AllowedOrigin>http://YOUR-W&B-SERVER-IP</AllowedOrigin>
    <AllowedMethod>GET</AllowedMethod>
    <AllowedMethod>PUT</AllowedMethod>
    <AllowedHeader>*</AllowedHeader>
</CORSRule>
</CORSConfiguration>

SQS 큐 생성

다음 절차에 따라 SQS 큐를 생성합니다.
  1. AWS 콘솔에서 Amazon SQS로 이동합니다.
  2. Create queue를 선택합니다.
  3. Details 섹션에서 Standard 큐 유형을 선택합니다.
  4. Access policy 섹션에서 다음 주체에 권한을 추가합니다.
  • SendMessage
  • ReceiveMessage
  • ChangeMessageVisibility
  • DeleteMessage
  • GetQueueUrl
선택적으로 Access Policy 섹션에서 고급 엑세스 정책을 추가합니다. 예를 들어, 구문이 포함된 Amazon SQS 엑세스 정책은 다음과 같습니다.
{
    "Version" : "2012-10-17",
    "Statement" : [
      {
        "Effect" : "Allow",
        "Principal" : "*",
        "Action" : ["sqs:SendMessage"],
        "Resource" : "<sqs-queue-arn>",
        "Condition" : {
          "ArnEquals" : { "aws:SourceArn" : "<s3-bucket-arn>" }
        }
      }
    ]
}

W&B를 실행하는 노드에 권한 부여

W&B 서버가 실행 중인 노드는 Amazon S3 및 Amazon SQS에 대한 엑세스를 허용하도록 구성되어야 합니다. 선택한 서버 배포 유형에 따라 노드 역할에 다음 정책 구문을 추가해야 할 수도 있습니다.
{
   "Statement":[
      {
         "Sid":"",
         "Effect":"Allow",
         "Action":"s3:*",
         "Resource":"arn:aws:s3:::<WANDB_BUCKET>"
      },
      {
         "Sid":"",
         "Effect":"Allow",
         "Action":[
            "sqs:*"
         ],
         "Resource":"arn:aws:sqs:<REGION>:<ACCOUNT>:<WANDB_QUEUE>"
      }
   ]
}

W&B 서버 구성

마지막으로 W&B 서버를 구성합니다.
  1. http(s)://YOUR-W&B-SERVER-HOST/system-admin에서 W&B 설정 페이지로 이동합니다.
  2. Use an external file storage backend 옵션을 활성화합니다.
  3. Amazon S3 버킷, 지역 및 Amazon SQS 큐에 대한 정보를 다음 형식으로 입력합니다.
  • File Storage Bucket: s3://<bucket-name>
  • File Storage Region (AWS only): <region>
  • Notification Subscription: sqs://<queue-name>
AWS file storage configuration
  1. Update settings를 선택하여 새로운 설정을 적용합니다.

W&B 버전 업그레이드

W&B를 업데이트하려면 다음 단계를 따르세요.
  1. wandb_app 모듈의 설정에 wandb_version을 추가합니다. 업그레이드하려는 W&B 버전을 입력합니다. 예를 들어, 다음 라인은 W&B 버전 0.48.1을 지정합니다.
module "wandb_app" {
    source  = "wandb/wandb/kubernetes"
    version = "~>1.0"

    license       = var.license
    wandb_version = "0.48.1"
또는 terraform.tfvarswandb_version을 추가하고 동일한 이름의 변수를 생성한 후 리터럴 값 대신 var.wandb_version을 사용할 수 있습니다.
  1. 설정을 업데이트한 후 권장 배포 옵션 섹션에 설명된 단계를 완료합니다.

Operator 기반 AWS Terraform 모듈로 마이그레이션

이 섹션에서는 terraform-aws-wandb 모듈을 사용하여 pre-operator 환경에서 post-operator 환경으로 업그레이드하는 데 필요한 단계를 자세히 설명합니다.
W&B 아키텍처를 위해 Kubernetes operator 패턴으로의 전환이 필요합니다. 자세한 설명은 아키텍처 변화 설명을 참조하세요.

아키텍처 전후 비교

이전의 W&B 아키텍처는 다음을 사용했습니다.
module "wandb_infra" {
  source  = "wandb/wandb/aws"
  version = "1.16.10"
  ...
}
인프라 제어용:
pre-operator-infra
그리고 W&B 서버 배포를 위한 이 모듈:
module "wandb_app" {
  source  = "wandb/wandb/kubernetes"
  version = "1.12.0"
}
pre-operator-k8s
전환 후 아키텍처는 다음을 사용합니다.
module "wandb_infra" {
  source  = "wandb/wandb/aws"
  version = "4.7.2"
  ...
}
인프라 설치와 Kubernetes 클러스터에 대한 W&B 서버 설치를 모두 관리하므로 post-operator.tf에서 module "wandb_app"이 필요하지 않습니다.
post-operator-k8s
이러한 아키텍처 변화를 통해 SRE/인프라 팀의 수동 Terraform 작업 없이도 추가 기능(예: OpenTelemetry, Prometheus, HPA, Kafka 및 이미지 업데이트)을 사용할 수 있습니다. W&B Pre-Operator 기본 설치로 시작하려면 post-operator.tf.disabled 파일 확장자가 있는지 확인하고 pre-operator.tf가 활성화되어 있는지(확장자가 .disabled가 아닌지) 확인하세요. 해당 파일들은 여기에서 찾을 수 있습니다.

사전 요구 사항

마이그레이션 프로세스를 시작하기 전에 다음 사전 요구 사항을 충족하는지 확인하세요.
  • 송신(Egress): 배포는 에어갭(airgapped) 환경일 수 없습니다. Release Channel에 대한 최신 사양을 가져오기 위해 deploy.wandb.ai에 대한 엑세스가 필요합니다.
  • AWS 자격 증명: AWS 자원과 상호 작용할 수 있도록 적절한 AWS 자격 증명이 구성되어야 합니다.
  • Terraform 설치: 시스템에 최신 버전의 Terraform이 설치되어 있어야 합니다.
  • Route53 호스팅 영역: 애플리케이션이 서비스될 도메인에 해당하는 기존 Route53 호스팅 영역.
  • Pre-Operator Terraform 파일: pre-operator.tfpre-operator.tfvars와 같은 관련 변수 파일이 올바르게 설정되어 있는지 확인합니다.

Pre-Operator 설정

다음 Terraform 코맨드를 실행하여 Pre-Operator 설정을 초기화하고 구성을 적용합니다.
terraform init -upgrade
terraform apply -var-file=./pre-operator.tfvars
pre-operator.tf는 다음과 유사해야 합니다.
namespace     = "operator-upgrade"
domain_name   = "sandbox-aws.wandb.ml"
zone_id       = "Z032246913CW32RVRY0WU"
subdomain     = "operator-upgrade"
wandb_license = "ey..."
wandb_version = "0.51.2"
pre-operator.tf 설정은 두 개의 모듈을 호출합니다.
module "wandb_infra" {
  source  = "wandb/wandb/aws"
  version = "1.16.10"
  ...
}
이 모듈은 인프라를 구동합니다.
module "wandb_app" {
  source  = "wandb/wandb/kubernetes"
  version = "1.12.0"
}
이 모듈은 애플리케이션을 배포합니다.

Post-Operator 설정

pre-operator.tf.disabled 확장자가 있고 post-operator.tf가 활성화되어 있는지 확인하세요. post-operator.tfvars에는 추가 변수가 포함됩니다.
...
# wandb_version = "0.51.2"는 이제 Release Channel을 통해 관리되거나 User Spec에서 설정됩니다.

# 업그레이드에 필요한 Operator 변수:
size                 = "small"
enable_dummy_dns     = true
enable_operator_alb  = true
custom_domain_filter = "sandbox-aws.wandb.ml"
다음 코맨드를 실행하여 Post-Operator 설정을 초기화하고 구성을 적용합니다.
terraform init -upgrade
terraform apply -var-file=./post-operator.tfvars
plan 및 apply 단계에서 다음 자원이 업데이트됩니다.
actions:
  create:
    - aws_efs_backup_policy.storage_class
    - aws_efs_file_system.storage_class
    - aws_efs_mount_target.storage_class["0"]
    - aws_efs_mount_target.storage_class["1"]
    - aws_eks_addon.efs
    - aws_iam_openid_connect_provider.eks
    - aws_iam_policy.secrets_manager
    - aws_iam_role_policy_attachment.ebs_csi
    - aws_iam_role_policy_attachment.eks_efs
    - aws_iam_role_policy_attachment.node_secrets_manager
    - aws_security_group.storage_class_nfs
    - aws_security_group_rule.nfs_ingress
    - random_pet.efs
    - aws_s3_bucket_acl.file_storage
    - aws_s3_bucket_cors_configuration.file_storage
    - aws_s3_bucket_ownership_controls.file_storage
    - aws_s3_bucket_server_side_encryption_configuration.file_storage
    - helm_release.operator
    - helm_release.wandb
    - aws_cloudwatch_log_group.this[0]
    - aws_iam_policy.default
    - aws_iam_role.default
    - aws_iam_role_policy_attachment.default
    - helm_release.external_dns
    - aws_default_network_acl.this[0]
    - aws_default_route_table.default[0]
    - aws_iam_policy.default
    - aws_iam_role.default
    - aws_iam_role_policy_attachment.default
    - helm_release.aws_load_balancer_controller

  update_in_place:
    - aws_iam_policy.node_IMDSv2
    - aws_iam_policy.node_cloudwatch
    - aws_iam_policy.node_kms
    - aws_iam_policy.node_s3
    - aws_iam_policy.node_sqs
    - aws_eks_cluster.this[0]
    - aws_elasticache_replication_group.default
    - aws_rds_cluster.this[0]
    - aws_rds_cluster_instance.this["1"]
    - aws_default_security_group.this[0]
    - aws_subnet.private[0]
    - aws_subnet.private[1]
    - aws_subnet.public[0]
    - aws_subnet.public[1]
    - aws_launch_template.workers["primary"]

  destroy:
    - kubernetes_config_map.config_map
    - kubernetes_deployment.wandb
    - kubernetes_priority_class.priority
    - kubernetes_secret.secret
    - kubernetes_service.prometheus
    - kubernetes_service.service
    - random_id.snapshot_identifier[0]

  replace:
    - aws_autoscaling_attachment.autoscaling_attachment["primary"]
    - aws_route53_record.alb
    - aws_eks_node_group.workers["primary"]
다음과 유사한 화면을 볼 수 있습니다.
post-operator-apply
post-operator.tf에는 단일 모듈만 존재함에 유의하세요.
module "wandb_infra" {
  source  = "wandb/wandb/aws"
  version = "4.7.2"
  ...
}

Post-Operator 설정의 변경 사항:

  1. 필수 공급자 업데이트: 공급자 호환성을 위해 required_providers.aws.version3.6에서 4.0으로 변경합니다.
  2. DNS 및 로드 밸런서 설정: Ingress를 통해 DNS 레코드 및 AWS 로드 밸런서 설정을 관리하기 위해 enable_dummy_dnsenable_operator_alb를 통합합니다.
  3. 라이선스 및 크기 설정: 새로운 운영 요구 사항에 맞게 licensesize 파라미터를 wandb_infra 모듈로 직접 전달합니다.
  4. 커스텀 도메인 처리: 필요한 경우, kube-system 네임스페이스 내의 External DNS pod 로그를 확인하여 DNS 문제를 해결하기 위해 custom_domain_filter를 사용합니다.
  5. Helm 공급자 설정: Kubernetes 자원을 효과적으로 관리하기 위해 Helm 공급자를 활성화하고 구성합니다.
provider "helm" {
  kubernetes {
    host                   = data.aws_eks_cluster.app_cluster.endpoint
    cluster_ca_certificate = base64decode(data.aws_eks_cluster.app_cluster.certificate_authority[0].data)
    token                  = data.aws_eks_cluster_auth.app_cluster.token
    exec {
      api_version = "client.authentication.k8s.io/v1beta1"
      args        = ["eks", "get-token", "--cluster-name", data.aws_eks_cluster.app_cluster.name]
      command     = "aws"
    }
  }
}
이 종합적인 설정을 통해 Pre-Operator에서 Post-Operator 설정으로의 원활한 전환을 보장하며, operator 모델을 통해 제공되는 새로운 효율성과 기능을 활용할 수 있습니다.