Skip to content

Commit

Permalink
Make command reference docs consistent (redhat-developer#6126)
Browse files Browse the repository at this point in the history
* add-binding.md

* build-images.md

* delete-component.md

* deploy.md

* odo list

* Temp changes

* Add collapsible examples
  • Loading branch information
valaparthvi authored and kadel committed Oct 3, 2022
1 parent fc025eb commit b55f390
Show file tree
Hide file tree
Showing 18 changed files with 425 additions and 174 deletions.
48 changes: 28 additions & 20 deletions docs/website/docs/command-reference/add-binding.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
title: odo add binding
---

## Description
The `odo add binding` command adds a link between an Operator-backed service and a component. odo uses the [Service Binding Operator](https://github.com/redhat-developer/service-binding-operator/) to create this link.

Running this command from a directory containing a Devfile will modify the Devfile, and once pushed (using `odo dev`) to the cluster, it creates an instance of the `ServiceBinding` resource.
Expand Down Expand Up @@ -44,6 +43,23 @@ In the interactive mode, you will be guided to choose:
# Add binding between a service, and the component present in the working directory in the interactive mode
odo add binding
```
<details>
<summary>Example</summary>

```shell
$ odo add binding
? Do you want to list services from: current namespace
? Select service instance you want to bind to: cluster-sample (Cluster.postgresql.k8s.enterprisedb.io)
? Enter the Binding's name: my-go-app-cluster-sample
? How do you want to bind the service? Bind As Files
? Select naming strategy for binding names: DEFAULT
✓ Successfully added the binding to the devfile.
Run `odo dev` to create it on the cluster.
You can automate this command by executing:
odo add binding --service cluster-sample.Cluster.postgresql.k8s.enterprisedb.io --name my-go-app-cluster-sample
```
</details>
### Non-interactive mode
In the non-interactive mode, you will have to specify the following required information through the command-line:
Expand All @@ -58,10 +74,18 @@ In the non-interactive mode, you will have to specify the following required inf
Refer to [this page](https://docs.openshift.com/container-platform/4.10/applications/connecting_applications_to_services/binding-workloads-using-sbo.html#sbo-naming-strategies_binding-workloads-using-sbo) for more details on naming strategies.
```shell
# Add binding between a service named 'cluster-sample',
# and the component present in the working directory in the non-interactive mode
odo add binding --name mybinding --service cluster-sample
odo add binding --name <name> --service <service-name> [--service-namespace NAMESPACE] [--bind-as-files] [--naming-strategy [none | lowercase | uppercase]]
```
<details>
<summary>Example</summary>
```shell
$ odo add binding --service cluster-sample.Cluster.postgresql.k8s.enterprisedb.io --name my-go-app-cluster-sample
✓ Successfully added the binding to the devfile.
Run `odo dev` to create it on the cluster.
```
</details>
#### Understanding Bind as Files
To connect your component with a service, you need to store some data (e.g. username, password, host address) on your component's container.
Expand All @@ -84,19 +108,3 @@ The `--workload` flag supports the following formats to specify the workload nam
* `<name>/<kind>.<apigroup>`

The above formats are helpful when multiple services with the same name exist on the cluster.

### Using different formats
```shell
# Add binding between a service named 'cluster-sample', and the component present in the working directory
odo add binding --service cluster-sample --name restapi-cluster-sample

# Add binding between service named 'cluster-sample' of kind 'Cluster', and APIGroup 'postgresql.k8s.enterprisedb.io',
# and the component present in the working directory
odo add binding --service cluster-sample/Cluster.postgresql.k8s.enterprisedb.io --name restapi-cluster-sample
odo add binding --service cluster-sample.Cluster.postgresql.k8s.enterprisedb.io --name restapi-cluster-sample

# Add binding between service named 'cluster-sample' of kind 'Cluster',
# and the component present in the working directory
odo add binding --service cluster-sample/Cluster --name restapi-cluster-sample
odo add binding --service cluster-sample.Cluster --name restapi-cluster-sample
```
43 changes: 43 additions & 0 deletions docs/website/docs/command-reference/build-images.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,46 @@ The `buildContext` indicates the directory used as build context. The default va
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 will be pushed to their registries after they are built.

## Running the command
### Pre-requisites
* Login to an image registry(quay.io, hub.docker.com, etc)
* Dockerfile

```shell
odo build-images
```
<details>
<summary>Example</summary>

```shell
$ odo build-images

↪ Building & Pushing Container: quay.io/user/myimage
• Building image locally ...
STEP 1/7: FROM quay.io/phmartin/node:17
STEP 2/7: WORKDIR /usr/src/app
--> Using cache b18c8d9f4c739a91e5430f235b7beaac913250bec8bfcae531a8e93c750cea87
--> b18c8d9f4c7
STEP 3/7: COPY package*.json ./
--> Using cache cd151181cd9b2c69fc938eb89f3f71d0327d27ffba53c54247a105733cb36217
--> cd151181cd9
STEP 4/7: RUN npm install
--> Using cache 72b79a4f76ab0f9665653a974f5c667b1cb964c89c58e71aa4817b1055b1c473
--> 72b79a4f76a
STEP 5/7: COPY . .
--> 84f475ad011
STEP 6/7: EXPOSE 8080
--> 12af8468cd0
STEP 7/7: CMD [ "node", "server.js" ]
COMMIT quay.io/user/myimage
--> 58c0731e9a1
Successfully tagged quay.io/user/myimage:latest
58c0731e9a110e8dbb2dbe4bdb55a15bdbbce1b78e121d350e23de79f33c3dde
✓ Building image locally [2s]
```
</details>


### Faking the image build
You can also fake the image build by exporting `PODMAN_CMD=echo` to your environment.
27 changes: 18 additions & 9 deletions docs/website/docs/command-reference/create-namespace.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,41 @@ title: odo create namespace

Any new namespace created with this command will also be set as the current active namespace, this applies to project as well.

To create a namespace you can run `odo create namespace <name>`:
## Running the command
To create a namespace, run the following command:
```shell
odo create namespace mynamespace
odo create namespace <name>
```
<details>
<summary>Example</summary>

```shell
$ odo create namespace mynamespace
✓ Namespace "mynamespace" is ready for use
✓ New namespace created and now using namespace: mynamespace
```
</details>


Optionally, you can also use `project` as an alias to `namespace`.

To create a project you can run `odo create project <name>`:
To create a project, run the following command:
```shell
odo create project myproject
odo create project <name>
```
<details>
<summary>Example</summary>

```shell
$ odo create project myproject
✓ Project "myproject" is ready for use
✓ New project created and now using project: myproject
```
</details>

:::note

:::tip
Using either of the aliases will not make any change to the resource created on the cluster. This command is smart enough to detect the resources supported by your cluster and make an informed decision on the type of resource that should be created.
So you can run `odo create project` on a Kubernetes cluster, and it will create a Namespace resource, and you can run `odo create namespace` on an OpenShift cluster, it will create a Project resource.
:::

## Available Flags
* `--wait` - Use this flag to wait until the new namespace is ready
So you can run `odo create project` on a Kubernetes cluster, and it will create a `Namespace` resource, and you can run `odo create namespace` on an OpenShift cluster, it will create a `Project` resource.
:::
47 changes: 33 additions & 14 deletions docs/website/docs/command-reference/delete-component.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,29 @@ title: odo delete component

`odo delete component` command is useful for deleting resources that are managed by `odo`. It deletes the component and its related innerloop, and outerloop resources from the cluster.

## Running the command
There are 2 ways to delete a component:
- [Delete with access to Devfile](#delete-with-access-to-devfile)
- [Delete without access to Devfile](#delete-without-access-to-devfile)
- [Available Flags](#available-flags)

## Delete with access to Devfile
### Delete with access to Devfile
```shell
odo delete component
odo delete component [--force] [--wait]
```
<details>
<summary>Example</summary>

```shell
$ 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"
```
</details>

`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.
Expand All @@ -24,22 +38,27 @@ You can delete these resources by running the command in the [next section](#del

`odo` does not delete the Devfile, the `odo` configuration files, or the source code.

## Delete without access to Devfile
### Delete without access to Devfile
```shell
odo delete component --name <component_name> [--namespace <namespace>]
odo delete component --name <component_name> [--namespace <namespace>] [--force] [--wait]
```
<details>
<summary>Example</summary>

```shell
$ 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"
```
</details>


`odo` searches for resources attached to the given component in the given namespace on the cluster.
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.

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

:::info
In both cases, `odo` does not wait for resources to be deleted.
:::

## Available Flags
* `-f`, `--force` - Use this flag to avoid being prompted for confirmation.
* `--name` - Name of the component to delete (optional). By default, the component described in the local devfile is deleted
* `--namespace` - Namespace to find the component to delete (optional). By default, the current namespace defined in kubeconfig is used
29 changes: 18 additions & 11 deletions docs/website/docs/command-reference/delete-namespace.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,38 @@ title: odo delete namespace

`odo delete namespace` lets you delete a namespace/project on your cluster. If you are on a Kubernetes cluster, running the command will delete a Namespace resource for you, and for an OpenShift cluster, it will delete a Project resource.

To delete a namespace you can run `odo delete namespace <name>`:
## Running the command
To delete a namespace, run the following command:
```shell
odo delete namespace mynamespace
odo delete namespace <name> [--wait] [--force]
```
<details>
<summary>Example</summary>

```shell
$ odo delete namespace mynamespace
✓ Namespace "mynamespace" deleted
```
</details>

Optionally, you can also use `project` as an alias to `namespace`.

To delete a project you can run `odo delete project <name>`:
To delete a project, run the following command:
```shell
odo delete project myproject
odo delete project <name> [--wait] [--force]
```
<details>
<summary>Example</summary>

```shell
$ odo delete project myproject
✓ Project "myproject" deleted
✓ Project "myproject" deleted
```
</details>


:::note
:::tip
This command is smart enough to detect the resources supported by your cluster and make an informed decision on the type of resource that should be deleted, using either of the aliases.
So you can run `odo delete project` on a Kubernetes cluster, and it will delete a Namespace resource, or you can run `odo delete namespace` on an OpenShift cluster, it will delete a Project resource.
:::

## Available Flags
* `-f`, `--force` - Use this flag to avoid being prompted for confirmation.
* `--wait` - Use this flag to wait until the namespace no longer exists
So you can run `odo delete project` on a Kubernetes cluster, and it will delete a `Namespace` resource, or you can run `odo delete namespace` on an OpenShift cluster, it will delete a `Project` resource.
:::
57 changes: 57 additions & 0 deletions docs/website/docs/command-reference/deploy.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,63 @@ components:

Note that the `uri` for the Dockerfile could also be an HTTP or HTTPS URL.

### Running the command
```shell
odo deploy
```
<details>
<summary>Example</summary>

```shell
$ odo deploy
__
/ \__ Deploying the application using my-nodejs Devfile
\__/ \ Namespace: my-percona-server-mongodb-operator
/ \__/ odo version: v3.0.0-rc1
\__/

↪ Building & Pushing Container: quay.io/pvala18/myimage
• Building image locally ...
STEP 1/7: FROM quay.io/phmartin/node:17
STEP 2/7: WORKDIR /usr/src/app
--> Using cache b18c8d9f4c739a91e5430f235b7beaac913250bec8bfcae531a8e93c750cea87
--> b18c8d9f4c7
STEP 3/7: COPY package*.json ./
--> Using cache cd151181cd9b2c69fc938eb89f3f71d0327d27ffba53c54247a105733cb36217
--> cd151181cd9
STEP 4/7: RUN npm install
--> Using cache 72b79a4f76ab0f9665653a974f5c667b1cb964c89c58e71aa4817b1055b1c473
--> 72b79a4f76a
STEP 5/7: COPY . .
--> 5c81f92690e
STEP 6/7: EXPOSE 8080
--> 9892b562a8a
STEP 7/7: CMD [ "node", "server.js" ]
COMMIT quay.io/pvala18/myimage
--> 7578e3e3667
Successfully tagged quay.io/pvala18/myimage:latest
7578e3e36676418853c579063dd190c9d736114ca414e28c8646880b446a1618
✓ Building image locally [2s]
• Pushing image to container registry ...
Getting image source signatures
Copying blob 0b3c02b5d746 skipped: already exists
Copying blob 62a747bf1719 skipped: already exists
Copying blob 650b52851ab5 done
Copying blob 013fc0144002 skipped: already exists
Copying blob aef6a4d33347 skipped: already exists
Copying config 7578e3e366 done
Writing manifest to image destination
Storing signatures
✓ Pushing image to container registry [22s]

↪ Deploying Kubernetes Component: my-component
✓ Creating kind Deployment

Your Devfile has been successfully deployed

```
</details>

## Substituting variables

The Devfile can define variables to make the Devfile parameterizable. The Devfile can define values for these variables, and you
Expand Down
Loading

0 comments on commit b55f390

Please sign in to comment.