Skip to content

Commit e096426

Browse files
committed
perf improvements
1 parent 57d970c commit e096426

File tree

6 files changed

+97
-29
lines changed

6 files changed

+97
-29
lines changed

Diff for: Dockerfile

+2
Original file line numberDiff line numberDiff line change
@@ -131,3 +131,5 @@ COPY roles /opt/ansible/roles
131131
RUN chown -R apb:0 /opt/{ansible,apb} && \
132132
chmod -R g=u /opt/{ansible,apb}
133133
USER apb
134+
ENV ANSIBLE_PIPELINING=True \
135+
ANSIBLE_CALLBACK_WHITELIST=profile_tasks

Diff for: playbooks/deprovision.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
- name: mssql-apb playbook to deprovision the application
33
hosts: localhost
4-
gather_facts: false
4+
gather_facts: False
55
connection: local
66
roles:
77
- role: ansible.kubernetes-modules

Diff for: playbooks/provision.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
- name: mssql-apb playbook to provision the application
33
hosts: localhost
4-
gather_facts: false
4+
gather_facts: False
55
connection: local
66
roles:
77
- role: ansible.kubernetes-modules

Diff for: playbooks/test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
- name: "[MSSQL-APB] [TEST] Test MSSQL APB"
33
hosts: localhost
4-
gather_facts: false
4+
gather_facts: False
55
connection: local
66
roles:
77
- role: ansible.kubernetes-modules

Diff for: roles/deprovision-mssql-apb/tasks/main.yml

+28
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
name: '{{ service_instance }}'
1515
namespace: '{{ namespace }}'
1616
state: '{{ state }}'
17+
async: 180
18+
poll: 0
19+
register: rm_svc
1720

1821

1922
##############################################################################
@@ -25,6 +28,9 @@
2528
name: '{{ service_instance }}'
2629
namespace: '{{ namespace }}'
2730
state: '{{ state }}'
31+
async: 180
32+
poll: 0
33+
register: rm_dc
2834

2935

3036
##############################################################################
@@ -34,3 +40,25 @@
3440
name: '{{ service_instance }}'
3541
namespace: '{{ namespace }}'
3642
state: '{{ state }}'
43+
async: 180
44+
poll: 0
45+
register: rm_secret
46+
47+
48+
- name: 'Check on service task'
49+
async_status: jid={{ rm_svc.ansible_job_id }}
50+
register: svc_job_result
51+
until: svc_job_result.finished
52+
retries: 60
53+
54+
- name: 'Check on DC task'
55+
async_status: jid={{ rm_dc.ansible_job_id }}
56+
register: dc_job_result
57+
until: dc_job_result.finished
58+
retries: 60
59+
60+
- name: 'Check on secret task'
61+
async_status: jid={{ rm_secret.ansible_job_id }}
62+
register: s_job_result
63+
until: s_job_result.finished
64+
retries: 60

Diff for: roles/provision-mssql-apb/tasks/main.yml

+64-26
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,47 @@
1414
- name: '{{ mssql_image_tag }}'
1515
docker_image_repository: '{{ mssql_image }}'
1616
state: '{{ state }}'
17+
async: 180
18+
poll: 0
19+
register: create_is
1720
when: mssql_local != true
1821

22+
- name: Create secret
23+
k8s_v1_secret:
24+
name: '{{ service_instance }}'
25+
namespace: '{{ namespace }}'
26+
string_data:
27+
ACCEPT_EULA: "Y"
28+
MSSQL_SA_PASSWORD: '{{ mssql_sa_pw }}'
29+
MSSQL_PID: '{{ mssql_pid }}'
30+
MSSQL_LCID: '{{ mssql_lcid | string }}'
31+
MSSQL_AGENT_ENABLED: '{{ mssql_agent | string }}'
32+
MSSQL_MEMORY_LIMIT_MB: '{{ (( memory_limit | int ) * 1000 ) | string }}'
33+
state: '{{ state }}'
34+
async: 180
35+
poll: 0
36+
register: create_secret
37+
38+
- name: Create PVC for persistent deployment
39+
k8s_v1_persistent_volume_claim:
40+
name: '{{ service_instance }}'
41+
namespace: '{{ namespace }}'
42+
access_modes:
43+
- ReadWriteOnce
44+
resources_requests:
45+
storage: '{{ volume_size }}G'
46+
state: '{{ state }}'
47+
async: 180
48+
poll: 0
49+
register: create_pvc
50+
when: _apb_plan_id == "persistent"
51+
1952

