Files
odo/docs/website/versioned_docs/version-3.0.0/command-reference/create.md
Charlie Drage 55e4f9554e Version the documentation (#5502)
<!--
Thank you for opening a PR! Here are some things you need to know before submitting:

1. Please read our developer guideline: https://github.com/redhat-developer/odo/wiki/Developer-Guidelines
2. Label this PR accordingly with the '/kind' line
3. Ensure you have written and ran the appropriate tests: https://github.com/redhat-developer/odo/wiki/Writing-and-running-tests
4. Read how we approve and LGTM each PR: https://github.com/redhat-developer/odo/wiki/PR-Review

Documentation:

If you are pushing a change to documentation, please read: https://github.com/redhat-developer/odo/wiki/Contributing-to-Docs
-->

**What type of PR is this:**

<!--
Add one of the following kinds:
/kind bug
/kind feature
/kind cleanup
/kind tests

Feel free to use other [labels](https://github.com/redhat-developer/odo/labels) as needed. However one of the above labels must be present or the PR will not be reviewed. This instruction is for reviewers as well.
-->
/kind documentation

**What does this PR do / why we need it:**

This versions the documentation in order to display both 2.5.0 and 3.0.0
alpha1

In this PR we:

* Update the package dependencies, as there was a small bug with
  docusaurus displaying versioning
* Moves all documentation for 3.0.0-alpha1 into it's own folder
* Makes the old 2.5.0 documentation as the most current docs

**Which issue(s) this PR fixes:**
<!--
Specifying the issue will automatically close it when this PR is merged
-->

Fixes https://github.com/redhat-developer/odo/issues/5377

**PR acceptance criteria:**

- [X] Unit test

- [X] Integration test

- [X] Documentation

**How to test changes / Special notes to the reviewer:**
2022-03-01 01:23:18 -05:00

3.8 KiB

title, sidebar_position
title sidebar_position
odo create 3

odo uses the devfile to store the configuration of and describe the resources like storage, services, etc. of a component. The odo create command allows you to generate this file.

Creating a component

To create a devfile for an existing project, you can execute odo create with the name and type of your component (for example, nodejs or go):

odo create nodejs mynodejs

Here nodejs is the type of the component and mynodejs is the name of the component odo creates for you.

Note: for a list of all the supported component types, run odo catalog list components.

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 was in a folder called node-backend relative to the current working directory, you could run:

odo create nodejs mynodejs --context ./node-backend

Both relative and absolute paths are supported.

To specify the project or app of where your component will be deployed, you can use the --project and --app flags.

For example, to create a component that is a part of the myapp app inside the backend project:

odo create nodejs --app myapp --project backend

Note: if these are not specified, they will default to the active app and project

Starter projects

If you do not have existing source code but wish to get up and running quickly to experiment with devfiles and components, you could use the starter projects to get started. To use a starter project, include the --starter flag in your odo create command.

To get a list of available starter projects for a component type, you can use the odo catalog describe component command. For example, to get all available starter projects for the nodejs component type, run:

odo catalog describe component nodejs

Then specify the desired project with the --starter flag:

odo create nodejs --starter nodejs-starter

This will download the example template corresponding to the chosen component type (in the example above, nodejs) in your current directory (or the path provided with the --context flag).

If a starter project has its own devfile, then this devfile will be preserved.

Using an existing devfile

If you want to create a new component from an existing devfile, you can do so by specifying the path to the devfile with the --devfile flag.

For example, the following command will create a component called mynodejs, based on the devfile from GitHub:

odo create mynodejs --devfile https://raw.githubusercontent.com/odo-devfiles/registry/master/devfiles/nodejs/devfile.yaml

Interactive creation

The odo create command can also be run interactively. Execute odo create, which will guide you through a list of steps 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 will be 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 should be created in the working directory. To deploy these resources to your cluster, run odo push.