Skip to content

Commit ce9d43b

Browse files
committed
docs: deployments
1 parent 9732635 commit ce9d43b

11 files changed

Lines changed: 356 additions & 177 deletions

File tree

docs/pages/configuration/deployments/README.mdx

Lines changed: 67 additions & 151 deletions
Original file line numberDiff line numberDiff line change
@@ -3,172 +3,88 @@ title: Deployments
33
sidebar_label: Basics
44
---
55

6-
import Tabs from '@theme/Tabs';
7-
import TabItem from '@theme/TabItem';
8-
import FragmentWorkflowDeployDependencies from '../../_partials/workflow-deploy-dependencies.mdx';
9-
import FragmentWorkflowBuildImages from '../../_partials/workflow-build-images.mdx';
10-
import FragmentWorkflowReplaceTags from '../../_partials/workflow-replace-tags.mdx';
11-
import FragmentWorkflowDeployProject from '../../_partials/workflow-deploy-project.mdx';
126
import ConfigPartialDeployments from '../_partials/v2beta1/deployments.mdx'
137

14-
Deployments are configured within the `deployments` section of the `devspace.yaml`.
158

16-
## Examples
9+
## Deploy with DevSpace
1710

18-
<Tabs
19-
defaultValue="mixed"
20-
values={[
21-
{ label: 'Mixed', value: 'mixed', },
22-
{ label: 'Component Chart', value: 'component', },
23-
{ label: 'Custom Helm Chart', value: 'helm', },
24-
{ label: 'Manifests', value: 'manifests', },
25-
{ label: 'Kustomizations', value: 'kustomize', },
26-
]
27-
}>
28-
<TabItem value="mixed">
29-
30-
```yaml
11+
### 1. Define Deployments
12+
To deploy to Kubernetes using DevSpace, we need to define `deployments` in `devspace.yaml`:
13+
```yaml title=devspace.yaml
14+
version: v2beta1
3115
deployments:
32-
deployment-1: # Name of this deployment
33-
helm: # Deploy using the Component Helm Chart
34-
values: ... # See: https://devspace.sh/component-chart/docs/introduction
35-
36-
deployment-2: # Name of this deployment
37-
kubectl: # Deploy Kubernetes manifests or Kustomizations
16+
configs:
17+
kubectl:
3818
manifests:
39-
- app/manifests/
40-
- db/deployment.yaml
41-
42-
deployment-3: # Name of this deployment
43-
helm: # Deploy a Helm Chart
44-
chart:
45-
name: bitnami/mysql # Deploy chart from bitnami registry
46-
values: ...
47-
48-
deployment-4: # Name of this deployment
49-
helm: ... # Deploy another Helm Chart
19+
- ./api/deploy/configmap.yaml
20+
- ./payments/deploy/configmap.yaml
21+
api:
22+
helm:
5023
chart:
51-
name: ./chart # Deploy chart from local folder
52-
values: ...
53-
```
54-
55-
</TabItem>
56-
<TabItem value="component">
57-
58-
```yaml
59-
deployments:
60-
deployment-1: # Name of this deployment
61-
helm: # Deploy using the Component Helm Chart
62-
values: ... # See: https://devspace.sh/component-chart/docs/introduction
63-
```
64-
65-
</TabItem>
66-
<TabItem value="helm">
67-
68-
```yaml
69-
deployments:
70-
database: # Name of this deployment
71-
helm: # Deploy a Helm Chart
24+
name: component-chart
25+
repo: https://charts.devspace.sh
26+
values:
27+
containers:
28+
- image: ghcr.io/loft-sh/devspace-example-api
29+
service:
30+
ports:
31+
- port: 8080
32+
payments:
33+
helm:
7234
chart:
73-
name: bitnami/mysql # Deploy chart from bitnami registry
74-
values: ...
75-
backend: # Name of this deployment
76-
helm: ... # Deploy another Helm Chart
35+
name: ./payments/chart/
36+
valuesFiles:
37+
- ./payments/helm-values-dev.yaml
38+
auth:
39+
helm:
7740
chart:
78-
name: ./chart # Deploy chart from local folder
79-
values: ...
41+
name: auth-server-chart
42+
version: 3.2.1
43+
repo: https://mycompany.tld/helm/
44+
values:
45+
...
8046
```
47+
The example above defines 4 deployments:
48+
- `configs` which deploys two ConfigMap objects to Kubernetes from plain manifest files
49+
- `api` which is deployed from the component chart provided by DevSpace
50+
- `payments` which is deployed using a local Helm chart that is located in a folder
51+
- `auth` which is deployed from a chart that has been pushed to a Helm repository
52+
53+
54+
### 2. Call `create_deployments` in Pipeline
55+
DevSpace deploys resources to Kubernetes when the [`create_deployments` function](../functions/README.mdx#create_deployments) is called within `pipelines` as shown in this example:
56+
57+
```yaml title=devspace.yaml
58+
version: v2beta1
59+
pipelines:
60+
# highlight-start
61+
dev: |-
62+
create_deployments --all
63+
start_dev --all
64+
deploy: |-
65+
build_images --all
66+
create_deployments --all
67+
deploy-api: |-
68+
create_deployments api
69+
deploy-ordered: |-
70+
create_deployments auth
71+
create_deployments api payments
72+
# highlight-end
8173
82-
</TabItem>
83-
<TabItem value="manifests">
84-
85-
```yaml
8674
deployments:
87-
backend: # Name of this deployment
88-
kubectl: # Deploy Kubernetes manifests or Kustomizations
89-
manifests:
90-
- app/manifests/
91-
- db/deployment.yaml
92-
```
93-
94-
</TabItem>
95-
<TabItem value="kustomize">
96-
97-
```yaml
98-
deployments:
99-
backend: # Name of this deployment
100-
kubectl: # Deploy Kubernetes manifests or Kustomizations
101-
kustomize: true
102-
manifests:
103-
- app/kustomization/
104-
```
105-
106-
</TabItem>
107-
</Tabs>
108-
109-
:::info Sequential and Concurrent Deployment
110-
Deployments, like images, will be processed in parallel by default. To process deployments sequentially, you can specify it as a dependency, or override the pipeline and call [create_deployments](../../configuration/functions/README.mdx#create_deployments) sequentially.
111-
:::
112-
113-
## Run Deployments
114-
When you run one of the following commands, DevSpace will run the deployment process:
115-
- `devspace deploy` (before deploying the application)
116-
- `devspace dev` (before deploying the application and starting the development mode)
117-
118-
### Important Flags
119-
The following flags are available for all commands that trigger the deployment process:
120-
- `-d / --force-deploy` redeploy all deployments (even if they could be skipped because they have not changed)
121-
- `-b / --force-build` rebuild all images (even if they could be skipped because context and Dockerfile have not changed)
122-
123-
124-
## Deployment Process
125-
DevSpace loads the `deployments` configuration from `devspace.yaml` and by default deploys each deployment sequentially in the order that they are specified in the `deployments` array. Alternatively, some or all deployments can be configured to deploy in parallel by setting `concurrent: true`. Deployments with concurrency enabled will deploy before sequential deployments. Additionally, DevSpace also deploys related projects specified in `dependencies`.
126-
127-
:::warning Helm hooks and concurrency
128-
When using concurrency for Helm deployments that have Helm hooks, be cautious if those hooks depend on resources created by other deployments. You may want such a deployments to be run sequentially after concurrent deployments are completed. Otherwise, appropriate retry logic will be necessary for the affected Helm hook in order to avoid deployment failure.
129-
:::
130-
131-
### 1. Deploy Dependencies
132-
133-
<FragmentWorkflowDeployDependencies/>
134-
135-
136-
### 2. Build, Tag &amp; Push Images
137-
138-
<FragmentWorkflowBuildImages/>
139-
140-
141-
### 3. Tag Replacement
142-
143-
<FragmentWorkflowReplaceTags/>
144-
145-
146-
### 4. Deploy Project
147-
148-
<FragmentWorkflowDeployProject/>
149-
150-
<br/>
151-
152-
---
153-
154-
## Useful Commands
155-
156-
### `devspace list deployments`
157-
This command lists all deployments and their status:
158-
```bash
159-
devspace list deployments
75+
api: ... # see example above
76+
payments: ... # see example above
77+
auth: ... # see example above
16078
```
16179

162-
### `devspace render`
163-
This command prints all Kubernetes manifests that would be created when running `devspace deploy` or `devspace dev` but without actually deploying them to the cluster:
164-
```bash
165-
devspace render
166-
```
167-
In case of Helm deployments, this command behaves similar to `helm install --dry-run --debug`
16880

169-
:::info Image Building & Tag Replacement
170-
This command will build images (if necessary) and update the tags within manifests and Helm chart values.
171-
:::
81+
### 3. Run Pipeline
82+
Given the example above, you can now run:
83+
- `devspace deploy` or `devspace dev` to deploy all deployments
84+
- `devspace run-pipeline deploy-api` to deploy only the component chart deployment named `api`
85+
- `devspace run-pipeline deploy-ordered` to
86+
1. First deploy `auth` (blocking)
87+
2. Then deploy `api` and `payments` in parallel
17288

17389

17490
## Configuration
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
title: Helm Chart Source
3+
sidebar_label: Chart
4+
---
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
title: Deploy Applications via Component Chart
3+
sidebar_label: Component Chart
4+
---
5+
6+
import ConfigPartial from '../../../_partials/v2beta1/deployments/helm/componentChart/reference.mdx'
7+
8+
9+
DevSpace provides a built-in general purpose Helm chart that allows you to deploy applications without creating your own Helm chart. The idea of this chart is to be quite generic, so that it is suitable to deploy most applications with it by just customizing the values passed to the chart.
10+
11+
```yaml title=devspace.yaml
12+
version: v2beta1
13+
deployments:
14+
api:
15+
helm:
16+
chart:
17+
name: component-chart
18+
repo: https://charts.devspace.sh
19+
values:
20+
containers:
21+
- image: ghcr.io/loft-sh/devspace-example-api
22+
service:
23+
ports:
24+
- port: 8080
25+
```
26+
27+
:::info Values Validation
28+
Because the component chart is embedded into DevSpace itself, DevSpace will parse the `values` for a component chart deployment and is able to run a config validation against the component chart's values specification.
29+
:::
30+
31+
32+
## Values Reference
33+
The component chart supports the following fields for its `values`:
34+
35+
<ConfigPartial/>
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
title: Deploy Local Charts
3+
sidebar_label: Local Chart
4+
---
5+
6+
DevSpace can deploy Helm charts located on the same filesystem as the `devspace.yaml` file.
7+
8+
9+
## Local Charts vs Dependencies
10+
If you have multiple services located in the same git repository (monorepo), you may be tempted to have a single `devspace.yaml` at the root of the git repository and then specify one deployment for each service using a local path to each service's chart folder, for example. However, ideally you want to encapsule the build, deployment and development logic for each service inside a separate devspace.yaml that is located very closely to the actual code. This allows you work on microservices independenctly and only pull in other services if they are actually needed. DevSpace provides a feature called [`dependencies`](../../dependencies/README.mdx) which allows you to define relationships between `devspace.yaml` files to allow users to start working on a service while DevSpace stands up and maintains dependent microservices if needed.
11+
12+
13+
## Local Helm Charts
14+
To deploy a local Helm chart, you need to tell DevSpace where to locate the chart.
15+
16+
### From Folder
17+
A common structure is to have a folder in your git repository which contains the Helm chart for this service. In this case, use the `name` field to specify the path to the Helm chart folder relative to the `devspace.yaml` file.
18+
19+
```yaml title=devspace.yaml
20+
version: v2beta1
21+
deployments:
22+
payments:
23+
helm:
24+
chart:
25+
name: ./payments/chart/
26+
values:
27+
key: value
28+
...
29+
valuesFiles:
30+
- ./payments/helm-values-dev.yaml
31+
```
32+
33+
### From Tar Archive
34+
In case you want to deploy a Helm chart that has been archived to a `tar` file (or a compressed `.tar.gz` for example), you can use the `name` field to specify the path to the archive file relative to the `devspace.yaml` file.
35+
36+
```yaml title=devspace.yaml
37+
version: v2beta1
38+
deployments:
39+
payments:
40+
helm:
41+
chart:
42+
name: ./payments/chart.tar.gz
43+
values:
44+
key: value
45+
...
46+
valuesFiles:
47+
- ./payments/helm-values-dev.yaml
48+
```

0 commit comments

Comments
 (0)