AKS(Azure Kubernetes Service)에서 wasmCloud 사용

WebAssembly 구성 요소는 애플리케이션을 빌드하고 배포하는 새로운 방법입니다. 이러한 컴파일러는 프로그래밍 언어에 대한 이식 가능 컴파일 대상으로 설계되었으며 다양한 환경에서 실행할 수 있습니다. WebAssembly 구성 요소는 설계상 샌드박스화되어 있으며 정의된 인터페이스를 사용하여 기능을 제공합니다. 구성 요소는 컨테이너와 달리 훨씬 작고 빠르게 시작할 수 있는 단일 이진입니다. 사양에서 모델에 대한 전체 설명과 구성 요소를 찾습니다.

wasmCloud는 WebAssembly 구성 요소의 개발, 배포 및 오케스트레이션을 빠르게 추진하도록 설계된 CNCF(Cloud Native Computing Foundation) 프로젝트입니다. 이 문서에서는 AKS(Azure Kubernetes Service) 클러스터에 wasmCloud를 배포하는 방법에 대한 지침을 자세히 설명합니다.

시작하기 전 주의 사항:

필수 조건

  • Azure Portal을 사용하여 wasmCloud를 AKS 클러스터에 배포할 수 없습니다.

wasmCloud 배포

AKS 클러스터에 wasmCloud를 배포하려면 클러스터에 일체형 Helm 차트를 설치해야 합니다. 이렇게 하면 다음 서비스가 단일 네임스페이스에 설치됩니다.

  • NATS: NATS는 wasmCloud의 구성 요소 간 모든 통신을 위한 백본을 제공합니다.
  • wadm: wasmCloud 애플리케이션 관리자, 즉 wadm은 wasmCloud 상에서 실행되는 애플리케이션을 관리하는 오케스트레이터입니다.
  • wasmCloud 운영자: wasmCloud 운영자는 wasmCloud 호스트의 수명 주기를 관리하는 Kubernetes 운영자입니다.

wasmCloud를 전용 Kubernetes 네임스페이스에 배포하는 것이 좋습니다.

  1. kubectl을 사용하여 wasmCloud에 대한 네임스페이스를 만듭니다.

    kubectl create namespace wasmcloud
    
  2. helm upgrade 명령을 사용하여 wasmCloud 네임스페이스에 NATS와 wadm을 설치합니다.

    # By default, the chart installs NATS, Wadm, and wasmCloud Operator subcharts
     helm upgrade --install \
          wasmcloud-platform \
          --values https://raw.githubusercontent.com/wasmCloud/wasmcloud/main/charts/wasmcloud-platform/values.yaml \
          oci://ghcr.io/wasmcloud/charts/wasmcloud-platform:0.1.2 \
          --dependency-update
    

    이 명령의 출력은 다음과 유사해야 합니다.

    NAME: wasmcloud-platform
    LAST DEPLOYED: Thu Nov  7 14:58:54 2024
    NAMESPACE: default
    STATUS: deployed
    REVISION: 1
    NOTES:
    
  3. 모든 Pod가 kubectl을 사용할 때까지 기다립니다.

    kubectl rollout status deploy,sts -l app.kubernetes.io/name=nats
    kubectl wait --for=condition=available --timeout=600s deploy -l app.kubernetes.io/name=wadm
    kubectl wait --for=condition=available --timeout=600s deploy -l app.kubernetes.io/name=wasmcloud-operator
    
  4. CRD와 kubectl을 사용하여 wasmCloud 호스트를 시작합니다.

    cat << EOF | kubectl apply -f -
    apiVersion: k8s.wasmcloud.dev/v1alpha1
    kind: WasmCloudHostConfig
    metadata:
      name: wasmcloud-host
    spec:
      lattice: default
      version: "1.4.1"
    EOF
    
    
  5. wasmCloud 호스트가 실행 중인지 확인합니다.

    kubectl get pod -l app.kubernetes.io/instance=wasmcloud-host
    

    출력은 다음과 유사해야 합니다.

    NAME                             READY   STATUS    RESTARTS   AGE
    wasmcloud-host-f9d67b8cf-lvsq6   2/2     Running   0          84s
    
  6. wash를 사용하여 wasmCloud 호스트에 연결할 수 있는지 확인합니다.

    별도의 셸에서 다음 명령을 실행하여 실행 중인 NATS Pod 중 하나로 포트 전달합니다.

    kubectl port-forward nats-0 4222
    

    이 명령은 포트 4222의 모든 트래픽을 클러스터에서 실행 중인 NATS Pod로 로컬로 전달합니다. wash를 사용하여 wasmCloud에 연결하려면 이 포트를 전달해야 합니다.

    원래 셸에서 wash로 다음 명령을 실행하여 wasmCloud 호스트가 실행 중인지 확인합니다.

    wash get hosts
    

    출력은 다음과 유사해야 합니다.

      Host ID                                                      Friendly name           Uptime (seconds)
      ND2G4FRXLBCV3YL52OD4NRSS66Z5YOR3JOSL3Q7T5I6ZJM4EII3Y73CZ     frosty-resonance-6227   312
    

