Environments and Pipelines
What are Environments
Environments are a stand-alone, sandboxed grouping of resources that allow you to deploy an instance of an Aineko Project into. This allows for faster development cycles as the feedback loop is tightened.
- Deployment branches
-
These are branches that correspond to environments. For example, the
develop
environment will be based off thedevelop
branch. Every time thedevelop
branch changes, Aineko Cloud will attempt to update thedevelop
environment to match what is reflected in the codebase.
Initial environments
By default, we initialize the 2 environments develop
and production
for every repository. This is in line to best engineering best practices where developers use a develop
environment to test the latest version of the codebase before deploying it into production.
Environment separation
Each environment is within its own VPC, and so are unable to communicate with each other. This ensure they do not impact each other in any way, so for example a bug in develop
should never affect your production
environment.
In the example deployment configuration below, the environments
block configures the pipeline to run for each environment. Note that deployments are only triggered when commits are made to the branch that matches the environment name. For example, only the pipelines under the develop
key are deployed when this file is committed to the develop
branch.
Example deploy.yml
version: 0.1.0
environments:
develop:
pipelines:
- example_pipeline_1
- example_pipeline_2
production:
pipelines:
- example_pipeline_2
pipelines:
example_pipeline_1:
source: conf/pipeline_1.yml
example_pipeline_2:
source: conf/pipeline_2.yml
Here are a few examples on the deployment behavior when the example deployment configuration is committed to different branches:
Example deployment scenarios when commit is made to different branches
develop
environment-
example_pipeline_1
andexample_pipeline_2
are deployed or updated to reflect any new changes. production
environment-
Remains untouched; any pipelines currently running there remains unaffected.
develop
environment-
Remains untouched; any pipelines currently running there remains unaffected.
production
environment-
example_pipeline_2
is deployed or updated to reflect any new changes.
develop
environment-
Remains untouched; any pipelines currently running there remains unaffected.
production
environment-
Remains untouched; any pipelines currently running there remains unaffected.
Create a new Environment
Warning
Note, for the Beta release of Aineko Cloud, we allow up to 4 different environments per project.
Warning
The environment name must be 1 to 24 characters long and can only contain letters, numbers, and dashes.
To create a new environment in addition to the default develop
and production
environments, you can simply update deploy.yml
to reflect this. For example, to create a staging
environment, push the following deploy.yml
to a branch called staging
:
Example deploy.yml
with staging
environment
version: 0.1.0
environments:
develop:
pipelines:
- example_pipeline_1
- example_pipeline_2
staging:
pipeline:
- example_pipeline_2
production:
pipelines:
- example_pipeline_2
pipelines:
example_pipeline_1:
source: conf/pipeline_1.yml
example_pipeline_2:
source: conf/pipeline_2.yml
This will trigger the initialize-environment
workflow, which kicks off the provisioning of the environment. Similar to the earlier step Create an Aineko Project, this step will take 60-90 minutes. Thereafter, you will be able to quickly and easily deploy pipelines just like you would to the develop
and production
environments.
Destroying Pipelines in an Environment
To destroy a pipeline existing in an environment, we can simply remove that pipeline name from the environment key. Following on from the above example, if we wanted to destroy example_pipeline_1
from the develop
environment, we would commit the following deployment configuration to the develop
branch:
Example deploy.yml
to destroy pipeline
version: 0.1.0
environments:
develop:
pipelines:
- example_pipeline_2
staging:
pipeline:
- example_pipeline_2
production:
pipelines:
- example_pipeline_2
pipelines:
example_pipeline_1:
source: conf/pipeline_1.yml
example_pipeline_2:
source: conf/pipeline_2.yml
To remove all pipelines from an environment, remove the relevant environment key. For example, you would remove the staging
block to destroy all pipelines in that environment.
Limitation: removing all pipelines across environments
The environments
key is required for a valid deployment configuration. Hence, to remove all pipelines across every environment, you will need a deploy.yml
that looks like the following:
version: 0.1.0
environments:
develop:
pipelines: []
Delete an Environment
Destroying all pipelines in an environment does not destroy the environment
Destroying pipelines does not destroy the other services running in the background that make the magic of an Aineko Cloud environment possible. These inactive environments will still count to the 4 environment limit.
To completely destroy an environment, first make sure that any pipelines running on it is successfully destroyed. Then reach out to us at support@aineko.dev to request an environment deletion. The deletion process will take about a day.
Note that once an environment is deleted, if we ever want to add it back, it will have to be re-initialized.