:_mod-docs-content-type: REFERENCE
[id="odo-deploy_{context}"]
= odo deploy


`odo` can be used to deploy components in a manner similar to how they would be deployed using a CI/CD system.
First, `odo` builds the container images, and then it deploys the Kubernetes resources required to deploy the components.

When running the command `odo deploy`, `odo` searches for the default command of kind `deploy` in the devfile, and executes this command.
The kind `deploy` is supported by the devfile format starting from version 2.2.0.

The `deploy` command is typically a _composite_ command, composed of several _apply_ commands:

* A command referencing an `image` component that, when applied, will build the image of the container to deploy, and then push it to its registry.
* A command referencing a link:https://devfile.io/docs/devfile/2.2.0/user-guide/adding-kubernetes-component-to-a-devfile.html[Kubernetes component] that, when applied, will create a Kubernetes resource in the cluster.

With the following example `devfile.yaml` file, a container image is built using the `Dockerfile` present in the directory.
The image is pushed to its registry and then a Kubernetes Deployment resource is created in the cluster, using this freshly built image.

[source,terminal]
----
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}}
----
