Adding kubernetes component
This section describes how to add a
kubernetes component to a devfile. A complex component type that allows to apply configuration from a list of Kubernetes or OpenShift components.
Define a component using the type
The content can be provided through the
referenceattribute, which points to the file with the component content.
Adding kubernetes component using the reference attributedevfile.yaml
components: - name: mysql kubernetes: reference: petclinic.yaml selector: app.kubernetes.io/name: mysql app.kubernetes.io/component: database app.kubernetes.io/part-of: petclinic
Alternatively, to post a devfile with such components to REST API, the contents of the Kubernetes or OpenShift list can be embedded into the devfile using the
Adding kubernetes component using the referenceContent attributedevfile.yaml
components: - name: mysql kubernetes: reference: petclinic.yaml referenceContent: | kind: List items: - apiVersion: v1 kind: Pod metadata: name: ws spec: containers: ... etc
Overriding container entrypoints. As with the
containercomponent, it is possible to override the entrypoint of the containers contained in the Kubernetes or OpenShift list using the
argsproperties (as understood by Kubernetes).
There can be more containers in the list (contained in Pods or Pod templates of deployments). It is therefore necessary to select which containers to apply the entrypoint changes to as follows:
Overriding container entrypointsdevfile.yaml
components: - name: appDeployment kubernetes: reference: app-deployment.yaml entrypoints: - parentName: mysqlServer command: ['sleep'] args: ['infinity'] - parentSelector: app: prometheus args: ['-f', '/opt/app/prometheus-config.yaml']
entrypointslist contains constraints for picking the containers along with the
argsparameters to apply to them. In the example above, the constraint is
parentName: mysqlServer, which will cause the command to be applied to all containers defined in any parent object called
mysqlServer. The parent object is assumed to be a top level object in the list defined in the referenced file, which is
app-deployment.yamlin the example above.
Other types of constraints (and their combinations) are possible:
containerNamethe name of the container
parentNamethe name of the parent object that (indirectly) contains the containers to override
parentSelectorthe set of labels the parent object needs to have
A combination of these constraints can be used to precisely locate the containers inside the referenced Kubernetes list.
Overriding container environment variables
To provision or override entrypoints in a Kubernetes or OpensShift component, configure it in the following way:
Overriding container environment variablesdevfile.yaml
components: - name: appDeployment kubernetes: reference: app-deployment.yaml env: - name: ENV_VAR value: value
This is useful for temporary content or without access to editing the referenced content. The specified environment variables are provisioned into each init container and containers inside all Pods and Deployments.
Specifying mount-source option
To specify a project sources directory mount into container(s), use the
Specifying mount-source optiondevfile.yaml
components: - name: appDeployment kubernetes: reference: app-deployment.yaml mountSources: true
If enabled, project sources mounts will be applied to every container of the given component. This parameter is also applicable for