Skip to content

Commit

Permalink
Merge pull request project-sunbird#797 from MasterAlt/release-2.4.0
Browse files Browse the repository at this point in the history
Notification service build and deployment Ansible scripts and Jenkins pipeline along health checks and revised memory and cpu limits
  • Loading branch information
G33tha authored Sep 9, 2019
2 parents 4206b87 + f36496c commit 46a560a
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 7 deletions.
9 changes: 7 additions & 2 deletions ansible/roles/stack-sunbird/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ config_limit_memory: 1024M
config_limit_cpu: 1
config_reservation_cpu: 1

# Notification Service vars
notification_replicas: 1
notification_limit_memory: 500MB
notification_limit_cpu: 1

# This variable is not to access learner service but to call the api
# learner-service:9000/org/v1/search
sunbird_learner_service_base_url: http://api-manager_kong:8000/
Expand Down Expand Up @@ -80,8 +85,8 @@ user_org_limit_cpu: 1
user_org_reservation_cpu: 1

cert_replicas: 1
cert_reservation_memory: 750MB
cert_limit_memory: 800MB
cert_reservation_memory: 500MB
cert_limit_memory: 550MB
cert_limit_cpu: 1
cert_reservation_cpu: 1

Expand Down
6 changes: 3 additions & 3 deletions ansible/roles/stack-sunbird/tasks/cert_service.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
- name: Remove user org service
- name: Remove cert service
shell: "docker service rm cert-service"
ignore_errors: yes

- name: Deploy user org service
shell: "docker service create --with-registry-auth --replicas {{ cert_replicas }} -p 9011:9000 --name cert-service --hostname cert-service --reserve-memory {{ cert_reservation_memory }} --limit-memory {{ cert_limit_memory }} --limit-cpu {{ cert_limit_cpu }} --reserve-cpu {{ cert_reservation_cpu }} --network application_default --env-file /home/deployer/env/sunbird_cert-service.env {{hub_org}}/{{image_name}}:{{image_tag}}"
- name: Deploy cert service
shell: "docker service create --with-registry-auth --replicas {{ cert_replicas }} -p 9011:9000 --name cert-service --hostname cert-service --limit-memory {{ cert_limit_memory }} --limit-cpu {{ cert_limit_cpu }} --health-cmd 'wget -qO- cert-service:9000/service/health || exit 1' --health-timeout 3s --health-retries 3 --network application_default --env-file /home/deployer/env/sunbird_cert-service.env {{hub_org}}/{{image_name}}:{{image_tag}}"
2 changes: 1 addition & 1 deletion ansible/roles/stack-sunbird/tasks/enc_service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
ignore_errors: yes

- name: Deploy enc service
shell: "docker service create --with-registry-auth --replicas {{ enc_replicas }} -p 9010:8013 --name enc-service --hostname enc-service --reserve-memory {{ enc_reservation_memory }} --limit-memory {{ enc_limit_memory }} --limit-cpu {{ enc_limit_cpu }} --reserve-cpu {{ enc_reservation_cpu }} --network application_default --env-file /home/deployer/env/sunbird_enc-service.env {{hub_org}}/{{image_name}}:{{image_tag}}"
shell: "docker service create --with-registry-auth --replicas {{ enc_replicas }} -p 9010:8013 --name enc-service --hostname enc-service --limit-memory {{ enc_limit_memory }} --limit-cpu {{ enc_limit_cpu }} --health-cmd 'wget -qO- enc-service:8013/service/health || exit 1' --health-timeout 3s --health-retries 3 --network application_default --env-file /home/deployer/env/sunbird_enc-service.env {{hub_org}}/{{image_name}}:{{image_tag}}"
3 changes: 3 additions & 0 deletions ansible/roles/stack-sunbird/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
- include: cert_service.yml
when: deploy_cert is defined

- include: notification_service.yml
when: deploy_notification is defined

- include: content_service.yml
when: deploy_content is defined

Expand Down
7 changes: 7 additions & 0 deletions ansible/roles/stack-sunbird/tasks/notification_service.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
- name: Remove notification service
shell: "docker service rm notification-service"
ignore_errors: yes

- name: Deploy notification service
shell: "docker service create --with-registry-auth --replicas {{ notification_replicas }} -p 9012:9000 --name notification-service --hostname notification-service --limit-memory {{ notification_limit_memory }} --limit-cpu {{ notification_limit_cpu }} --network application_default --env-file /home/deployer/env/sunbird_notification-service.env {{hub_org}}/{{image_name}}:{{image_tag}}"
2 changes: 1 addition & 1 deletion ansible/roles/stack-sunbird/tasks/user_org_service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
ignore_errors: yes

- name: Deploy user org service
shell: "docker service create --with-registry-auth --replicas {{ user_org_replicas }} -p 9009:9000 --name user-org-service --hostname user-org-service --reserve-memory {{ user_org_reservation_memory }} --limit-memory {{ user_org_limit_memory }} --limit-cpu {{ user_org_limit_cpu }} --reserve-cpu {{ user_org_reservation_cpu }} --network application_default --env-file /home/deployer/env/sunbird_user-org-service.env {{hub_org}}/{{image_name}}:{{image_tag}}"
shell: "docker service create --with-registry-auth --replicas {{ user_org_replicas }} -p 9009:9000 --name user-org-service --hostname user-org-service --limit-memory {{ user_org_limit_memory }} --limit-cpu {{ user_org_limit_cpu }} --health-cmd 'wget -qO- user-org-service:9000/service/health || exit 1' --health-timeout 3s --health-retries 3 --network application_default --env-file /home/deployer/env/sunbird_user-org-service.env {{hub_org}}/{{image_name}}:{{image_tag}}"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sunbird_enc_service_url=http://enc-service:8013
30 changes: 30 additions & 0 deletions pipelines/deploy/notification/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
@Library('deploy-conf') _
node() {
try {
stage('checkout public repo') {
cleanWs()
checkout scm
}

stage('deploy') {
values = docker_params()
currentWs = sh(returnStdout: true, script: 'pwd').trim()
ansiblePlaybook = "$currentWs/ansible/deploy.yml"
ansibleExtraArgs = "--tags \"stack-sunbird\" --extra-vars \"hub_org=$hub_org image_name=$values.image_name image_tag=$values.image_tag service_name=notification-service deploy_notification=True\" --vault-password-file /var/lib/jenkins/secrets/vault-pass"
values.put('currentWs', currentWs)
values.put('ansiblePlaybook', ansiblePlaybook)
values.put('ansibleExtraArgs', ansibleExtraArgs)
ansible_playbook_run(values)
archiveArtifacts 'metadata.json'
currentBuild.description = "Image: ${values.image_tag}, Private: ${params.private_branch}, Public: ${params.branch_or_tag}"
}
}
catch (err) {
currentBuild.result = "FAILURE"
throw err
}
finally {
slack_notify(currentBuild.result)
email_notify()
}
}

0 comments on commit 46a560a

Please sign in to comment.