Steps to on-board a new service
Pre-requisites
- First setup jenkins using
jenkins-setup.md - Each service should have a build folder which contains
Dockerfile,Jenkinsfileand abuild.shif needed. Jenkins file is very generic and one can use the givenJenkinsfilein the root folder of this repo. Following should be the repo structure at GitHub or any other SCM.
service_repo_name
- build
- Jenkinsfile
- Dockerfile
- build.sh (optional)
- src
- other folders
Steps for build
- Now go to build folder and create a new item. Copy an existing build job for this new item.
- Configure the newly created job and modify the paths of
Dockerfile,Jenkins,Git Repoaccording to your repository structure. - Test a build by clicking
Scan Multibranch pipeline now - The first build will fail on any branch always, rebuild again by clicking
Rebuild with Parameters
Steps for deploy
- Now go to deploy folder and create a new item. Copy an existing deploy job for this new item.
- Go to
ansible_workspace_dirand add a new tag and respective roles for the new service. You can use the structure of existing roles to add a new service. - Update the Nginx conf file to expose your services on the local host from the docker swarm.
Gotchas for localsetup
Uncomment the lines in inventory/hosts
Docker swarm will have all the services on a default network. Run
docker network create -d overlay application_defaultto create a default network for your services.ansible playbooks have global variables declared in
group_vars/dev.ymlandvars/main.ymlin theansible_workspace_dir. Local variables are there in each roles'vars/main.ymlWe use hashicorp vaults to store passwords so modify the
secret pathandVAULT_TOKENandVAULT_ADDRmanually.
Possible upcoming updates
standard routes for each services might be used in nginx default conf. Like to access esamwad-backend a route
/samarth/esamwad-backendwould be defined.Hashicorp intergration to manage secrets