Adding components to a devfile

Each component in a single devfile must have a unique name and use one of the objects: container, kubernetes, openshift, or volume. See the following tables for component properties in a devfile:

Table 1. Component object
Key Type Required Description

container

componentObject

no

The list of containers that you use.

Table 2. container object
Key Type Required Description

name

string

yes

The name of your container.

image

string

yes

The image version.

memoryLimit

string

no

The memory limit that you use with your container.

mountSources

boolean

no

Choose to mount the source or not.

sourceMapping

string

no

The path in the container where you transfer and mount the project sources. This path is available in the container through the environment, PROJECTS_ROOT.

endpoints

endpointObject

no

The list of endpoints to use.

volumeMounts

volumeMountsObject

no

The list of volumes to mount.

environment

envObject

no

The list of environment variables to use.

Table 3. endpoint object
Key Type Required Description

name

string

yes

The name of your endpoint.

targetPort

integer

yes

The port number that you target.

exposure

string

no

Use the following attributes to describe how to expose the endpoints on the network: public, internal, none. If not specified, the default attribute is public.

path

string

no

The path to the endpoint URL.

protocol

string

no

Use the following attributes to describe the application and transport protocols of the traffic that goes through the endpoint: http, https, ws, wss, tcp, udp. If not specified, the default attribute is http.

secure

boolean

no

Choose to define the endpoint as secure or not.

Table 4. volume object
Key Type Required Description

name

string

yes

The name of the volume components that you use.

path

string

no

The path in the component container where you mount the volume.

name

string

yes

The name of the volume component.

size

string

no

The size of the storage you create.

Procedure
  1. Add a components section in the devfile, containing a list of one or more components.

  2. For each component, define an unique value for the mandatory name attribute.

  3. For each component, define a mandatory type of one of the following types: kubernetes, container or volume.

  4. Adding a kubernetes or openshift component to a devfile

  5. Adding container components to a devfile

  6. Specifying persistent storage

  7. Limiting resources usage

  8. Defining environment variables

  9. Defining endpoints

  10. Defining Kubernetes resources

Additional resources