-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: Plug datadog apm #101
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{% if ddtrace is defined and ddtrace %} | ||
apiVersion: v1 | ||
kind: BuildConfig | ||
metadata: | ||
labels: | ||
app: richie | ||
service: richie | ||
version: "{{ richie_image_tag }}" | ||
deployment_stamp: "{{ deployment_stamp }}" | ||
name: "richie-{{ deployment_stamp }}" | ||
namespace: "{{ project_name }}" | ||
spec: | ||
successfulBuildsHistoryLimit: 5 | ||
failedBuildsHistoryLimit: 2 | ||
triggers: | ||
- type: ImageChange | ||
- type: ConfigChange | ||
strategy: | ||
type: Docker | ||
source: | ||
dockerfile: |- | ||
FROM {{ richie_image_name }}:{{ richie_image_tag }} | ||
# Switch back to the root user to install development dependencies | ||
USER root:root | ||
|
||
RUN pip install --no-cache-dir --prefix=/usr/local ddtrace | ||
CMD ddtrace-run gunicorn -c /usr/local/etc/gunicorn/richie.py richie.wsgi:application | ||
|
||
# Un-privileged user running the application | ||
USER 10000 | ||
output: | ||
to: | ||
kind: ImageStreamTag | ||
name: "ddtrace-richie-{{ deployment_stamp }}:{{ richie_image_tag }}" | ||
{% endif %} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,8 +20,13 @@ spec: | |
deployment_stamp: "{{ deployment_stamp }}" | ||
spec: | ||
containers: | ||
- name: richie | ||
- name: "richie" | ||
{% if ddtrace is defined and ddtrace %} | ||
image: "docker-registry.default.svc:5000/{{ project_name }}/ddtrace-richie-{{ deployment_stamp }}:{{ richie_image_tag }}" | ||
#image: "ddtrace-richie-{{ deployment_stamp }}:{{ richie_image_tag }}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do you need to force docker registry address? Because of Anyway, only the commented line should stay right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We discussed this with @rouja and propose to always point to an image stream. The syntax is more or less:
Then in the image stream, we build the image we need for each project:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's a wonderful feature. I'll declare a new issue for this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jmaupetit There is already a PR for this ;-) #105 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤔 yes, but it only scopes edxapp right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. True! But it's a functional POC whereas my comment above was a bit vague. |
||
{% else %} | ||
image: "{{ richie_image_name }}:{{ richie_image_tag }}" | ||
{% endif %} | ||
imagePullPolicy: IfNotPresent | ||
env: | ||
- name: DJANGO_SETTINGS_MODULE | ||
|
@@ -38,6 +43,18 @@ spec: | |
value: "{{ richie_host }}" | ||
- name: ES_CLIENT | ||
value: "richie-{{ richie_elasticsearch_host }}-{{ deployment_stamp }}" | ||
{% if ddtrace is defined and ddtrace %} | ||
- name: DATADOG_TRACE_AGENT_HOSTNAME | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: status.hostIP | ||
- name: DD_AGENT_SERVICE_HOST | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: status.hostIP | ||
- name: DD_AGENT_SERVICE_PORT | ||
value: '8126' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should it be configurable, e.g. stored in a var? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it should come from a variable? |
||
{% endif %} | ||
envFrom: | ||
- secretRef: | ||
name: richie-{{ secret_id }} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{% if ddtrace is defined and ddtrace %} | ||
apiVersion: v1 | ||
kind: ImageStream | ||
metadata: | ||
labels: | ||
app: richie | ||
service: richie | ||
version: "{{ richie_image_tag }}" | ||
deployment_stamp: "{{ deployment_stamp }}" | ||
name: "ddtrace-richie-{{ deployment_stamp }}" | ||
namespace: "{{ project_name }}" | ||
{% endif %} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,6 +62,12 @@ job_stamp: null | |
# docs/developer_guide/secrets.md | ||
secret_id: "1.0.0" | ||
|
||
|
||
# ddtrace is set to true for enable the APM in all apps where the templates | ||
# include the possibility to have a ddtrace APM agent | ||
# defaul is set to False | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would write: # Set xxx to "true" to enable APM in all apps where defined templates
# include this feature (default: "false") |
||
ddtrace: false | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we name it |
||
|
||
# TODO: move the following settings to the redirect app | ||
# Ports | ||
aliases_port: 8999 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
$ANSIBLE_VAULT;1.1;AES256 | ||
32383464343731303731643337633338333463636366306138343430336336383961353638326165 | ||
6639623661623435383237626634653036316361323535390a653966386136366461343961663561 | ||
63346637353036383837303964653438303564623739386334633763333866316637613138643435 | ||
6162393439326261360a613062346330313663633363643434636464633530303435613738666137 | ||
66336130663130393432343937663132623138636433313530313536383538323531333031346431 | ||
32386534363538303562316566356232626635393163656662613662313466366661316266333066 | ||
66353433336433363630393832633338656666366262353236646662366635626235396233353666 | ||
62623437376566393465303962363632326130613930363338303862653837643137653337643961 | ||
33633234616165336362323261623636313939393133646339626637363034623437356362326461 | ||
64313939643163616263613534356336383138326466336664653339336165333062363365333930 | ||
31356637643963373538313239343863343235383336636239306136373864333534366238616137 | ||
32373733626331613263356639626461656632623637636530366633646539366237356161393866 | ||
34633262626537636239313038313534663530393635383832643161656435373832306566653934 | ||
34313166363330373633396333613037333363346630663531333062313735626665353566653037 | ||
37303937323630613537316361373431373166613132356539633639393364343834326562356638 | ||
38623135376435376331323938653234303332643132303533313035373830616365306263643362 | ||
38363033373831323637643637653863306138646233316535666165643965346339333662306337 | ||
33656232656663646262366333653838633565623138356664313930386464306364663863653963 | ||
64393938363364653764656432373963363666636339613865636635633434313530376337386335 | ||
35356262376536646665393535353939643535316131626437666136336562666334326533353632 | ||
61346531623237666232366636376232613539323130633330313534313839366334646239613739 | ||
61633636373034323139323939303263633861646263646139343566396362303465396662336564 | ||
66616431613964383133346634363731356531383535313438653233366338363436383432343365 | ||
33393030653263373964386231303561316136326231396130386335326235316630366662356138 | ||
62303836343034373134373436346136323030376535383136663462616433366332613562343539 | ||
32363035393261636365353662616438323635353439326561653439613165373534393139393139 | ||
33383762386539336434636532613731643634383931383730646439346437656431363663373132 | ||
37363165623831656630393561386632633466623239613439303339376634656231336561386266 | ||
38313834626538613033626333323762316662306631656564346232326637613532663733343665 | ||
65386137326363623238613637383464303232303333663462346264656666353832626437373761 | ||
62333764323333343631373061653433646161653831346633326434386566353666363930616536 | ||
36396637363138306163393262306138366537313233313166343837353335663462613861356266 | ||
30616164313235313561383030313362656265353936646261363861613239663863663230663430 | ||
37616466643738653035333063396536333663366462326436386433306233643938386538313331 | ||
31336238653331396661623630343363626364326637373631643931313938393161303661303663 | ||
38656465313338313665653631326639306165616330633735313836363463623262653461376639 | ||
32306463323163326639313239336134636531666431663533666562646339616434386631646436 | ||
36666432373132306266343230396436363435643032666166623561663438623235653132333631 | ||
38336637393033663961663933396135386332383364356135353030323033336438656337383637 | ||
61633662346233333634366435323261363238633362346436666465386534316631353633626263 | ||
66386635393036326665373634303963383364653536393664316438663032303165376330336430 | ||
39356166323538653534663566623638653538633838643666633731653663313062393764313965 | ||
39333833336165303361643136656231323731623163353865366364623663313132396262326431 | ||
31306534633834636334633964646635333366383066616665666337643435376236313937396261 | ||
3435 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
$ANSIBLE_VAULT;1.1;AES256 | ||
33393739333530396262376134396462616166653566333130303762373863333235363033313930 | ||
3261656534636363646638383830653736643239633661300a376161653464343531396163316539 | ||
35623566616330616631383164653638663737656661363062653731373535316331646661303061 | ||
3430663036326335650a353638646430353365303666636466343964616634663861373061363163 | ||
63353361343336313435653931383036313463383035663638393630373431636130303232313265 | ||
66333439343838383331626463353364616165393163363565336564303861373932623233323830 | ||
36613632653833636236633963393237366461653366653037636339663631386661633737343966 | ||
38646437333838633335336666393437323664646662653432653565663861363638396266663035 | ||
63343531343136613834306434353061643362343166313163613432346234363963393163333336 | ||
66636635303033633363643530613961373931366136353037363130316633623264633633326166 | ||
38663837633239376234366138353664363836333631373639376164323838666133623737343032 | ||
32626537396136383165353832363035656132333932393364356232663937363939313738366331 | ||
64363661623562396235396232316531313935613161633439643537383165306234333334373330 | ||
35313736353835616465623735306231373165313234666166626337343038666661383139383963 | ||
30623030313666316638373832363139656463626534393930383838373962366562613136363164 | ||
63663238323134353235343337363266613333373438613634323533333837343539306161346332 | ||
31623763343363643466356231323532613537333532336533666364306631646331656262376230 | ||
38326339313237366162356239343332663432313063663038303431373037326137643962656364 | ||
33373163346633636135643137366163333137356464343631653436633637393633333032396630 | ||
65303530366238653064663932376136646132313633623834393735663536663438613630396663 | ||
38393962633165343837396532356433326366356237343632303764333532386632376163616131 | ||
61383531333431383265626566626166396435323834343831316431393766323466616634343436 | ||
643835306435653464303963306133636639 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
# Variables specific to the staging environment | ||
richie_django_configuration: Staging | ||
|
||
# Activate APM | ||
ddtrace: true |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,16 @@ | |
templates: "{{ app | json_query('services[*].templates[]') | list }}" | ||
tags: deploy | ||
|
||
- name: Set OpenShift datadog objects to manage | ||
set_fact: | ||
images: "{{ templates | map('regex_search', '.*/is.yml.j2$') | select('string') | list }}" | ||
builds: "{{ templates | map('regex_search', '.*/bc.yml.j2$') | select('string') | list }}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Those objects should be generic (imagestreams and buidconfigs), not only related to datadog APM. Hence you should move them in the next bloc. |
||
when: ddtrace | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We always want to collect those objects not only when |
||
tags: | ||
- deploy | ||
- image | ||
- build | ||
|
||
- name: Set OpenShift objects to manage | ||
set_fact: | ||
deployments: "{{ templates | map('regex_search', '.*/dc.*\\.yml\\.j2$') | select('string') | list }}" | ||
|
@@ -19,6 +29,14 @@ | |
- job | ||
- route | ||
|
||
- name: Display OpenShift's build for this app | ||
debug: msg="{{ builds | to_nice_yaml}}" | ||
when: builds is defined | ||
when: ddtrace | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove this condition. |
||
tags: | ||
- deploy | ||
- build | ||
|
||
- name: Display OpenShift's deployments for this app | ||
debug: | ||
msg: "{{ deployments | to_nice_yaml}}" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,19 @@ | |
# - "absent": all objects are deleted | ||
# deployment_stamp: the stamp of the object we are going to create or delete | ||
|
||
- name: OpenShift datadog objects with deployment_stamp[{{ deployment_stamp }}] must be {{ deployment_state | default('present') }} | ||
openshift_raw: | ||
definition: "{{ lookup('template', item) | from_yaml }}" | ||
state: "{{ deployment_state | default('present') }}" | ||
with_items: | ||
- "{{ images }}" | ||
- "{{ builds }}" | ||
when: ddtrace | ||
tags: | ||
- deploy | ||
- image | ||
- build | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same idea here: you should create ISs and BCs as generic objects. This should not be datadog-specific. |
||
|
||
- name: OpenShift objects with deployment_stamp[{{ deployment_stamp }}] must be {{ deployment_state | default('present') }} | ||
openshift_raw: | ||
definition: "{{ lookup('template', item) | from_yaml }}" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO the
--prefix
is not required: we do not need to split our dependencies in different places.