Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update devfile library * deploy cmd * Init "odo deploy" command reference * Integration test * Fix odo deploy * Filter components to apply during odo push * Output * Remove redondant level 1 title * Doc review * Use server-side apply to apply Kubernetes components * Review * Replace PROJECT_ROOT with PROJECTS_ROOT
- Loading branch information
Showing
63 changed files
with
1,990 additions
and
995 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
--- | ||
title: odo deploy | ||
sidebar_position: 4 | ||
--- | ||
|
||
odo can be used to deploy components in a similar manner they would be deployed by a CI/CD system, | ||
by first building the images of the containers to deploy, then by deploying the Kubernetes resources | ||
necessary 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 push it to its registry, | ||
- a command referencing a [`kubernetes` component](https://devfile.io/docs/devfile/2.2.0/user-guide/adding-kubernetes-component-to-a-devfile.html) that, when applied, will create a Kubernetes resource in the cluster. | ||
|
||
With the following example `devfile.yaml` file, a container image will be built by using the `Dockerfile` present in the directory, | ||
the image will be pushed to its registry and a Kubernetes Deployment will be created in the cluster, using this freshly built image. | ||
|
||
``` | ||
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}} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package common | ||
|
||
// ApplyClient is a wrapper around ApplyComponent which runs an apply command on a component | ||
type ApplyClient interface { | ||
ApplyComponent(component string) error | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package common | ||
|
||
import ( | ||
devfilev1 "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" | ||
) | ||
|
||
// applyCommand is a command implementation for Apply commands | ||
type applyCommand struct { | ||
adapter commandExecutor | ||
id string | ||
component string | ||
} | ||
|
||
// newApplyCommand creates a new applyCommand instance, adapting the devfile-defined command to run in the target component's container | ||
func newApplyCommand(command devfilev1.Command, executor commandExecutor) (command, error) { | ||
apply := command.Apply | ||
return &applyCommand{ | ||
adapter: executor, | ||
id: command.Id, | ||
component: apply.Component, | ||
}, nil | ||
} | ||
|
||
func (s applyCommand) Execute(show bool) error { | ||
err := s.adapter.ApplyComponent(s.component) | ||
return err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.