Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: external dependencies and resource weight (#4596)
docs: add resource weight and external dependencies
- Loading branch information
1 parent
b2b7878
commit b92c9e9
Showing
7 changed files
with
152 additions
and
21 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
35 changes: 35 additions & 0 deletions
35
docs/pages_en/advanced/helm/deploy_process/external_dependencies.md
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,35 @@ | ||
--- | ||
title: External dependencies | ||
permalink: advanced/helm/deploy_process/external_dependencies.html | ||
--- | ||
|
||
To make one release resource dependent on another, you can change its [deployment order]({{ "/advanced/helm/deploy_process/deployment_order.html" | true_relative_url }}) so that the dependent one is deployed after the primary one has been successfully deployed. But what if you want a release resource to depend on a resource that is not part of that release or is not even managed by werf (e.g., created by some operator)? | ||
|
||
In this case, the [`<name>.external-dependency.werf.io/resource`]({{ "/reference/deploy_annotations.html#external-dependency-resource" | true_relative_url }}) annotation can help you set the dependency on an external resource. The annotated resource will not be deployed until the defined external dependency is created and ready. | ||
|
||
Example: | ||
```yaml | ||
kind: Deployment | ||
metadata: | ||
name: app | ||
annotations: | ||
secret.external-dependency.werf.io/resource: secret/dynamic-vault-secret | ||
``` | ||
|
||
In the example above, werf will wait for the `dynamic-vault-secret` to be created before proceeding to deploy the `app` deployment. We assume that `dynamic-vault-secret` is created by the operator from your Vault instance and is not managed by werf. | ||
|
||
Let's take a look at another example: | ||
```yaml | ||
kind: Deployment | ||
metadata: | ||
name: service1 | ||
annotations: | ||
service2.external-dependency.werf.io/resource: deployment/service2 | ||
service2.external-dependency.werf.io/namespace: service2-production | ||
``` | ||
|
||
Here, werf will not start deploying `service1` until the deployment of `service2` in another namespace has been successfully completed. Note that `service2` can either be deployed as part of another werf release or be managed by some other CI/CD software (i.e., outside of werf's control). | ||
|
||
Reference: | ||
* [`<name>.external-dependency.werf.io/resource`]({{ "/reference/deploy_annotations.html#external-dependency-resource" | true_relative_url }}) | ||
* [`<name>.external-dependency.werf.io/namespace`]({{ "/reference/deploy_annotations.html#external-dependency-namespace" | true_relative_url }}) |
61 changes: 61 additions & 0 deletions
61
docs/pages_en/advanced/helm/deploy_process/resource_order.md
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,61 @@ | ||
--- | ||
title: Deployment order | ||
permalink: advanced/helm/deploy_process/deployment_order.html | ||
--- | ||
|
||
By default, resources are applied and tracked simultaneously because they all have the same initial ([werf.io/weight: 0]({{ "/reference/deploy_annotations.html#resource-weight" | true_relative_url }})) (which means that you haven't changed it or deliberately set it to "0"). However, you can change the order in which resources are applied and tracked by setting different weights for them. | ||
|
||
Before the deployment phase, werf groups the resources based on their weight, then applies the group with the lowest associated weight and waits until the resources from that group are ready. After all the resources from that group have been successfully deployed, werf proceeds to deploy the resources from the group with the next lowest weight. The process continues until all release resources have been deployed. | ||
|
||
> Note that "werf.io/weight" works only for non-Hook resources. For Hooks, use "helm.sh/hook-weight". | ||
Let's look at the example: | ||
```yaml | ||
kind: Job | ||
metadata: | ||
name: db-migration | ||
--- | ||
kind: StatefulSet | ||
metadata: | ||
name: postgres | ||
--- | ||
kind: Deployment | ||
metadata: | ||
name: app | ||
--- | ||
kind: Service | ||
metadata: | ||
name: app | ||
``` | ||
|
||
All of the above resources will be deployed simultaneously because they all have the same default weight (0). But what if the database must be deployed before migrations, and the application should only start after the migrations are completed? Well, there is a solution to this problem! Try this: | ||
```yaml | ||
kind: StatefulSet | ||
metadata: | ||
name: postgres | ||
annotations: | ||
werf.io/weight: "10" | ||
--- | ||
kind: Job | ||
metadata: | ||
name: db-migration | ||
annotations: | ||
werf.io/weight: "20" | ||
--- | ||
kind: Deployment | ||
metadata: | ||
name: app | ||
annotations: | ||
werf.io/weight: "30" | ||
--- | ||
kind: Service | ||
metadata: | ||
name: app | ||
annotations: | ||
werf.io/weight: "30" | ||
``` | ||
|
||
In the above example, werf will first deploy the database and wait for it to become ready, then run migrations and wait for them to complete, and then deploy the application and the related service. | ||
|
||
Reference: | ||
* [`werf.io/weight`]({{ "/reference/deploy_annotations.html#resource-weight" | true_relative_url }}) |
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