Skip to main content
Version: v3

odo delete component

odo delete component command is useful for deleting resources that are managed by odo. By default, it deletes the component and its related inner-loop, and outer-loop resources from the cluster and from podman.

The running-in flag allows to be more specific about which resources (either inner-loop or outer-loop) to delete.

The platform flag allows to restrict the deletion from a specific platform only, either cluster or podman.

Running the command

There are 2 ways to delete a component:

Delete with access to Devfile

odo delete component [--force] [--wait]
Example
$ odo delete component
Searching resources to delete, please wait...
This will delete "my-nodejs" from the namespace "my-project".
• The component contains the following resources that will get deleted:
- Deployment: my-component
? Are you sure you want to delete "my-nodejs" and all its resources? Yes
The component "my-nodejs" is successfully deleted from namespace "my-project"

odo looks into the Devfile present in the current directory for the component resources for the innerloop, and outerloop. If these resources have been deployed on the cluster, then odo will delete them after user confirmation. Otherwise, odo will exit with a message stating that it could not find the resources on the cluster.

note

If some resources attached to the component are present on the cluster or on podman, but not in the Devfile, then they will not be deleted. You can delete these resources by running the command in the next section.

Filtering resources to delete

You can specify the type of resources candidate for deletion via the --running-in flag. Acceptable values are dev (for inner-loop resources) or deploy (for outer-loop resources).

You can target a specific platform from which delete the resources, with the --platform flag. Acceptable values are cluster and podman.

Example
$ odo delete component --running-in dev --platform cluster
Searching resources to delete, please wait...
This will delete "my-nodejs" from the namespace "my-project".
• The following resources will get deleted from cluster:
• - Deployment: my-nodejs-app

? Are you sure you want to delete "my-nodejs" and all its resources running in the Dev mode? Yes
✓ Deleting resources from cluster [22ms]
The component "my-nodejs" is successfully deleted from namespace "my-project"

Deleting local files with --files

By default, odo does not delete the Devfile, the odo configuration files, or the source code. But when --files is passed, odo attempts to delete files or directories it initially created locally.

This will delete the following files or directories:

  • the .odo directory in the current directory
  • optionally, the Devfile only if it was initially created via odo (initialization via any of the odo init, odo dev or odo deploy commands).

Note that odo dev might generate a .gitignore file if it does not exist in the current directory, but this file will not be removed when --files is passed to odo delete component.

caution

Use this flag with caution because this permanently deletes the files mentioned above. This operation is not reversible, unless your files are backed up or under version control.

odo delete component --files [--force] [--wait]
Example
$ odo delete component --files

Searching resources to delete, please wait...
This will delete "my-nodejs" from the namespace "my-project".
• The component contains the following resources that will get deleted:
- Deployment: my-component

This will also delete the following files and directories:
- /home/user/my-project/my-nodejs/.odo
- /home/user/my-project/my-nodejs/devfile.yaml
? Are you sure you want to delete "my-nodejs" and all its resources? Yes
The component "my-nodejs" is successfully deleted from namespace "my-project"

Delete without access to Devfile

odo delete component --name <component_name> [--namespace <namespace>] [--force] [--wait]
Example
$ odo delete component --name my-nodejs
Searching resources to delete, please wait...
This will delete "my-nodejs" from the namespace "my-project".
• The component contains the following resources that will get deleted:
- Deployment: my-component
? Are you sure you want to delete these resources? Yes
The component "my-nodejs" is successfully deleted from namespace "my-project"

odo searches for resources attached to the given component in the given namespace on the cluster and on Podman. If odo finds the resources, it will delete them after user confirmation. Otherwise, odo will exit with a message stating that it could not find the resources on the cluster or on Podman.

--namespace is optional, if not provided, odo will use the current active namespace.

Filtering resources to delete

You can specify the type of resources candidate for deletion via the --running-in flag. Acceptable values are dev (for inner-loop resources) or deploy (for outer-loop resources).

You can target a specific platform from which to delete the resources, with the --platform flag. Acceptable values are cluster and podman.

Example
$ odo delete component --name my-nodejs --running-in deploy --platform cluster
Searching resources to delete, please wait...
This will delete "my-nodejs" from the namespace "my-project".
• The following resources will get deleted from cluster:
• - Deployment: my-simple-nodejs-app

? Are you sure you want to delete these resources? Yes
✓ Deleting resources from cluster [22ms]
The component "my-nodejs" running in the Deploy mode is successfully deleted from namespace "my-project"