Sunday, June 11, 2017

Bamboo plan configuration for Dockerized applications

Plan configuration

Build Stage
Run stage
creating cluster
cluster formation
Deploy stage : Dev,Staging,Prod

Build jobs:
Stage NameJob description
Build stageDefault Job:
->Source code checkout
->Building Docker image
(Image format:
'registry.address:port/namespace/repository:tag') 
Run stagePush the image to ECR:
->Script for Inject the ecr credentials
->Docker push (push the image to ECR).
creating cluster→command:
aws ecs create-cluster --cluster-name "appname-xxxxx" --region "us-east-1"



Stage name  -→  cluster formation
Job nameDescription
Bootstrapping Ec2 instance:→ command
knife bootstrap ipaddress.xxxxx --ssh-user centos --sudo --identity-file /home/bamboo/.ssh/xxxxx.pem --node-name nodename-xxxx --run-list 'role[ecs-xxxx]'
→ command
Adding the runlist
knife node run_list add nodenamexxxx 'role[role-name]'

→ command
Run task
aws ecs register-task-definition --family xxxapp --container-definitions "[{"name":"appname_container","image":"registry.address:port/namespace/repository:tag:xxxxxxxx: 10,"memory":300,"workingDirectory": "/opt/Directoryname","essential": true,"environment": [{"name": "NODE_ENV","value": "DEVELOPMENT"}],"portMappings": [ {"hostPort": 3001,"containerPort": 3001,"protocol": "tcp" } ],"command": ["node","bin/www"]}]" --network-mode "bridge"


The above following are the build jobs.

Deploy jobs:
We have to  deploy the containers in two servers  in three different environments(Dev,staging,Prod).

The tasks description in the bamboo deploy jobs:




Deploy-tasksDescription
Artifact downloadwe are taking the taskdef version from the build job  as an artifact and we are downloading in the current directory.
taskdef version contains the version number of taskdefinition(which is nothing but the container version).
Inject Bamboo variablesIn the above mentioned task,we will get the updated taskdef version and we need to inject that in the taskdef-version.txt,which is on the bamboo server.
ScriptIn this script configuration,we are providing the file,which consists of the stop task,In which it contains,which task should be stopped and removed.
CommandThis command task contains,the information about the cluster,taskdefintion and which helps us to deploy the container in proper environment.








No comments:

Post a Comment