2053
##############################################################################
2154
## A Kubernetes service serves as an internal load balancer. It identifies a
2255
## set of replicated pods in order to proxy the connections it receives to them.
2356
##############################################################################
24-
- name: Create '{{ service_instance }}' service
57+
- name: Create service
2558
k8s_v1_service:
2659
name: '{{ service_instance }}'
2760
namespace: '{{ namespace }}'
@@ -37,7 +70,7 @@
3770
target_port: 1433
3871
state: '{{ state }}'
3972

40-
- name: Create '{{ service_name }}' service
73+
- name: Create '{{ service_name }}' CNAME service
4174
k8s_v1_service:
4275
name: '{{ service_name }}'
4376
namespace: '{{ namespace }}'
@@ -54,6 +87,9 @@
5487
port: '{{ service_port }}'
5588
target_port: 1433
5689
state: '{{ state }}'
90+
async: 180
91+
poll: 0
92+
register: create_svc_cname
5793

5894

5995
##############################################################################
@@ -198,30 +234,6 @@
198234
state: '{{ state }}'
199235
when: _apb_plan_id == "persistent"
200236

201-
- name: Create secret
202-
k8s_v1_secret:
203-
name: '{{ service_instance }}'
204-
namespace: '{{ namespace }}'
205-
string_data:
206-
ACCEPT_EULA: "Y"
207-
MSSQL_SA_PASSWORD: '{{ mssql_sa_pw }}'
208-
MSSQL_PID: '{{ mssql_pid }}'
209-
MSSQL_LCID: '{{ mssql_lcid | string }}'
210-
MSSQL_AGENT_ENABLED: '{{ mssql_agent | string }}'
211-
MSSQL_MEMORY_LIMIT_MB: '{{ (( memory_limit | int ) * 1000 ) | string }}'
212-
state: '{{ state }}'
213-
214-
- name: Create PVC for persistent deployment
215-
k8s_v1_persistent_volume_claim:
216-
name: '{{ service_instance }}'
217-
namespace: '{{ namespace }}'
218-
access_modes:
219-
- ReadWriteOnce
220-
resources_requests:
221-
storage: '{{ volume_size }}G'
222-
state: '{{ state }}'
223-
when: _apb_plan_id == "persistent"
224-
225237

226238
##############################################################################
227239
## Encode bind credentials.
@@ -238,6 +250,32 @@
238250
DB_URI: 'Data Source={{ service_instance }}.{{ namespace }}.svc,{{ service_port }}; Initial Catalog={{ mssql_db }}; User Id=SA; Password={{ mssql_sa_pw }};'
239251
when: action == 'provision'
240252

253+
- name: 'Check on ImageStream task'
254+
async_status: jid={{ create_is.ansible_job_id }}
255+
register: is_job_result
256+
until: is_job_result.finished
257+
retries: 60
258+
when: mssql_local != true
259+
260+
- name: 'Check on secret task'
261+
async_status: jid={{ create_secret.ansible_job_id }}
262+
register: s_job_result
263+
until: s_job_result.finished
264+
retries: 60
265+
266+
- name: 'Check on PVC task'
267+
async_status: jid={{ create_pvc.ansible_job_id }}
268+
register: pvc_job_result
269+
until: pvc_job_result.finished
270+
retries: 60
271+
when: _apb_plan_id == "persistent"
272+
273+
- name: 'Check on service CNAME task'
274+
async_status: jid={{ create_svc_cname.ansible_job_id }}
275+
register: csvc_job_result
276+
until: csvc_job_result.finished
277+
retries: 60
278+
241279
- name: Wait for mssql to come up
242280
wait_for:
243281
host: '{{ service_instance }}.{{ namespace }}.svc'

0 commit comments

Comments
 (0)