Skip to content

Commit f276ece

Browse files
authored
Merge pull request #2515 from OctopusDeploy/bobjwalker/dr-guide-best-practice
Wrapping up HA/DR Guides
2 parents 5691176 + 8530995 commit f276ece

File tree

9 files changed

+409
-170
lines changed

9 files changed

+409
-170
lines changed
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
---
2+
layout: src/layouts/Default.astro
3+
pubDate: 2023-01-01
4+
modDate: 2024-06-27
5+
title: Environments, Deployment Targets, and Target Tags
6+
description: Guidelines and recommendations for configuring environments, deployment targets, and lifecycles in Octopus Deploy.
7+
navOrder: 30
8+
hideInThisSection: true
9+
---
10+
11+
[Deployment targets](/docs/infrastructure/deployment-targets/) are what Octopus Deploy deploys to. They can be Windows servers, Linux servers, Kubernetes (K8s) clusters, Azure Web Apps, and more. Please refer to the [Deployment targets](/docs/infrastructure/deployment-targets/) for an up to date list on deployment targets. [Environments](/docs/infrastructure/environments) are how you organize your deployment targets into groups that represent different stages of your deployment pipeline. These stages are typically given names such as **development**, **test**, and **production**. [Target tags](/docs/infrastructure/deployment-targets/target-tags) (formerly target roles) are a filter to select specific deployment targets in an environment.
12+
13+
## Deployment Target, Environment, and Target Tag relationship \{#deployment-target-environment-and-role-relationship}
14+
Environments are how you group deployment targets in a stage in your deployment pipeline. Target tags are how you identify which deployment targets you wish to deploy to in that specific stage.
15+
16+
When you register a deployment target, you must provide at least one environment and one target tag.
17+
18+
:::figure
19+
![Environments and target tags for a deployment target](/docs/getting-started/best-practices/images/registering-deployment-target.png)
20+
:::
21+
22+
In the deployment process, you assign steps to run on deployment targets with specific target tags.
23+
24+
:::figure
25+
![Deployment process target tag assignment](/docs/getting-started/best-practices/images/target-roles-in-deployment-process.png)
26+
:::
27+
28+
For example, imagine you have three deployment targets in the **development** environment with the following target tags:
29+
- dev-server-01: `hello-world`, `hello-world-api`, `hello-world-ui`, and `IIS-Server-2019` tags
30+
- dev-server-02: `hello-world-api` and `IIS-Server-2019` tags
31+
- dev-server-03: `octo-petshop-api` and `IIS-Server-2019` tags
32+
33+
The deployment process from above targets the `hello-world-api` tag. When a deployment to the **development** environment is triggered, Octopus will only select the two servers assigned to the **development** environment AND with the `hello-world-api` target tag.
34+
35+
:::figure
36+
![Octopus selecting deployment targets](/docs/getting-started/best-practices/images/selecting-target-roles.png)
37+
:::
38+
39+
:::div{.hint}
40+
Assigning multiple target tags to a deployment step results in an OR statement. For example, adding the target tag `octo-petshop-api` to the deployment process and deploying to the **development** environment will result in the filtering logic to be:
41+
42+
All servers in the **development** environment AND the servers with the target tags `hello-world-api` OR `octo-petshop-api`.
43+
44+
For software developers, you can rewrite that sentence as:
45+
46+
`If (server.Environment == "development" && (server.TargetTag == "hello-world-api" || server.TargetTag == "octo-petshop-api"))`
47+
48+
Using the example from above, Octopus would select all three servers.
49+
:::
50+
51+
## Environment and Target Tag usage differences \{#environment-and-role-usage-differences}
52+
53+
Environments are designed as a macro grouping of deployment targets meant for use across multiple projects, variable sets, and more. Below is a list of items where environments are used:
54+
55+
- Lifecycles
56+
- Project Variable scoping
57+
- Variable Set scoping
58+
- Log filtering
59+
- Tenant variable scoping
60+
- Accounts
61+
- Certificates
62+
- Deployment targets
63+
- Process step scoping (only run a step on a specific environment)
64+
65+
Target tags are designed as a micro grouping of deployment targets meant to deploy a specific project or application component. Below is a list of items where tags are used:
66+
67+
- Project Variable scoping
68+
- Process step scoping (run this step for specific environments)
69+
70+
:::div{.hint}
71+
A deployment target can be assigned to 1 to N environments and 1 to N target tags.
72+
:::
73+
74+
## Environments
75+
76+
Adding an environment is a non-trivial task, as it involves adding/updating additional deployment targets, variable scoping, lifecycles accounts, certificates, and more. There is a direct correlation between a high number of environments and poor maintainability, usability, and performance.
77+
78+
Our recommendations for environments are:
79+
- Keep the number of environments per space to be between 2 and 10.
80+
- Name environments to match your company's terminology so you can re-use them across projects. Common names include **development**, **test**, **QA**, **acceptance**, **uat**, and **production**.
81+
- If you have between one and five data centers (including cloud regions), it's okay to have an environment per data center. For example, **Production - AU** for a data center in Australia and **Production - Central US** for the Azure Central US region. If you have more than five data centers, consider [tenants](/docs/tenants) where each data center is a tenant.
82+
- It's okay to have team-specific environments, similar to data center environments. Although if you have more than five or six teams, consider [tenants](//docs/tenants/) where each team is a tenant.
83+
84+
Anti-patterns to avoid are:
85+
- Project names in your environments. An environment name of **QA - OctoPetShop** indicates you need to either have more specific target tags on your deployment targets or you need to leverage spaces to isolate that application. Project-specific environments are a good indicator to consider [spaces](/docs/administration/spaces).
86+
- Branch names in your environment names. Consider using temporary [tenants](/docs/tenants) for your branch names or storing your branch name in a pre-release tag in the release version.
87+
- A single deployment environment, **production**. You should have at least one test environment to test and verify your release.
88+
89+
## Target Tags \{#roles}
90+
91+
There is also a direct correlation between generic target tags, such as `web-server` and the number of environments. As stated earlier, adding an environment is a non-trivial task, and leads to maintenance and performance overhead. The goal is to keep the number of environments low.
92+
93+
Using the generic target tag `web-server` will pick all the servers in a specific environment. For example, you have 25 servers in **production** with the tag `web-server`. When you deploy to **production**, Octopus will pick all 25 servers, but you only want to deploy to 4 of them. There is no automatic way to limit the servers picked without either creating a specific tag `hello-world-api` or creating a new environment.
94+
95+
Generic target tags also impact your future flexibility. For example, using `web-server` for 100 projects would require all targets on all environments to host those same 100 projects. If you were to decide in six months to split up those servers, you'd have to update over 100 projects.
96+
97+
Our recommendations for target tags are:
98+
- Avoid generic tags, such as `web-server`, whenever possible.
99+
- Use specific tags, `hello-world-api`, to uniquely identify a project and component to deploy. Use those specific tags in your deployment process.
100+
- Use architecture and platform-specific tags, for example, `IIS-Server-Windows-2019`. Use those tags for everyday maintenance tasks; updating to the latest version of Node.js, or installing a patch.
101+
102+
:::div{.hint}
103+
Add an environment for a business need; a new data center is brought online, you are adding your disaster recovery location into Octopus, or adding the ability for customers to test changes prior to **production**.
104+
105+
Add a new target tag to group servers and filter servers within each environment.
106+
:::
107+
108+
## Further reading
109+
110+
For further reading on environments, deployment targets, and target tags in Octopus Deploy please see:
111+
112+
- [Deployment Targets](/docs/infrastructure/deployment-targets)
113+
- [Environments](/docs/infrastructure/environments)
114+
- [Target Tags](/docs/infrastructure/deployment-targets/target-tags#create-target-roles)

src/pages/docs/best-practices/deployments/index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ This section covers our recommendations and implementation guides for configurin
1414

1515
The topics covered are:
1616

17+
- [Environments, deployment targets, and target tags](/docs/best-practices/deployments/environments-and-deployment-targets-and-roles)
1718
- [Lifecycles and Environments](/docs/best-practices/deployments/lifecycles-and-environments)
19+
- [Projects and Project group structure](/docs/best-practices/deployments/projects-and-project-groups)
1820
- [Deployment and Runbook Process](/docs/best-practices/deployments/deployment-and-runbook-processes)
1921
- [Variables](/docs/best-practices/deployments/variables)
2022
- [Step Templates and Script Modules](/docs/best-practices/deployments/step-templates-and-script-modules)
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
---
2+
layout: src/layouts/Default.astro
3+
pubDate: 2023-01-01
4+
modDate: 2023-10-04
5+
title: Projects and Project Groups Structure
6+
description: Guidelines and recommendations for configuring projects and project groups in Octopus Deploy.
7+
navOrder: 50
8+
hideInThisSection: true
9+
---
10+
11+
[Projects](/docs/projects) store the deployment configuration for an application. For each project, you can define a deployment process and runbooks to manage your infrastructure, variables, the environments where the software is deployed, and your software releases. Project groups allow you to group like projects together.
12+
13+
## Project structure
14+
15+
We recommend thinking of projects and project groups this way:
16+
17+
- Project Group = Software Suite
18+
- Project = Application
19+
20+
An application represents all the tightly coupled components required for the software to run. Some examples of applications are:
21+
22+
- A microservice running in a container monitoring a queue for work.
23+
- An N-Tier Web Application with a WebUI, WebAPI, back-end Service, and Database.
24+
- A back-end service that processes files from a file share based on a schedule.
25+
- A monolithic application with dozens of components.
26+
27+
All the components in a single "solution" or built in the same configuration should be deployed together. The deployment process should always deploy all the components. Trying to skip a component because it "didn't change" can reduce deployment time but increases the risk of bugs or failures because something was missed.
28+
29+
If you want to have a project per component, you need to ensure each component is decoupled from one another and can be deployed on a separate schedule.
30+
31+
:::div{.hint}
32+
Previous versions of this guide recommended having a project per component. Octopus Deploy now includes new features, including ITSM integration, Config as Code, and more options for variable run conditions. There is also a logistical overhead with a project per component. That recommendation was made in 2021. At that time, a project per component made sense. It is no longer applicable with the 2023 version of Octopus Deploy.
33+
:::
34+
35+
## Anti-patterns to avoid
36+
37+
A project should deploy all the coupled components of an application (WebUI, WebAPI, Service, Database). Some common anti-patterns we've seen you should avoid are:
38+
39+
- A project per component in an application. If the components are referenced in the same "solution" or built in the same build configuration, they need to be deployed together.
40+
- A project per application, per environment, such as `OctoPetShop_Dev`, `OctoPetShop_Test`, and so on. That is impossible to maintain and track versions.
41+
- A project per customer or physical location, such as `OctoPetShop_AustinEast`, `OctoPetShop_AustinWest`, and so on. This is impossible to maintain, you'd need a syncing process for all projects. Use [multi-tenancy](/docs/tenants) instead.
42+
43+
## Cumulative changes
44+
45+
Octopus Deploy expects any application component it deploys to contain everything that the component needs. If you are deploying a web application, the deployment should include all the JavaScript, CSS, binaries, HTML files, etc., needed to run that web application. It shouldn't just be a delta change of a few HTML files or binaries. Octopus Deploy expects that for a variety of reasons.
46+
47+
- All releases will need to be deployed to all environments.
48+
- Deploying only delta changes requires you to always deploy all versions in a specific order.
49+
- If a new deployment target (web server) is created, you will have to deploy all versions to that new target rather than the latest.
50+
- You'll need a mechanism to create roll-up releases; otherwise, the list of versions to deploy when a new target is added will grow and become unwieldy.
51+
- It'll be near impossible to roll back to a previous version of the code.
52+
53+
## Further reading
54+
55+
For further reading on projects and project groups in Octopus Deploy, please see:
56+
57+
- [Projects](/docs/projects)
58+
- [Multi-Tenancy](/docs/tenants)

0 commit comments

Comments
 (0)