Authoring devfilesDefining attributes

Authoring devfiles

Defining attributes

As a developer, you can use devfile attributes to configure various features and properties according to the needs of users and tools. Attributes are implementation-dependent and written in free-form YAML.

Attributes can be defined at the top level of the devfile, or in the following objects:

  • components
  • commands
  • projects
  • starterProjects
  • endpoints
  • metadata: Attributes in metadata are deprecated. Use top-level attributes instead.

Prerequisites

Procedure

  1. Define attributes in a component:

    Java Quarkus example

    ----
    schemaVersion: 2.2.0
    metadata:
      name: java-quarkus
    ...
    components:
      - name: outerloop-deploy
        attributes:
          deployment/replicas: 1
          deployment/cpuLimit: "100m"
          deployment/cpuRequest: 10m
          deployment/memoryLimit: 250Mi
          deployment/memoryRequest: 100Mi
          deployment/container-port: 8081
        kubernetes:
          uri: outerloop-deploy.yaml
    ----
    
  2. Define a custom attribute at the devfile level.

    When no editor is specified, a default editor is provided. To represent this user-defined example, use the editorFree attribute as shown in the following example:

    A devfile without an editor

    ----
    schemaVersion: 2.2.0
    attributes:
        editorFree: true
    metadata:
      name: petclinic-dev-environment
    components:
      - name: myapp
        kubernetes:
          uri: my-app.yaml
    ----
    

Additional resources