Skip to content

Latest commit

 

History

History
111 lines (88 loc) · 5.01 KB

4.component.md

File metadata and controls

111 lines (88 loc) · 5.01 KB

4. Components

Target Role: Application Developer

This section defines components.

The role of a component is to enable developers to declare, in infrastructure-neutral format, the operational characteristics of a discrete unit of execution.

Components describe functional units that may be instantiated as part of a larger distributed application. For example, each microservice in an application is described as a component. The description itself is not an instance of that microservice, but a declaration of the operational capabilities of that microservice. The Application Configuration describes how components are grouped together and how instances of those components are then configured.

Representation

All component schematics are canonically represented as JSON and can be validated using the provided JSON Schema. Because it is more amenable for human consumption, YAML is also supported, and most of the examples are given in YAML. For the sake of validation, YAML may be converted to an equivalent JSON representation before validating it against the JSON Schema.

Top-Level Attributes

These attributes provide top-level information about the component definition.

Attribute Type Required Default Value Description
apiVersion string Y A string that identifies the version of the schema the object should have. The core types uses core.oam.dev/v1alpha2 in this version of specification.
kind string Y Must be Component.
metadata Metadata Y Information about the component.
spec Spec Y A specification for component attributes.

Spec

The spec defines the constituent parts of a component.

Attribute Type Required Default Value Description
workload Workload Y Declaration of settings that should be passed to the workload runtime
parameters []Parameter N The component's configuration options.

Workload

The workload section contains the instantiation of the schema referenced by the corresponding Workload Definition. The schema can be used to validated this section.

Parameter

The Parameters section defines all of the configurable parameters for this component.

Attribute Type Required Default Value Description
name string Y The parameter's name. Must be unique per component.
description string N A description of the parameter.
fieldPaths []string Y JSON field paths.
required boolean N false Whether a value must be provided when authoring an applicationConfiguration including this component.

Parameter name fields must be Unicode letter and number characters. Application Configurations will specify parameters values using this name.

Parameter fieldPaths specifies an array of fields within this Component's workload that will be overwritten by the value of this parameter. fieldPaths are specified as JSON field paths without a leading dot, for example spec.containers[0].image. The type of the parameter is inferred by the type of the fields to which those paths refer. Thus, all fields to which those paths refer MUST have the same type and MUST NOT be object type.

Examples

This section illustrates use of the component schematic defined above to describe a component. This component instantiates a core containerized workload.

apiVersion: core.oam.dev/v1alpha2
kind: Component
metadata:
  name: frontend
  annotations:
    version: v1.0.0
    description: >
      Sample component schematic that describes the administrative interface for our Twitter bot.
spec:
  workload:
    apiVersion: core.oam.dev/v1alpha2
    kind: ContainerizedWorkload
    metadata:
      name: sample-workload
    spec:
      osType: linux
      containers:
      - name: my-cool-workload
        image: example/very-cool-workload:0.1.2@sha256:verytrustworthyhash
        resources:
          cpu:
            required: 1.0
          memory:
            required: 100MB
        cmd:
        - "bash lscpu"
        ports:
        - name: http
          value: 8080
        env:
        - name: CACHE_SECRET
        livenessProbe:
          httpGet:
            port: 8080
            path: /healthz
        readinessProbe:
          httpGet:
            port: 8080
            path: /healthz
  parameters: 
  - name: imageName
    required: false
    fieldPaths: 
    - "spec.containers[0].image"
  - name: cacheSecret
    required: true
    fieldPaths:
    - "spec.containers[0].env[0].value"
Previous Part Next Part
3. Workload Definition 5. Application Scopes