components:
- image:
imageName: quay.io/myusername/myimage
dockerfile:
uri: ./Dockerfile (1)
buildContext: ${PROJECTS_ROOT} (2)
name: component-built-from-dockerfile
odo
can build container images based on Dockerfiles, and push these images to their registries.
When running the odo build-images
command, odo
searches for all components in the devfile.yaml
with the image
type, for example:
components:
- image:
imageName: quay.io/myusername/myimage
dockerfile:
uri: ./Dockerfile (1)
buildContext: ${PROJECTS_ROOT} (2)
name: component-built-from-dockerfile
1 | The uri field indicates the relative path of the Dockerfile to use, relative to the directory containing the devfile.yaml . The devfile specification indicates that uri could also be an HTTP URL, but this case is not supported by odo yet. |
2 | The buildContext indicates the directory used as build context. The default value is ${PROJECTS_ROOT} . |
For each image component, odo executes either podman
or docker
(the first one found, in this order), to build the image with the specified Dockerfile, build context, and arguments.
If the --push
flag is passed to the command, the images are pushed to their registries after they are built.
odo
uses different catalogs to deploy components and services.
odo
uses the portable devfile format to describe the components. It can connect to various devfile registries to download devfiles for different languages and frameworks.
See odo registry
for more information.
To list all the devfiles available on the different registries, run the command:
$ odo catalog list components
NAME DESCRIPTION REGISTRY
go Stack with the latest Go version DefaultDevfileRegistry
java-maven Upstream Maven and OpenJDK 11 DefaultDevfileRegistry
nodejs Stack with Node.js 14 DefaultDevfileRegistry
php-laravel Stack with Laravel 8 DefaultDevfileRegistry
python Python Stack with Python 3.7 DefaultDevfileRegistry
[...]
To get more information about a specific component, run the command:
$ odo catalog describe component
For example, run the command:
$ odo catalog describe component nodejs
* Registry: DefaultDevfileRegistry (1)
Starter Projects: (2)
---
name: nodejs-starter
attributes: {}
description: ""
subdir: ""
projectsource:
sourcetype: ""
git:
gitlikeprojectsource:
commonprojectsource: {}
checkoutfrom: null
remotes:
origin: https://github.com/odo-devfiles/nodejs-ex.git
zip: null
custom: null
1 | Registry is the registry from which the devfile is retrieved. |
2 | Starter projects are sample projects in the same language and framework of the devfile, that can help you start a new project. |
See odo create
for more information on creating a project from a starter project.
odo
can deploy services with the help of Operators.
Only Operators deployed with the help of the Operator Lifecycle Manager are supported by odo.
To list the available Operators and their associated services, run the command:
$ odo catalog list services
Services available through Operators
NAME CRDs
postgresql-operator.v0.1.1 Backup, Database
redis-operator.v0.8.0 RedisCluster, Redis
In this example, two Operators are installed in the cluster. The postgresql-operator.v0.1.1
Operator deploys services related to PostgreSQL: Backup
and Database
.
The redis-operator.v0.8.0
Operator deploys services related to Redis: RedisCluster
and Redis
.
To get a list of all the available Operators, |
To search for a specific service by a keyword, run the command:
$ odo catalog search service
For example, to retrieve the PostgreSQL services, run the command:
$ odo catalog search service postgres
Services available through Operators
NAME CRDs
postgresql-operator.v0.1.1 Backup, Database
You will see a list of Operators that contain the searched keyword in their name.
To get more information about a specific service, run the command:
$ odo catalog describe service
For example:
$ odo catalog describe service postgresql-operator.v0.1.1/Database
KIND: Database
VERSION: v1alpha1
DESCRIPTION:
Database is the Schema for the the Database Database API
FIELDS:
awsAccessKeyId (string)
AWS S3 accessKey/token ID
Key ID of AWS S3 storage. Default Value: nil Required to create the Secret
with the data to allow send the backup files to AWS S3 storage.
[...]
A service is represented in the cluster by a CustomResourceDefinition (CRD) resource. The previous command displays the details about the CRD such as kind
, version
, and the list of fields available to define an instance of this custom resource.
The list of fields is extracted from the OpenAPI schema included in the CRD. This information is optional in a CRD, and if it is not present, it is extracted from the ClusterServiceVersion (CSV) resource representing the service instead.
It is also possible to request the description of an Operator-backed service, without providing CRD type information. To describe the Redis Operator on a cluster, without CRD, run the following command:
$ odo catalog describe service redis-operator.v0.8.0
NAME: redis-operator.v0.8.0
DESCRIPTION:
A Golang based redis operator that will make/oversee Redis
standalone/cluster mode setup on top of the Kubernetes. It can create a
redis cluster setup with best practices on Cloud as well as the Bare metal
environment. Also, it provides an in-built monitoring capability using
... (cut short for beverity)
Logging Operator is licensed under [Apache License, Version
2.0](https://github.com/OT-CONTAINER-KIT/redis-operator/blob/master/LICENSE)
CRDs:
NAME DESCRIPTION
RedisCluster Redis Cluster
Redis Redis
odo
uses a devfile to store the configuration of a component and to describe the component’s resources such as storage and services. The odo create command generates this file.
To create a devfile for an existing project, run the odo create
command with the name and type of your component (for example, nodejs
or go
):
odo create nodejs mynodejs
In the example, nodejs
is the type of the component and mynodejs
is the name of the component that odo
creates for you.
For a list of all the supported component types, run the command |
If your source code exists outside the current directory, the --context
flag can be used to specify the path.
For example, if the source for the nodejs component is in a folder called node-backend
relative to the current working directory, run the command:
odo create nodejs mynodejs --context ./node-backend
The --context
flag supports relative and absolute paths.
To specify the project or app where your component will be deployed, use the --project
and --app
flags.
For example, to create a component that is part of the myapp
app inside the backend
project, run the command:
odo create nodejs --app myapp --project backend
If these flags are not specified, they will default to the active app and project. |
Use the starter projects if you do not have existing source code but want to get up and running quickly to experiment with devfiles and components.
To use a starter project, add the --starter
flag to the odo create
command.
To get a list of available starter projects for a component type, run the odo catalog describe component
command.
For example, to get all available starter projects for the nodejs component type, run the command:
odo catalog describe component nodejs
Then specify the desired project using the --starter
flag on the odo create
command:
odo create nodejs --starter nodejs-starter
This will download the example template corresponding to the chosen component type, in this instance, nodejs
.
The template is downloaded to your current directory, or to the location specified by the --context
flag.
If a starter project has its own devfile, then this devfile will be preserved.
If you want to create a new component from an existing devfile, you can do so by specifying the path to the devfile using the --devfile
flag.
For example, to create a component called mynodejs
, based on a devfile from GitHub, use the following command:
odo create mynodejs --devfile https://raw.githubusercontent.com/odo-devfiles/registry/master/devfiles/nodejs/devfile.yaml
You can also run the odo create
command interactively, to guide you through the steps needed to create a component:
$ odo create
? Which devfile component type do you wish to create go
? What do you wish to name the new devfile component go-api
? What project do you want the devfile component to be created in default
Devfile Object Validation
✓ Checking devfile existence [164258ns]
✓ Creating a devfile component from registry: DefaultDevfileRegistry [246051ns]
Validation
✓ Validating if devfile name is correct [92255ns]
? Do you want to download a starter project Yes
Starter Project
✓ Downloading starter project go-starter from https://github.com/devfile-samples/devfile-stack-go.git [429ms]
Please use odo push
command to create the component with source deployed
You are prompted to choose the component type, name, and the project for the component. You can also choose whether or not to download a starter project. Once finished, a new devfile.yaml
file is created in the working directory.
To deploy these resources to your cluster, run the command odo push
.
The odo delete
command is useful for deleting resources that are managed by odo
.
To delete a devfile component, run the odo delete
command:
$ odo delete
If the component has been pushed to the cluster, the component is deleted from the cluster, along with its dependent storage, URL, secrets, and other resources. If the component has not been pushed, the command exits with an error stating that it could not find the resources on the cluster.
Use the -f
or --force
flag to avoid the confirmation questions.
To undeploy the devfile Kubernetes components, that have been deployed with odo deploy
, execute the odo delete
command with the --deploy
flag:
$ odo delete --deploy
Use the -f
or --force
flag to avoid the confirmation questions.