Skip to main content

Custom Resources

Core primitives in Cosmonic Control are represented by Kubernetes custom resources. Custom resources may be declaratively provisioned and managed using the API extensions defined in Custom Resource Definitions (CRDs).

Cosmonic Control uses CRDs for the following custom resources from the k8s.cosmonic.io/v1alpha1 and runtime.wasmcloud.dev/v1alpha1 API packages:

  • Cluster - clusters.k8s.cosmonic.io/v1alpha1
  • Component - components.runtime.wasmcloud.dev/v1alpha1
  • ComponentReplicas - componentreplicas.runtime.wasmcloud.dev/v1alpha1
  • Config - configs.runtime.wasmcloud.dev/v1alpha1
  • Host - hosts.runtime.wasmcloud.dev/v1alpha1
  • HostGroup - hostgroups.k8s.cosmonic.io/v1alpha1
  • Link - links.runtime.wasmcloud.dev/v1alpha1
  • Provider - providers.runtime.wasmcloud.dev/v1alpha1
  • ProviderReplicas - providerreplicas.runtime.wasmcloud.dev/v1alpha1

For complete API specifications, see the API references for k8s.cosmonic.io/v1alpha1 and runtime.wasmcloud.dev/v1alpha1.

Cluster

The Cluster resource represents a wasmCloud cluster control plane.

Example manifest:

apiVersion: k8s.cosmonic.io/v1alpha1
kind: Cluster
metadata:
  name: default
  namespace: default

Component

The Component resource represents a single WebAssembly component, including configs, links, and secrets.

Example manifest:

apiVersion: runtime.wasmcloud.dev/v1alpha1
kind: Component
metadata:
  name: example
spec:
  cluster:
    name: example
    namespace: default
  image: ghcr.io/wasmcloud/components/http-hello-world-rust:0.1.0
  concurrency: 100
  replicas: 1
  exports:
    - wit:
        namespace: wasi
        package: http
        interfaces:
          - incoming-handler
      target:
        provider:
          name: http-server
          namespace: default
        configFrom:
          - name: link-config
            namespace: default

ComponentReplicas

The ComponentReplica resource represents a replica of a WebAssembly component and is owned by a Component resource.

Example manifest:

apiVersion: runtime.wasmcloud.dev/v1alpha1
kind: ComponentReplica
metadata:
  name: <alphanumeric-component-replica-id>
  namespace: web
  ownerReferences:
  - apiVersion: runtime.wasmcloud.dev/v1alpha1
    controller: true
    kind: Component
    name: hello
spec:
  componentId: web-hello
  componentRef:
    name: hello
    namespace: web
  hostId: <alphanumberic-host-id>

Config

The Config resource represents a Link configuration specifying configuration values for a component or provider (e.g. address and port for an HTTP server).

Example manifest:

apiVersion: runtime.wasmcloud.dev/v1alpha1
kind: Config
metadata:
  name: link-config
spec:
  cluster:
    name: example
    namespace: default
  config:
    - name: address
      value: "0.0.0.0:8080"

Host

The Host resource represents a wasmCloud runtime environment called a host.

Example manifest:

apiVersion: runtime.wasmcloud.dev/v1alpha1
kind: Host
metadata:
  name: host-sample
spec:
  cluster:
    name: default
    namespace: default

HostGroup

The HostGroup resource represents a set of wasmCloud hosts belonging to a Cluster.

Example manifest:

apiVersion: k8s.cosmonic.io/v1alpha1
kind: HostGroup
metadata:
  name: default
spec:
  cluster: default
  replicas: 1

The Link resource represents a runtime link between a component and another entity (either a component or provider).

Example manifest:

apiVersion: runtime.wasmcloud.dev/v1alpha1
kind: Link
metadata:
  name: example-to-http-server
spec:
  cluster:
    name: example
    namespace: default
  wit:
    namespace: wasi
    package: http
    interfaces:
      - incoming-handler
  source:
    provider:
      name: http-server
      namespace: default
    configFrom:
      - name: example
        namespace: default
  target:
    component:
      name: example
      namespace: default

Provider

The Provider resource represents a wasmCloud capability provider scheduled in a given namespace.

Example manifest:

apiVersion: runtime.wasmcloud.dev/v1alpha1
kind: Provider
metadata:
  name: http-server
spec:
  cluster:
    name: example
    namespace: default
  image: ghcr.io/wasmcloud/http-server:0.23.1
  replicas: 1

ProviderReplicas

The ProviderReplica resource represents a replica of a WebAssembly component and is owned by a Provider resource.

Example manifest:

apiVersion: runtime.wasmcloud.dev/v1alpha1
kind: ProviderReplica
metadata:
  name: providerreplica-sample
spec:
  hostId: <alphanumeric-host-id>
  providerId: infra-messaging
  providerRef:
    name: messaging
    namespace: infra