wasmCloud 애플리케이션 배포

이제 wasmCloud가 AKS 클러스터에서 실행되므로 wasmCloud 애플리케이션을 배포할 수 있습니다. wasmCloud 애플리케이션은 wadm(wasmCloud 애플리케이션 관리자)에 의해 오케스트레이션되는 WebAssembly 구성 요소의 컬렉션입니다.

  1. wasmCloud 애플리케이션 매니페스트 파일을 만듭니다. 이 파일은 애플리케이션을 구성하는 구성 요소를 설명합니다. 다음 yaml 파일을 hello-world.yaml로 저장합니다.

    apiVersion: core.oam.dev/v1beta1
    kind: Application
    metadata:
      name: hello-world
      annotations:
        description: 'HTTP hello world demo in Rust, using the WebAssembly Component Model and WebAssembly Interfaces Types (WIT)'
    spec:
      components:
        - name: http-component
          type: component
          properties:
            image: ghcr.io/wasmcloud/components/http-hello-world-rust:0.1.0
          traits:
            # Govern the spread/scheduling of the component
            - type: spreadscaler
              properties:
                instances: 1
    
        # Add a capability provider that enables HTTP access
        - name: httpserver
          type: capability
          properties:
            image: ghcr.io/wasmcloud/http-server:0.23.2
          traits:
            # Establish a unidirectional link from this http server provider (the "source")
            # to the `http-component` component (the "target") so the component can handle incoming HTTP requests,
            #
            # The source (this provider) is configured such that the HTTP server listens on 0.0.0.0:8080
            - type: link
              properties:
                target: http-component
                namespace: wasi
                package: http
                interfaces: [incoming-handler]
                source_config:
                  - name: default-http
                    properties:
                      address: 0.0.0.0:8080
    
  2. wash를 사용하여 wasmCloud 애플리케이션을 배포합니다.

    wash app deploy hello-world.yaml
    

    출력은 다음과 유사해야 합니다.

    Deployed application "hello-world", version "01JC44TVDBC2V6MJ1NJTKNNX1J"
    
  3. wash를 사용하여 애플리케이션이 실행 중인지 확인합니다.

    wash app status hello-world
    

    출력은 다음과 유사해야 합니다.

    Name                                         Kind           Status
    http_component                               SpreadScaler   Deployed
    httpserver -(wasi:http)-> http_component     LinkScaler     Deployed
    httpserver                                   SpreadScaler   Deployed
    

    필요한 경우 모든 구성 요소가 Deployed 상태가 될 때까지 이 명령을 반복합니다.

  4. curl 및 kubectl port-forward를 사용하여 http 구성 요소를 호출합니다.

    별도의 셸에서 다음 명령을 실행하여 hello-world 애플리케이션으로 포트 전달합니다.

    kubectl port-forward port-forward deployment/wasmcloud-host 8080
    

    이 명령은 포트 8080의 모든 트래픽을 클러스터에서 실행 중인 wasmCloud 호스트로 로컬로 전달합니다. curl를 사용하여 wasmCloud에 연결하려면 이 포트를 전달해야 합니다.

    원래 셸에서 다음 명령을 실행하여 http 구성 요소를 호출합니다.

    curl http://localhost:8080
    

    출력은 다음과 유사해야 합니다.

    Hello from Rust!
    
  5. 설치된 리소스 정리

    만든 리소스를 정리하려면 다음 명령을 실행합니다.

    kubectl delete namespace wasmcloud
    

    이 명령은 AKS 클러스터에서 wasmCloud 구성 요소를 제거합니다.

다음 단계

wasmCloud 빠른 시작 가이드에 따라 계속해서 학습할 수 있습니다. 이 가이드에서는 처음부터 WebAssembly 구성 요소를 만드는 방법, 다양한 wasmCloud 기능을 사용하는 방법, 애플리케이션의 크기를 조정하는 방법을 안내합니다.