Este contenido no está disponible en el idioma seleccionado.
Chapter 3. Developer CLI (odo)
3.1. odo release notes Copiar enlaceEnlace copiado en el portapapeles!
3.1.1. Notable changes and improvements in odo version 2.5.0 Copiar enlaceEnlace copiado en el portapapeles!
-
Creates unique routes for each component, using hashing
adler32 Supports additional fields in the devfile for assigning resources:
- cpuRequest
- cpuLimit
- memoryRequest
- memoryLimit
Adds the
flag to the--deploycommand, to remove components deployed using theodo deletecommand:odo deploy$ odo delete --deploy-
Adds mapping support to the command
odo link -
Supports ephemeral volumes using the field in
ephemeralcomponentsvolume -
Sets the default answer to when asking for telemetry opt-in
yes - Improves metrics by sending additional telemetry data to the devfile registry
-
Updates the bootstrap image to
registry.access.redhat.com/ocp-tools-4/odo-init-container-rhel8:1.1.11 - The upstream repository is available at https://github.com/redhat-developer/odo
3.1.2. Bug fixes Copiar enlaceEnlace copiado en el portapapeles!
-
Previously, would fail if the
odo deployfile did not exist. The command now creates the.odo/envfile if required..odo/env -
Previously, interactive component creation using the command would fail if disconnect from the cluster. This issue is fixed in the latest release.
odo create
3.1.3. Getting support Copiar enlaceEnlace copiado en el portapapeles!
For Product
If you find an error, encounter a bug, or have suggestions for improving the functionality of
odo
Provide as many details in the issue description as possible.
For Documentation
If you find an error or have suggestions for improving the documentation, file a Jira issue for the most relevant documentation component.
3.2. Understanding odo Copiar enlaceEnlace copiado en el portapapeles!
Red Hat OpenShift Developer CLI (
odo
odo
odo
odo
odo
odo
3.2.1. odo key features Copiar enlaceEnlace copiado en el portapapeles!
odo
- Quickly deploy applications on a Kubernetes cluster by creating a new manifest or using an existing one
- Use commands to easily create and update the manifest, without the need to understand and maintain Kubernetes configuration files
- Provide secure access to applications running on a Kubernetes cluster
- Add and remove additional storage for applications on a Kubernetes cluster
- Create Operator-backed services and link your application to them
-
Create a link between multiple microservices that are deployed as components
odo -
Remotely debug applications you deployed using in your IDE
odo -
Easily test applications deployed on Kubernetes using
odo
3.2.2. odo core concepts Copiar enlaceEnlace copiado en el portapapeles!
odo
- Application
A typical application, developed with a cloud-native approach, that is used to perform a particular task.
Examples of applications include online video streaming, online shopping, and hotel reservation systems.
- Component
A set of Kubernetes resources that can run and be deployed separately. A cloud-native application is a collection of small, independent, loosely coupled components.
Examples of components include an API back-end, a web interface, and a payment back-end.
- Project
- A single unit containing your source code, tests, and libraries.
- Context
-
A directory that contains the source code, tests, libraries, and
odoconfig files for a single component. - URL
- A mechanism to expose a component for access from outside the cluster.
- Storage
- Persistent storage in the cluster. It persists the data across restarts and component rebuilds.
- Service
An external application that provides additional functionality to a component.
Examples of services include PostgreSQL, MySQL, Redis, and RabbitMQ.
In
, services are provisioned from the OpenShift Service Catalog and must be enabled within your cluster.odo- devfile
An open standard for defining containerized development environments that enables developer tools to simplify and accelerate workflows. For more information, see the documentation at https://devfile.io.
You can connect to publicly available devfile registries, or you can install a Secure Registry.
3.2.3. Listing components in odo Copiar enlaceEnlace copiado en el portapapeles!
odo
odo
odo registry
odo
You can list all the devfiles available of the different registries with the
odo catalog list components
Procedure
Log in to the cluster with
:odo$ odo login -u developer -p developerList the available
components:odo$ odo catalog list componentsExample output
Odo Devfile Components: NAME DESCRIPTION REGISTRY dotnet50 Stack with .NET 5.0 DefaultDevfileRegistry dotnet60 Stack with .NET 6.0 DefaultDevfileRegistry dotnetcore31 Stack with .NET Core 3.1 DefaultDevfileRegistry go Stack with the latest Go version DefaultDevfileRegistry java-maven Upstream Maven and OpenJDK 11 DefaultDevfileRegistry java-openliberty Java application Maven-built stack using the Open Liberty ru... DefaultDevfileRegistry java-openliberty-gradle Java application Gradle-built stack using the Open Liberty r... DefaultDevfileRegistry java-quarkus Quarkus with Java DefaultDevfileRegistry java-springboot Spring Boot® using Java DefaultDevfileRegistry java-vertx Upstream Vert.x using Java DefaultDevfileRegistry java-websphereliberty Java application Maven-built stack using the WebSphere Liber... DefaultDevfileRegistry java-websphereliberty-gradle Java application Gradle-built stack using the WebSphere Libe... DefaultDevfileRegistry java-wildfly Upstream WildFly DefaultDevfileRegistry java-wildfly-bootable-jar Java stack with WildFly in bootable Jar mode, OpenJDK 11 and... DefaultDevfileRegistry nodejs Stack with Node.js 14 DefaultDevfileRegistry nodejs-angular Stack with Angular 12 DefaultDevfileRegistry nodejs-nextjs Stack with Next.js 11 DefaultDevfileRegistry nodejs-nuxtjs Stack with Nuxt.js 2 DefaultDevfileRegistry nodejs-react Stack with React 17 DefaultDevfileRegistry nodejs-svelte Stack with Svelte 3 DefaultDevfileRegistry nodejs-vue Stack with Vue 3 DefaultDevfileRegistry php-laravel Stack with Laravel 8 DefaultDevfileRegistry python Python Stack with Python 3.7 DefaultDevfileRegistry python-django Python3.7 with Django DefaultDevfileRegistry
3.2.4. Telemetry in odo Copiar enlaceEnlace copiado en el portapapeles!
odo
odo
odo
You can modify your telemetry consent by using the
odo preference
-
consents to telemetry.
odo preference set ConsentTelemetry true -
disables telemetry.
odo preference unset ConsentTelemetry -
shows the current preferences.
odo preference view
3.3. Installing odo Copiar enlaceEnlace copiado en el portapapeles!
You can install the
odo
odo
oc
odo
Currently,
odo
3.3.1. Installing odo on Linux Copiar enlaceEnlace copiado en el portapapeles!
The
odo
| Operating System | Binary | Tarball |
|---|---|---|
| Linux | ||
| Linux on IBM Power | ||
| Linux on IBM Z and LinuxONE |
Procedure
Navigate to the content gateway and download the appropriate file for your operating system and architecture.
If you download the binary, rename it to
:odo$ curl -L https://developers.redhat.com/content-gateway/rest/mirror/pub/openshift-v4/clients/odo/latest/odo-linux-amd64 -o odoIf you download the tarball, extract the binary:
$ curl -L https://developers.redhat.com/content-gateway/rest/mirror/pub/openshift-v4/clients/odo/latest/odo-linux-amd64.tar.gz -o odo.tar.gz $ tar xvzf odo.tar.gz
Change the permissions on the binary:
$ chmod +x <filename>Place the
binary in a directory that is on yourodo.PATHTo check your
, execute the following command:PATH$ echo $PATHVerify that
is now available on your system:odo$ odo version
3.3.2. Installing odo on Windows Copiar enlaceEnlace copiado en el portapapeles!
The
odo
| Operating System | Binary | Tarball |
|---|---|---|
| Windows |
Procedure
Navigate to the content gateway and download the appropriate file:
-
If you download the binary, rename it to .
odo.exe -
If you download the archive, unzip the binary with a ZIP program and then rename it to .
odo.exe
-
If you download the binary, rename it to
Move the
binary to a directory that is on yourodo.exe.PATHTo check your
, open the command prompt and execute the following command:PATHC:\> pathVerify that
is now available on your system:odoC:\> odo version
3.3.3. Installing odo on macOS Copiar enlaceEnlace copiado en el portapapeles!
The
odo
| Operating System | Binary | Tarball |
|---|---|---|
| macOS |
Procedure
Navigate to the content gateway and download the appropriate file:
If you download the binary, rename it to
:odo$ curl -L https://developers.redhat.com/content-gateway/rest/mirror/pub/openshift-v4/clients/odo/latest/odo-darwin-amd64 -o odoIf you download the tarball, extract the binary:
$ curl -L https://developers.redhat.com/content-gateway/rest/mirror/pub/openshift-v4/clients/odo/latest/odo-darwin-amd64.tar.gz -o odo.tar.gz $ tar xvzf odo.tar.gz
Change the permissions on the binary:
# chmod +x odoPlace the
binary in a directory that is on yourodo.PATHTo check your
, execute the following command:PATH$ echo $PATHVerify that
is now available on your system:odo$ odo version
3.3.4. Installing odo on VS Code Copiar enlaceEnlace copiado en el portapapeles!
The OpenShift VS Code extension uses both
odo
oc
Prerequisites
- You have installed VS Code.
Procedure
- Open VS Code.
-
Launch VS Code Quick Open with +
Ctrl.P Enter the following command:
$ ext install redhat.vscode-openshift-connector
3.3.5. Installing odo on Red Hat Enterprise Linux (RHEL) using an RPM Copiar enlaceEnlace copiado en el portapapeles!
For Red Hat Enterprise Linux (RHEL), you can install the
odo
Procedure
Register with Red Hat Subscription Manager:
# subscription-manager registerPull the latest subscription data:
# subscription-manager refreshList the available subscriptions:
# subscription-manager list --available --matches '*OpenShift Developer Tools and Services*'In the output of the previous command, find the
field for your OpenShift Container Platform subscription and attach the subscription to the registered system:Pool ID# subscription-manager attach --pool=<pool_id>Enable the repositories required by
:odo# subscription-manager repos --enable="ocp-tools-4.9-for-rhel-8-x86_64-rpms"Install the
package:odo# yum install odoVerify that
is now available on your system:odo$ odo version
3.4. Configuring the odo CLI Copiar enlaceEnlace copiado en el portapapeles!
You can find the global settings for
odo
preference.yaml
$HOME/.odo
You can set a different location for the
preference.yaml
GLOBALODOCONFIG
3.4.1. Viewing the current configuration Copiar enlaceEnlace copiado en el portapapeles!
You can view the current
odo
$ odo preference view
Example output
PARAMETER CURRENT_VALUE
UpdateNotification
NamePrefix
Timeout
BuildTimeout
PushTimeout
Ephemeral
ConsentTelemetry true
3.4.2. Setting a value Copiar enlaceEnlace copiado en el portapapeles!
You can set a value for a preference key by using the following command:
$ odo preference set <key> <value>
Preference keys are case-insensitive.
Example command
$ odo preference set updatenotification false
Example output
Global preference was successfully updated
3.4.3. Unsetting a value Copiar enlaceEnlace copiado en el portapapeles!
You can unset a value for a preference key by using the following command:
$ odo preference unset <key>
You can use the
-f
Example command
$ odo preference unset updatenotification
? Do you want to unset updatenotification in the preference (y/N) y
Example output
Global preference was successfully updated
3.4.4. Preference key table Copiar enlaceEnlace copiado en el portapapeles!
The following table shows the available options for setting preference keys for the
odo
| Preference key | Description | Default value |
|---|---|---|
|
| Control whether a notification to update
| True |
|
| Set a default name prefix for an
| Current directory name |
|
| Timeout for the Kubernetes server connection check. | 1 second |
|
| Timeout for waiting for a build of the git component to complete. | 300 seconds |
|
| Timeout for waiting for a component to start. | 240 seconds |
|
| Controls whether
| True |
|
| Controls whether
| False |
3.4.5. Ignoring files or patterns Copiar enlaceEnlace copiado en el portapapeles!
You can configure a list of files or patterns to ignore by modifying the
.odoignore
odo push
odo watch
If the
.odoignore
.gitignore
To ignore
.git
.js
tests
.odoignore
.gitignore
.git
*.js
tests/
The
.odoignore
3.5. odo CLI reference Copiar enlaceEnlace copiado en el portapapeles!
3.5.1. odo build-images Copiar enlaceEnlace copiado en el portapapeles!
odo
When running the
odo build-images
odo
devfile.yaml
image
components:
- image:
imageName: quay.io/myusername/myimage
dockerfile:
uri: ./Dockerfile
buildContext: ${PROJECTS_ROOT}
name: component-built-from-dockerfile
- 1
- The
urifield indicates the relative path of the Dockerfile to use, relative to the directory containing thedevfile.yaml. The devfile specification indicates thaturicould also be an HTTP URL, but this case is not supported by odo yet. - 2
- The
buildContextindicates the directory used as build context. The default value is${PROJECTS_ROOT}.
For each image component, odo executes either
podman
docker
If the
--push
3.5.2. odo catalog Copiar enlaceEnlace copiado en el portapapeles!
odo
3.5.2.1. Components Copiar enlaceEnlace copiado en el portapapeles!
odo
odo registry
3.5.2.1.1. Listing components Copiar enlaceEnlace copiado en el portapapeles!
To list all the devfiles available on the different registries, run the command:
$ odo catalog list components
Example output
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
[...]
3.5.2.1.2. Getting information about a component Copiar enlaceEnlace copiado en el portapapeles!
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
Example output
* Registry: DefaultDevfileRegistry
Starter Projects:
---
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
See
odo create
3.5.2.2. Services Copiar enlaceEnlace copiado en el portapapeles!
odo
Only Operators deployed with the help of the Operator Lifecycle Manager are supported by odo.
3.5.2.2.1. Listing services Copiar enlaceEnlace copiado en el portapapeles!
To list the available Operators and their associated services, run the command:
$ odo catalog list services
Example output
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
Backup
Database
redis-operator.v0.8.0
RedisCluster
Redis
To get a list of all the available Operators,
odo
odo
3.5.2.2.2. Searching services Copiar enlaceEnlace copiado en el portapapeles!
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
Example output
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.
3.5.2.2.3. Getting information about a service Copiar enlaceEnlace copiado en el portapapeles!
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
Example output
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
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
Example output
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
3.5.3. odo create Copiar enlaceEnlace copiado en el portapapeles!
odo
3.5.3.1. Creating a component Copiar enlaceEnlace copiado en el portapapeles!
To create a devfile for an existing project, run the
odo create
nodejs
go
odo create nodejs mynodejs
In the example,
nodejs
mynodejs
odo
For a list of all the supported component types, run the command
odo catalog list components
If your source code exists outside the current directory, the
--context
node-backend
odo create nodejs mynodejs --context ./node-backend
The
--context
To specify the project or app where your component will be deployed, use the
--project
--app
myapp
backend
odo create nodejs --app myapp --project backend
If these flags are not specified, they will default to the active app and project.
3.5.3.2. Starter projects Copiar enlaceEnlace copiado en el portapapeles!
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
odo create
To get a list of available starter projects for a component type, run the
odo catalog describe component
odo catalog describe component nodejs
Then specify the desired project using the
--starter
odo create
odo create nodejs --starter nodejs-starter
This will download the example template corresponding to the chosen component type, in this instance,
nodejs
--context
3.5.3.3. Using an existing devfile Copiar enlaceEnlace copiado en el portapapeles!
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
mynodejs
odo create mynodejs --devfile https://raw.githubusercontent.com/odo-devfiles/registry/master/devfiles/nodejs/devfile.yaml
3.5.3.4. Interactive creation Copiar enlaceEnlace copiado en el portapapeles!
You can also run the
odo create
$ 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
To deploy these resources to your cluster, run the command
odo push
3.5.4. odo delete Copiar enlaceEnlace copiado en el portapapeles!
The
odo delete
odo
3.5.4.1. Deleting a component Copiar enlaceEnlace copiado en el portapapeles!
To delete a devfile component, run the
odo delete
$ 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
--force
3.5.4.2. Undeploying devfile Kubernetes components Copiar enlaceEnlace copiado en el portapapeles!
To undeploy the devfile Kubernetes components, that have been deployed with
odo deploy
odo delete
--deploy
$ odo delete --deploy
Use the
-f
--force
3.5.4.3. Delete all Copiar enlaceEnlace copiado en el portapapeles!
To delete all artifacts including the following items, run the
odo delete
--all
- devfile component
-
Devfile Kubernetes component that was deployed using the command
odo deploy - Devfile
- Local configuration
$ odo delete --all
3.5.4.4. Available flags Copiar enlaceEnlace copiado en el portapapeles!
-f,--force- Use this flag to avoid the confirmation questions.
-w,--wait- Use this flag to wait for component deletion and any dependencies. This flag does not work when undeploying.
The documentation on Common Flags provides more information on the flags available for commands.
3.5.5. odo deploy Copiar enlaceEnlace copiado en el portapapeles!
odo
odo
When running the command
odo deploy
odo
deploy
deploy
The
deploy
-
A command referencing an component that, when applied, will build the image of the container to deploy, and then push it to its registry.
image - A command referencing a Kubernetes component that, when applied, will create a Kubernetes resource in the cluster.
With the following example
devfile.yaml
Dockerfile
schemaVersion: 2.2.0
[...]
variables:
CONTAINER_IMAGE: quay.io/phmartin/myimage
commands:
- id: build-image
apply:
component: outerloop-build
- id: deployk8s
apply:
component: outerloop-deploy
- id: deploy
composite:
commands:
- build-image
- deployk8s
group:
kind: deploy
isDefault: true
components:
- name: outerloop-build
image:
imageName: "{{CONTAINER_IMAGE}}"
dockerfile:
uri: ./Dockerfile
buildContext: ${PROJECTS_ROOT}
- name: outerloop-deploy
kubernetes:
inlined: |
kind: Deployment
apiVersion: apps/v1
metadata:
name: my-component
spec:
replicas: 1
selector:
matchLabels:
app: node-app
template:
metadata:
labels:
app: node-app
spec:
containers:
- name: main
image: {{CONTAINER_IMAGE}}
3.5.6. odo link Copiar enlaceEnlace copiado en el portapapeles!
The
odo link
odo
odo
odo
3.5.6.1. Various linking options Copiar enlaceEnlace copiado en el portapapeles!
odo
odo
3.5.6.1.1. Default behavior Copiar enlaceEnlace copiado en el portapapeles!
By default, the
odo link
kubernetes/
odo push
odo
3.5.6.1.2. The --inlined flag Copiar enlaceEnlace copiado en el portapapeles!
If you specify the
--inlined
odo link
odo
devfile.yaml
kubernetes/
--inlined
odo link
odo service create
devfile.yaml
--inlined
odo link
odo service create
3.5.6.1.3. The --map flag Copiar enlaceEnlace copiado en el portapapeles!
Sometimes, you might want to add more binding information to the component, in addition to what is available by default. For example, if you are linking the component with a service and would like to bind some information from the service’s spec (short for specification), you could use the
--map
odo
3.5.6.1.4. The --bind-as-files flag Copiar enlaceEnlace copiado en el portapapeles!
For all the linking options discussed so far,
odo
--bind-as-files
odo
/bindings
--bind-as-files
3.5.6.2. Examples Copiar enlaceEnlace copiado en el portapapeles!
3.5.6.2.1. Default odo link Copiar enlaceEnlace copiado en el portapapeles!
In the following example, the backend component is linked with the PostgreSQL service using the default
odo link
$ odo list
Sample output
APP NAME PROJECT TYPE STATE MANAGED BY ODO
app backend myproject spring Pushed Yes
$ odo service list
Sample output
NAME MANAGED BY ODO STATE AGE
PostgresCluster/hippo Yes (backend) Pushed 59m41s
Now, run
odo link
$ odo link PostgresCluster/hippo
Example output
✓ Successfully created link between component "backend" and service "PostgresCluster/hippo"
To apply the link, please use `odo push`
And then run
odo push
After a successful
odo push
When you open the URL for the application deployed by backend component, it shows a list of
items in the database. For example, in the output for thetodocommand, the path whereodo url listare listed is included:todos$ odo url listSample output
Found the following URLs for component backend NAME STATE URL PORT SECURE KIND 8080-tcp Pushed http://8080-tcp.192.168.39.112.nip.io 8080 false ingressThe correct path for the URL would be http://8080-tcp.192.168.39.112.nip.io/api/v1/todos. The exact URL depends on your setup. Also note that there are no
in the database unless you add some, so the URL might just show an empty JSON object.todosYou can see binding information related to the Postgres service injected into the backend component. This binding information is injected, by default, as environment variables. You can check it using the
command from the backend component’s directory:odo describe$ odo describeExample output:
Component Name: backend Type: spring Environment Variables: · PROJECTS_ROOT=/projects · PROJECT_SOURCE=/projects · DEBUG_PORT=5858 Storage: · m2 of size 3Gi mounted to /home/user/.m2 URLs: · http://8080-tcp.192.168.39.112.nip.io exposed via 8080 Linked Services: · PostgresCluster/hippo Environment Variables: · POSTGRESCLUSTER_PGBOUNCER-EMPTY · POSTGRESCLUSTER_PGBOUNCER.INI · POSTGRESCLUSTER_ROOT.CRT · POSTGRESCLUSTER_VERIFIER · POSTGRESCLUSTER_ID_ECDSA · POSTGRESCLUSTER_PGBOUNCER-VERIFIER · POSTGRESCLUSTER_TLS.CRT · POSTGRESCLUSTER_PGBOUNCER-URI · POSTGRESCLUSTER_PATRONI.CRT-COMBINED · POSTGRESCLUSTER_USER · pgImage · pgVersion · POSTGRESCLUSTER_CLUSTERIP · POSTGRESCLUSTER_HOST · POSTGRESCLUSTER_PGBACKREST_REPO.CONF · POSTGRESCLUSTER_PGBOUNCER-USERS.TXT · POSTGRESCLUSTER_SSH_CONFIG · POSTGRESCLUSTER_TLS.KEY · POSTGRESCLUSTER_CONFIG-HASH · POSTGRESCLUSTER_PASSWORD · POSTGRESCLUSTER_PATRONI.CA-ROOTS · POSTGRESCLUSTER_DBNAME · POSTGRESCLUSTER_PGBOUNCER-PASSWORD · POSTGRESCLUSTER_SSHD_CONFIG · POSTGRESCLUSTER_PGBOUNCER-FRONTEND.KEY · POSTGRESCLUSTER_PGBACKREST_INSTANCE.CONF · POSTGRESCLUSTER_PGBOUNCER-FRONTEND.CA-ROOTS · POSTGRESCLUSTER_PGBOUNCER-HOST · POSTGRESCLUSTER_PORT · POSTGRESCLUSTER_ROOT.KEY · POSTGRESCLUSTER_SSH_KNOWN_HOSTS · POSTGRESCLUSTER_URI · POSTGRESCLUSTER_PATRONI.YAML · POSTGRESCLUSTER_DNS.CRT · POSTGRESCLUSTER_DNS.KEY · POSTGRESCLUSTER_ID_ECDSA.PUB · POSTGRESCLUSTER_PGBOUNCER-FRONTEND.CRT · POSTGRESCLUSTER_PGBOUNCER-PORT · POSTGRESCLUSTER_CA.CRTSome of these variables are used in the backend component’s
file so that the Java Spring Boot application can connect to the PostgreSQL database service.src/main/resources/application.propertiesLastly,
has created a directory calledodoin your backend component’s directory that contains the following files:kubernetes/$ ls kubernetes odo-service-backend-postgrescluster-hippo.yaml odo-service-hippo.yamlThese files contain the information (YAML manifests) for two resources:
-
- the Postgres service created using
odo-service-hippo.yamlcommand.odo service create --from-file ../postgrescluster.yaml -
- the link created using
odo-service-backend-postgrescluster-hippo.yamlcommand.odo link
-
3.5.6.2.2. Using odo link with the --inlined flag Copiar enlaceEnlace copiado en el portapapeles!
Using the
--inlined
odo link
odo link
kubernetes/
--inlined
odo
kubernetes/
devfile.yaml
To see this, unlink the component from the PostgreSQL service first:
$ odo unlink PostgresCluster/hippo
Example output:
✓ Successfully unlinked component "backend" from service "PostgresCluster/hippo"
To apply the changes, please use `odo push`
To unlink them on the cluster, run
odo push
kubernetes/
$ ls kubernetes
odo-service-hippo.yaml
Next, use the
--inlined
$ odo link PostgresCluster/hippo --inlined
Example output:
✓ Successfully created link between component "backend" and service "PostgresCluster/hippo"
To apply the link, please use `odo push`
You need to run
odo push
--inlined
odo
devfile.yaml
kubernetes:
inlined: |
apiVersion: binding.operators.coreos.com/v1alpha1
kind: ServiceBinding
metadata:
creationTimestamp: null
name: backend-postgrescluster-hippo
spec:
application:
group: apps
name: backend-app
resource: deployments
version: v1
bindAsFiles: false
detectBindingResources: true
services:
- group: postgres-operator.crunchydata.com
id: hippo
kind: PostgresCluster
name: hippo
version: v1beta1
status:
secret: ""
name: backend-postgrescluster-hippo
Now if you were to run
odo unlink PostgresCluster/hippo
odo
devfile.yaml
odo push
3.5.6.2.3. Custom bindings Copiar enlaceEnlace copiado en el portapapeles!
odo link
--map
postgrescluster.yaml
If the name of your
PostgresCluster
hippo
odo service list
postgresVersion
$ odo link PostgresCluster/hippo --map pgVersion='{{ .hippo.spec.postgresVersion }}'
Note that, if the name of your Postgres service is different from
hippo
.hippo
pgVersion
After a link operation, run
odo push
$ odo exec -- env | grep pgVersion
Example output:
pgVersion=13
Since you might want to inject more than just one piece of custom binding information,
odo link
--map <key>=<value>
$ odo link PostgresCluster/hippo --map pgVersion='{{ .hippo.spec.postgresVersion }}' --map pgImage='{{ .hippo.spec.image }}'
and then run
odo push
$ odo exec -- env | grep -e "pgVersion\|pgImage"
Example output:
pgVersion=13
pgImage=registry.developers.crunchydata.com/crunchydata/crunchy-postgres-ha:centos8-13.4-0
3.5.6.2.3.1. To inline or not? Copiar enlaceEnlace copiado en el portapapeles!
You can accept the default behavior where
odo link
kubernetes/
--inlined
devfile.yaml
3.5.6.3. Binding as files Copiar enlaceEnlace copiado en el portapapeles!
Another helpful flag that
odo link
--bind-as-files
Ensure that there are no existing links between the backend component and the PostgreSQL service. You could do this by running
odo describe
Linked Services:
· PostgresCluster/hippo
Unlink the service from the component using:
$ odo unlink PostgresCluster/hippo
$ odo push
3.5.6.4. --bind-as-files examples Copiar enlaceEnlace copiado en el portapapeles!
3.5.6.4.1. Using the default odo link Copiar enlaceEnlace copiado en el portapapeles!
By default,
odo
kubernetes/
$ odo link PostgresCluster/hippo --bind-as-files
$ odo push
Example odo describe output:
$ odo describe
Component Name: backend
Type: spring
Environment Variables:
· PROJECTS_ROOT=/projects
· PROJECT_SOURCE=/projects
· DEBUG_PORT=5858
· SERVICE_BINDING_ROOT=/bindings
· SERVICE_BINDING_ROOT=/bindings
Storage:
· m2 of size 3Gi mounted to /home/user/.m2
URLs:
· http://8080-tcp.192.168.39.112.nip.io exposed via 8080
Linked Services:
· PostgresCluster/hippo
Files:
· /bindings/backend-postgrescluster-hippo/pgbackrest_instance.conf
· /bindings/backend-postgrescluster-hippo/user
· /bindings/backend-postgrescluster-hippo/ssh_known_hosts
· /bindings/backend-postgrescluster-hippo/clusterIP
· /bindings/backend-postgrescluster-hippo/password
· /bindings/backend-postgrescluster-hippo/patroni.yaml
· /bindings/backend-postgrescluster-hippo/pgbouncer-frontend.crt
· /bindings/backend-postgrescluster-hippo/pgbouncer-host
· /bindings/backend-postgrescluster-hippo/root.key
· /bindings/backend-postgrescluster-hippo/pgbouncer-frontend.key
· /bindings/backend-postgrescluster-hippo/pgbouncer.ini
· /bindings/backend-postgrescluster-hippo/uri
· /bindings/backend-postgrescluster-hippo/config-hash
· /bindings/backend-postgrescluster-hippo/pgbouncer-empty
· /bindings/backend-postgrescluster-hippo/port
· /bindings/backend-postgrescluster-hippo/dns.crt
· /bindings/backend-postgrescluster-hippo/pgbouncer-uri
· /bindings/backend-postgrescluster-hippo/root.crt
· /bindings/backend-postgrescluster-hippo/ssh_config
· /bindings/backend-postgrescluster-hippo/dns.key
· /bindings/backend-postgrescluster-hippo/host
· /bindings/backend-postgrescluster-hippo/patroni.crt-combined
· /bindings/backend-postgrescluster-hippo/pgbouncer-frontend.ca-roots
· /bindings/backend-postgrescluster-hippo/tls.key
· /bindings/backend-postgrescluster-hippo/verifier
· /bindings/backend-postgrescluster-hippo/ca.crt
· /bindings/backend-postgrescluster-hippo/dbname
· /bindings/backend-postgrescluster-hippo/patroni.ca-roots
· /bindings/backend-postgrescluster-hippo/pgbackrest_repo.conf
· /bindings/backend-postgrescluster-hippo/pgbouncer-port
· /bindings/backend-postgrescluster-hippo/pgbouncer-verifier
· /bindings/backend-postgrescluster-hippo/id_ecdsa
· /bindings/backend-postgrescluster-hippo/id_ecdsa.pub
· /bindings/backend-postgrescluster-hippo/pgbouncer-password
· /bindings/backend-postgrescluster-hippo/pgbouncer-users.txt
· /bindings/backend-postgrescluster-hippo/sshd_config
· /bindings/backend-postgrescluster-hippo/tls.crt
Everything that was an environment variable in the
key=value
odo describe
cat
Example command:
$ odo exec -- cat /bindings/backend-postgrescluster-hippo/password
Example output:
q({JC:jn^mm/Bw}eu+j.GX{k
Example command:
$ odo exec -- cat /bindings/backend-postgrescluster-hippo/user
Example output:
hippo
Example command:
$ odo exec -- cat /bindings/backend-postgrescluster-hippo/clusterIP
Example output:
10.101.78.56
3.5.6.4.2. Using --inlined Copiar enlaceEnlace copiado en el portapapeles!
The result of using
--bind-as-files
--inlined
odo link --inlined
devfile.yaml
kubernetes/
odo describe
3.5.6.4.3. Custom bindings Copiar enlaceEnlace copiado en el portapapeles!
When you pass custom bindings while linking the backend component with the PostgreSQL service, these custom bindings are injected not as environment variables but are mounted as files. For example:
$ odo link PostgresCluster/hippo --map pgVersion='{{ .hippo.spec.postgresVersion }}' --map pgImage='{{ .hippo.spec.image }}' --bind-as-files
$ odo push
These custom bindings get mounted as files instead of being injected as environment variables. To validate that this worked, run the following command:
Example command:
$ odo exec -- cat /bindings/backend-postgrescluster-hippo/pgVersion
Example output:
13
Example command:
$ odo exec -- cat /bindings/backend-postgrescluster-hippo/pgImage
Example output:
registry.developers.crunchydata.com/crunchydata/crunchy-postgres-ha:centos8-13.4-0
3.5.7. odo registry Copiar enlaceEnlace copiado en el portapapeles!
odo
odo
You can connect to publicly available devfile registries, or you can install your own Secure Registry.
You can use the
odo registry
odo
3.5.7.1. Listing the registries Copiar enlaceEnlace copiado en el portapapeles!
To list the registries currently contacted by
odo
$ odo registry list
Example output:
NAME URL SECURE
DefaultDevfileRegistry https://registry.devfile.io No
DefaultDevfileRegistry
3.5.7.2. Adding a registry Copiar enlaceEnlace copiado en el portapapeles!
To add a registry, run the command:
$ odo registry add
Example output:
$ odo registry add StageRegistry https://registry.stage.devfile.io
New registry successfully added
If you are deploying your own Secure Registry, you can specify the personal access token to authenticate to the secure registry with the
--token
$ odo registry add MyRegistry https://myregistry.example.com --token <access_token>
New registry successfully added
3.5.7.3. Deleting a registry Copiar enlaceEnlace copiado en el portapapeles!
To delete a registry, run the command:
$ odo registry delete
Example output:
$ odo registry delete StageRegistry
? Are you sure you want to delete registry "StageRegistry" Yes
Successfully deleted registry
Use the
--force
-f
3.5.7.4. Updating a registry Copiar enlaceEnlace copiado en el portapapeles!
To update the URL or the personal access token of a registry already registered, run the command:
$ odo registry update
Example output:
$ odo registry update MyRegistry https://otherregistry.example.com --token <other_access_token>
? Are you sure you want to update registry "MyRegistry" Yes
Successfully updated registry
Use the
--force
-f
3.5.8. odo service Copiar enlaceEnlace copiado en el portapapeles!
odo
The list of available Operators and services available for installation can be found using the
odo catalog
Services are created in the context of a component, so run the
odo create
A service is deployed using two steps:
- Define the service and store its definition in the devfile.
-
Deploy the defined service to the cluster, using the command.
odo push
3.5.8.1. Creating a new service Copiar enlaceEnlace copiado en el portapapeles!
To create a new service, run the command:
$ odo service create
For example, to create an instance of a Redis service named
my-redis-service
Example output
$ odo catalog list services
Services available through Operators
NAME CRDs
redis-operator.v0.8.0 RedisCluster, Redis
$ odo service create redis-operator.v0.8.0/Redis my-redis-service
Successfully added service to the configuration; do 'odo push' to create service on the cluster
This command creates a Kubernetes manifest in the
kubernetes/
devfile.yaml
$ cat kubernetes/odo-service-my-redis-service.yaml
Example output
apiVersion: redis.redis.opstreelabs.in/v1beta1
kind: Redis
metadata:
name: my-redis-service
spec:
kubernetesConfig:
image: quay.io/opstree/redis:v6.2.5
imagePullPolicy: IfNotPresent
resources:
limits:
cpu: 101m
memory: 128Mi
requests:
cpu: 101m
memory: 128Mi
serviceType: ClusterIP
redisExporter:
enabled: false
image: quay.io/opstree/redis-exporter:1.0
storage:
volumeClaimTemplate:
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
Example command
$ cat devfile.yaml
Example output
[...]
components:
- kubernetes:
uri: kubernetes/odo-service-my-redis-service.yaml
name: my-redis-service
[...]
Note that the name of the created instance is optional. If you do not provide a name, it will be the lowercase name of the service. For example, the following command creates an instance of a Redis service named
redis
$ odo service create redis-operator.v0.8.0/Redis
3.5.8.1.1. Inlining the manifest Copiar enlaceEnlace copiado en el portapapeles!
By default, a new manifest is created in the
kubernetes/
devfile.yaml
devfile.yaml
--inlined
$ odo service create redis-operator.v0.8.0/Redis my-redis-service --inlined
Successfully added service to the configuration; do 'odo push' to create service on the cluster
Example command
$ cat devfile.yaml
Example output
[...]
components:
- kubernetes:
inlined: |
apiVersion: redis.redis.opstreelabs.in/v1beta1
kind: Redis
metadata:
name: my-redis-service
spec:
kubernetesConfig:
image: quay.io/opstree/redis:v6.2.5
imagePullPolicy: IfNotPresent
resources:
limits:
cpu: 101m
memory: 128Mi
requests:
cpu: 101m
memory: 128Mi
serviceType: ClusterIP
redisExporter:
enabled: false
image: quay.io/opstree/redis-exporter:1.0
storage:
volumeClaimTemplate:
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
name: my-redis-service
[...]
3.5.8.1.2. Configuring the service Copiar enlaceEnlace copiado en el portapapeles!
Without specific customization, the service will be created with a default configuration. You can use either command-line arguments or a file to specify your own configuration.
3.5.8.1.2.1. Using command-line arguments Copiar enlaceEnlace copiado en el portapapeles!
Use the
--parameters
-p
The following example configures the Redis service with three parameters:
$ odo service create redis-operator.v0.8.0/Redis my-redis-service \
-p kubernetesConfig.image=quay.io/opstree/redis:v6.2.5 \
-p kubernetesConfig.serviceType=ClusterIP \
-p redisExporter.image=quay.io/opstree/redis-exporter:1.0
Successfully added service to the configuration; do 'odo push' to create service on the cluster
Example command
$ cat kubernetes/odo-service-my-redis-service.yaml
Example output
apiVersion: redis.redis.opstreelabs.in/v1beta1
kind: Redis
metadata:
name: my-redis-service
spec:
kubernetesConfig:
image: quay.io/opstree/redis:v6.2.5
serviceType: ClusterIP
redisExporter:
image: quay.io/opstree/redis-exporter:1.0
You can obtain the possible parameters for a specific service using the
odo catalog describe service
3.5.8.1.2.2. Using a file Copiar enlaceEnlace copiado en el portapapeles!
Use a YAML manifest to configure your own specification. In the following example, the Redis service is configured with three parameters.
Create a manifest:
$ cat > my-redis.yaml <<EOF apiVersion: redis.redis.opstreelabs.in/v1beta1 kind: Redis metadata: name: my-redis-service spec: kubernetesConfig: image: quay.io/opstree/redis:v6.2.5 serviceType: ClusterIP redisExporter: image: quay.io/opstree/redis-exporter:1.0 EOFCreate the service from the manifest:
$ odo service create --from-file my-redis.yaml Successfully added service to the configuration; do 'odo push' to create service on the cluster
3.5.8.2. Deleting a service Copiar enlaceEnlace copiado en el portapapeles!
To delete a service, run the command:
$ odo service delete
Example output
$ odo service list
NAME MANAGED BY ODO STATE AGE
Redis/my-redis-service Yes (api) Deleted locally 5m39s
$ odo service delete Redis/my-redis-service
? Are you sure you want to delete Redis/my-redis-service Yes
Service "Redis/my-redis-service" has been successfully deleted; do 'odo push' to delete service from the cluster
Use the
--force
-f
3.5.8.3. Listing services Copiar enlaceEnlace copiado en el portapapeles!
To list the services created for your component, run the command:
$ odo service list
Example output
$ odo service list
NAME MANAGED BY ODO STATE AGE
Redis/my-redis-service-1 Yes (api) Not pushed
Redis/my-redis-service-2 Yes (api) Pushed 52s
Redis/my-redis-service-3 Yes (api) Deleted locally 1m22s
For each service,
STATE
odo push
odo service delete
3.5.8.4. Getting information about a service Copiar enlaceEnlace copiado en el portapapeles!
To get details of a service such as its kind, version, name, and list of configured parameters, run the command:
$ odo service describe
Example output
$ odo service describe Redis/my-redis-service
Version: redis.redis.opstreelabs.in/v1beta1
Kind: Redis
Name: my-redis-service
Parameters:
NAME VALUE
kubernetesConfig.image quay.io/opstree/redis:v6.2.5
kubernetesConfig.serviceType ClusterIP
redisExporter.image quay.io/opstree/redis-exporter:1.0
3.5.9. odo storage Copiar enlaceEnlace copiado en el portapapeles!
odo
emptyDir
3.5.9.1. Adding a storage volume Copiar enlaceEnlace copiado en el portapapeles!
To add a storage volume to the cluster, run the command:
$ odo storage create
Example output:
$ odo storage create store --path /data --size 1Gi
✓ Added storage store to nodejs-project-ufyy
$ odo storage create tempdir --path /tmp --size 2Gi --ephemeral
✓ Added storage tempdir to nodejs-project-ufyy
Please use `odo push` command to make the storage accessible to the component
In the above example, the first storage volume has been mounted to the
/data
1Gi
/tmp
3.5.9.2. Listing the storage volumes Copiar enlaceEnlace copiado en el portapapeles!
To check the storage volumes currently used by the component, run the command:
$ odo storage list
Example output:
$ odo storage list
The component 'nodejs-project-ufyy' has the following storage attached:
NAME SIZE PATH STATE
store 1Gi /data Not Pushed
tempdir 2Gi /tmp Not Pushed
3.5.9.3. Deleting a storage volume Copiar enlaceEnlace copiado en el portapapeles!
To delete a storage volume, run the command:
$ odo storage delete
Example output:
$ odo storage delete store -f
Deleted storage store from nodejs-project-ufyy
Please use `odo push` command to delete the storage from the cluster
In the above example, using the
-f
3.5.9.4. Adding storage to specific container Copiar enlaceEnlace copiado en el portapapeles!
If your devfile has multiple containers, you can specify which container you want the storage to attach to, using the
--container
odo storage create
The following example is an excerpt from a devfile with multiple containers :
components:
- name: nodejs1
container:
image: registry.access.redhat.com/ubi8/nodejs-12:1-36
memoryLimit: 1024Mi
endpoints:
- name: "3000-tcp"
targetPort: 3000
mountSources: true
- name: nodejs2
container:
image: registry.access.redhat.com/ubi8/nodejs-12:1-36
memoryLimit: 1024Mi
In the example, there are two containers,
nodejs1
nodejs2
nodejs2
$ odo storage create --container
Example output:
$ odo storage create store --path /data --size 1Gi --container nodejs2
✓ Added storage store to nodejs-testing-xnfg
Please use `odo push` command to make the storage accessible to the component
You can list the storage resources, using the
odo storage list
$ odo storage list
Example output:
The component 'nodejs-testing-xnfg' has the following storage attached:
NAME SIZE PATH CONTAINER STATE
store 1Gi /data nodejs2 Not Pushed
3.5.10. Common flags Copiar enlaceEnlace copiado en el portapapeles!
The following flags are available with most
odo
| Command | Description |
|---|---|
|
| Set the context directory where the component is defined. |
|
| Set the project for the component. Defaults to the project defined in the local configuration. If none is available, then current project on the cluster. |
|
| Set the application of the component. Defaults to the application defined in the local configuration. If none is available, then app. |
|
| Set the path to the
|
|
| Use this flag to see the logs. |
|
| Use this flag to tell the command not to prompt the user for confirmation. |
|
| Set the verbosity level. See Logging in odo for more information. |
|
| Output the help for a command. |
Some flags might not be available for some commands. Run the command with the
--help
3.5.11. JSON output Copiar enlaceEnlace copiado en el portapapeles!
The
odo
-o json
The output structure is similar to Kubernetes resources, with the
kind
apiVersion
metadata
spec
status
List commands return a
List
items
Delete commands return a
Status
Other commands return a resource associated with the command, for example,
Application
Storage
URL
The full list of commands currently accepting the
-o json
| Commands | Kind (version) | Kind (version) of list items | Complete content? |
|---|---|---|---|
| odo application describe | Application (odo.dev/v1alpha1) | n/a | no |
| odo application list | List (odo.dev/v1alpha1) | Application (odo.dev/v1alpha1) | ? |
| odo catalog list components | List (odo.dev/v1alpha1) | missing | yes |
| odo catalog list services | List (odo.dev/v1alpha1) | ClusterServiceVersion (operators.coreos.com/v1alpha1) | ? |
| odo catalog describe component | missing | n/a | yes |
| odo catalog describe service | CRDDescription (odo.dev/v1alpha1) | n/a | yes |
| odo component create | Component (odo.dev/v1alpha1) | n/a | yes |
| odo component describe | Component (odo.dev/v1alpha1) | n/a | yes |
| odo component list | List (odo.dev/v1alpha1) | Component (odo.dev/v1alpha1) | yes |
| odo config view | DevfileConfiguration (odo.dev/v1alpha1) | n/a | yes |
| odo debug info | OdoDebugInfo (odo.dev/v1alpha1) | n/a | yes |
| odo env view | EnvInfo (odo.dev/v1alpha1) | n/a | yes |
| odo preference view | PreferenceList (odo.dev/v1alpha1) | n/a | yes |
| odo project create | Project (odo.dev/v1alpha1) | n/a | yes |
| odo project delete | Status (v1) | n/a | yes |
| odo project get | Project (odo.dev/v1alpha1) | n/a | yes |
| odo project list | List (odo.dev/v1alpha1) | Project (odo.dev/v1alpha1) | yes |
| odo registry list | List (odo.dev/v1alpha1) | missing | yes |
| odo service create | Service | n/a | yes |
| odo service describe | Service | n/a | yes |
| odo service list | List (odo.dev/v1alpha1) | Service | yes |
| odo storage create | Storage (odo.dev/v1alpha1) | n/a | yes |
| odo storage delete | Status (v1) | n/a | yes |
| odo storage list | List (odo.dev/v1alpha1) | Storage (odo.dev/v1alpha1) | yes |
| odo url list | List (odo.dev/v1alpha1) | URL (odo.dev/v1alpha1) | yes |