Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Best practive 2 VM in Production Enviroment

lprada September 13, 2022

Hi, I am configguring pipelines to deploy to production. We haver 2 VM behinf a gateway to have redundancy. My question are this

 

1. We should have only one enviroment production or one for each VM.

2. How do I have to set the pipeline runner on windows? 2 runners with the same tag so they detect where to build, if this is the case is who I can deploy first in one vm and then in the other to minice downtime?

 

 

1 answer

1 accepted

0 votes
Answer accepted
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 14, 2022

Hi @lprada,

Are you planning to set up pipelines for deployment that run automatically (e.g. on branches, tags, or default) or custom pipelines for deployment (that do not run automatically, but get triggered manually or on schedule)?

I'm asking so I can give a better recommendation and a better answer to your questions depending on your use case.

Kind regards,
Theodora

lprada September 14, 2022

We want full automation, I must add that we are use ITSM of Jira to have gate for the services in production.

Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 14, 2022

Hi @lprada,

Thank you for your reply.

If you want to see the history of deployments for each VM, I would recommend configuring two deployment environments in Repository settings > Deployments.

If you open a repository on Bitbucket Cloud website, there is an option Deployments on the left-hand panel (right below the Pipelines option).
When you start making deployments, this page will show you the latest deployment for each environment, and if you select one of the environments you will see the deployment history for each environment.

If you want to deploy after every push on e.g. master branch, you can use a configuration as follows in your bitbucket-pipelines.yml file.

pipelines:
branches:
master:
- step:
runs-on:
- self.hosted
- windows
name: Deployment to Production 1
deployment: Production1
script:
- <commands to deploy here>
- step:
runs-on:
- self.hosted
- windows
name: Deployment to Production 2
deployment: Production2
script:
- <commands to deploy here>

The steps are executed sequentially this way. Please note that if the first step (Deployment to Production 1) fails, the second step (Deployment to Production 2) won't be executed.

 

For Windows Runners, we only support running one runner per machine. A second runner would need to run on a different machine.

However, since you want to deploy first to one VM and then to the second one, you can use one runner only. With one runner and the configuration I shared above, both steps will be executed on the same runner, and the first step must complete successfully for the second one to start.

Please feel free to let me know if you have any questions or other requirements.

Kind regards,
Theodora

lprada September 14, 2022

@Theodora Boudale I have another question, I made  a test with the idea to deploy to the 2 vm at de same time. I have 2 workers with the same label but the step only run in one vm, how to I make a step that has to run in all wokers with the label, for example next year we add another VM.

lprada September 15, 2022

Did you read the new message?

Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 16, 2022

Hi @lprada,

If you want to deploy to the 2 VMs at the same time, you will need to use the 'parallel' keyword in the bitbucket-pipelines.yml file and also have 2 runners available.

An example yaml file is as follows:

pipelines:
branches:
master:
- parallel:
- step:
runs-on:
- self.hosted
- windows
name: Deployment to Production 1
deployment: Production1
script:
- <commands to deploy here>
- step:
runs-on:
- self.hosted
- windows
name: Deployment to Production 2
deployment: Production2
script:
- <commands to deploy here>


If you have 2 runners with labels self.hosted and windows, and both are available, the 1st step will run in one runner and the 2nd step should run on the other available runner.

You can also use an additional label for each of the 2 runners, if you want to target each step to a specific runner (any additional labels should be added in the bitbucket-pipelines.yml file on the respective step's labels).

As a sidenote, I just wanted to give you a heads up that you can only have one in-progress deployment in each environment (one in-progress deployment for Production1, and one in-progress deployment for Production2 ). Any later pipelines that deploy to the same environment will be automatically paused. You can manually resume the paused deployment step once the in-progress deployment completes, I'm afraid that it is not possible at the moment to resume them automatically. We do have a feature request in our issue tracker for automatically resuming those https://jira.atlassian.com/browse/BCLOUD-16304

Please feel free to let me know if you have any questions.

Kind regards,
Theodora

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events