Skip to content

Commit

Permalink
✨(playbook) introduce static services
Browse files Browse the repository at this point in the history
Add support  for static services, with  fixed name, in addition  to the services
deployed with  a deployment stamp in  their name. It allows  applications inside
the cluster to use the services exposed by other applications, with a consistent
fqdn.

BREAKING  CHANGE :  blue/green related  tasks are  now updating  static services
instead of routes
  • Loading branch information
madmatah committed Jan 29, 2020
1 parent 7e05c31 commit 88bfac9
Show file tree
Hide file tree
Showing 37 changed files with 429 additions and 117 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Versioning](http://semver.org/spec/v2.0.0.html).
- `marsha`
- `edxec`
- `edxapp`
- Introduce static services to expose services to other apps with a fixed name

### Changed

Expand Down
3 changes: 1 addition & 2 deletions apps/edxapp/templates/services/nginx/route_cms.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ metadata:
customer: "{{ customer }}"
app: "edxapp"
service: "nginx"
version: "{{ edxapp_nginx_image_tag }}"
route_prefix: "{{ prefix }}"
route_target_service: "cms"
annotations:
Expand All @@ -25,4 +24,4 @@ spec:
targetPort: "{{ edxapp_nginx_cms_port }}-tcp"
to:
kind: Service
name: "edxapp-nginx-{{ deployment_stamp }}"
name: "edxapp-nginx-{{ prefix }}"
3 changes: 1 addition & 2 deletions apps/edxapp/templates/services/nginx/route_lms.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ metadata:
customer: "{{ customer }}"
app: "edxapp"
service: "nginx"
version: "{{ edxapp_nginx_image_tag }}"
route_prefix: "{{ prefix }}"
route_target_service: "lms"
annotations:
Expand All @@ -25,4 +24,4 @@ spec:
targetPort: "{{ edxapp_nginx_lms_port }}-tcp"
to:
kind: Service
name: "edxapp-nginx-{{ deployment_stamp }}"
name: "edxapp-nginx-{{ prefix }}"
3 changes: 1 addition & 2 deletions apps/edxapp/templates/services/nginx/route_preview.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ metadata:
customer: "{{ customer }}"
app: "edxapp"
service: "nginx"
version: "{{ edxapp_nginx_image_tag }}"
route_prefix: "{{ prefix }}"
route_target_service: "lms"
annotations:
Expand All @@ -25,4 +24,4 @@ spec:
targetPort: "{{ edxapp_nginx_lms_port }}-tcp"
to:
kind: Service
name: "edxapp-nginx-{{ deployment_stamp }}"
name: "edxapp-nginx-{{ prefix }}"
30 changes: 30 additions & 0 deletions apps/edxapp/templates/services/nginx/static-svc.yml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
apiVersion: v1
kind: Service
metadata:
labels:
app: edxapp
service: nginx
deployment_stamp: "{{ deployment_stamp }}"
service_prefix: "{{ prefix }}"
type: static-service
removable: "no"
name: "edxapp-nginx-{{ prefix }}"
namespace: "{{ project_name }}"
spec:
ports:
- name: "{{ edxapp_nginx_cms_port }}-tcp"
port: {{ edxapp_nginx_cms_port }}
protocol: TCP
targetPort: {{ edxapp_nginx_cms_port }}
- name: "{{ edxapp_nginx_lms_port }}-tcp"
port: {{ edxapp_nginx_lms_port }}
protocol: TCP
targetPort: {{ edxapp_nginx_lms_port }}
- name: "{{ edxapp_nginx_healthcheck_port }}-tcp"
port: {{ edxapp_nginx_healthcheck_port }}
protocol: TCP
targetPort: {{ edxapp_nginx_healthcheck_port }}
selector:
app: edxapp
deploymentconfig: "edxapp-nginx-{{ deployment_stamp | default('undefined', true) }}"
type: ClusterIP
3 changes: 1 addition & 2 deletions apps/edxec/templates/services/nginx/route.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ metadata:
customer: "{{ customer }}"
app: "edxec"
service: "nginx"
version: "{{ edxec_nginx_image_tag }}"
route_prefix: "{{ prefix }}"
route_target_service: "app"
annotations:
Expand All @@ -24,4 +23,4 @@ spec:
targetPort: "{{ edxec_nginx_port }}-tcp"
to:
kind: Service
name: "edxec-nginx-{{ deployment_stamp }}"
name: "edxec-nginx-{{ prefix }}"
26 changes: 26 additions & 0 deletions apps/edxec/templates/services/nginx/static-svc.yml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
apiVersion: v1
kind: Service
metadata:
labels:
app: edxec
service: nginx
deployment_stamp: "{{ deployment_stamp }}"
service_prefix: "{{ prefix }}"
type: static-service
removable: "no"
name: "edxec-nginx-{{ prefix }}"
namespace: "{{ project_name }}"
spec:
ports:
- name: {{ edxec_nginx_port }}-tcp
port: {{ edxec_nginx_port }}
protocol: TCP
targetPort: {{ edxec_nginx_port }}
- name: "{{ edxec_nginx_healthcheck_port }}-tcp"
port: {{ edxec_nginx_healthcheck_port }}
protocol: TCP
targetPort: {{ edxec_nginx_healthcheck_port }}
selector:
app: edxec
deploymentconfig: "edxec-nginx-{{ deployment_stamp | default('undefined', true) }}"
type: ClusterIP
3 changes: 1 addition & 2 deletions apps/forum/templates/services/app/route.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ metadata:
customer: "{{ customer }}"
app: "forum"
service: "app"
version: "{{ forum_image_tag }}"
route_prefix: "{{ prefix }}"
route_target_service: "app"
annotations:
Expand All @@ -24,4 +23,4 @@ spec:
targetPort: "{{ forum_port }}-tcp"
to:
kind: Service
name: "forum-app-{{ deployment_stamp }}"
name: "forum-app-{{ prefix }}"
22 changes: 22 additions & 0 deletions apps/forum/templates/services/app/static-svc.yml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: v1
kind: Service
metadata:
labels:
app: forum
service: forum
deployment_stamp: "{{ deployment_stamp }}"
service_prefix: "{{ prefix }}"
type: static-service
removable: "no"
name: "forum-app-{{ prefix }}"
namespace: "{{ project_name }}"
spec:
ports:
- name: "{{ forum_port }}-tcp"
port: {{ forum_port }}
protocol: TCP
targetPort: {{ forum_port }}
selector:
app: forum
deploymentconfig: "forum-app-{{ deployment_stamp | default('undefined', true) }}"
type: ClusterIP
2 changes: 1 addition & 1 deletion apps/hello/templates/services/app/route.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ spec:
targetPort: "{{ hello_app_port }}-tcp"
to:
kind: Service
name: "hello-app-{{ deployment_stamp }}"
name: "hello-app-{{ prefix }}"
20 changes: 20 additions & 0 deletions apps/hello/templates/services/app/static-svc.yml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: v1
kind: Service
metadata:
labels:
app: hello
deployment_stamp: "{{ deployment_stamp }}"
service_prefix: "{{ prefix }}"
type: static-service
removable: "no"
name: "hello-app-{{ prefix }}"
namespace: "{{ project_name }}"
spec:
ports:
- name: {{ hello_app_port }}-tcp
port: {{ hello_app_port }}
protocol: TCP
targetPort: {{ hello_app_port }}
type: ClusterIP
selector:
deploymentconfig: "hello-app-{{ deployment_stamp | default('undefined', true) }}"
3 changes: 1 addition & 2 deletions apps/learninglocker/templates/services/nginx/route.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ metadata:
customer: "{{ customer }}"
app: "learninglocker"
service: "nginx"
version: "{{ learninglocker_nginx_image_tag }}"
route_prefix: "{{ prefix }}"
annotations:
kubernetes.io/tls-acme: "true"
Expand All @@ -23,4 +22,4 @@ spec:
targetPort: "{{ learninglocker_nginx_port }}-tcp"
to:
kind: Service
name: "learninglocker-nginx-{{ deployment_stamp }}"
name: "learninglocker-nginx-{{ prefix }}"
26 changes: 26 additions & 0 deletions apps/learninglocker/templates/services/nginx/static-svc.yml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
apiVersion: v1
kind: Service
metadata:
labels:
app: learninglocker
service: nginx
deployment_stamp: "{{ deployment_stamp }}"
service_prefix: "{{ prefix }}"
type: static-service
removable: "no"
name: "learninglocker-nginx-{{ prefix }}"
namespace: "{{ project_name }}"
spec:
ports:
- name: "{{ learninglocker_nginx_port }}-tcp"
port: {{ learninglocker_nginx_port }}
protocol: TCP
targetPort: {{ learninglocker_nginx_port }}
- name: "{{ learninglocker_nginx_healthcheck_port }}-tcp"
port: {{ learninglocker_nginx_healthcheck_port }}
protocol: TCP
targetPort: {{ learninglocker_nginx_healthcheck_port }}
selector:
app: learninglocker
deploymentconfig: "learninglocker-nginx-{{ deployment_stamp | default('undefined', true) }}"
type: ClusterIP
3 changes: 1 addition & 2 deletions apps/marsha/templates/services/nginx/route.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ metadata:
customer: "{{ customer }}"
app: "marsha"
service: "nginx"
version: "{{ marsha_nginx_image_tag }}"
route_prefix: "{{ prefix }}"
route_target_service: "app"
annotations:
Expand All @@ -24,4 +23,4 @@ spec:
targetPort: "{{ marsha_nginx_port }}-tcp"
to:
kind: Service
name: "marsha-nginx-{{ deployment_stamp }}"
name: "marsha-nginx-{{ prefix }}"
26 changes: 26 additions & 0 deletions apps/marsha/templates/services/nginx/static-svc.yml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
apiVersion: v1
kind: Service
metadata:
labels:
app: marsha
service: nginx
deployment_stamp: "{{ deployment_stamp }}"
service_prefix: "{{ prefix }}"
type: static-service
removable: "no"
name: "marsha-nginx-{{ prefix }}"
namespace: "{{ project_name }}"
spec:
ports:
- name: {{ marsha_nginx_port }}-tcp
port: {{ marsha_nginx_port }}
protocol: TCP
targetPort: {{ marsha_nginx_port }}
- name: "{{ marsha_nginx_healthcheck_port }}-tcp"
port: {{ marsha_nginx_healthcheck_port }}
protocol: TCP
targetPort: {{ marsha_nginx_healthcheck_port }}
selector:
app: marsha
deploymentconfig: "marsha-nginx-{{ deployment_stamp | default('undefined', true) }}"
type: ClusterIP
3 changes: 1 addition & 2 deletions apps/richie/templates/services/nginx/route.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ metadata:
customer: "{{ customer }}"
app: "richie"
service: "nginx"
version: "{{ richie_nginx_image_tag }}"
route_prefix: "{{ prefix }}"
route_target_service: "app"
annotations:
Expand All @@ -24,4 +23,4 @@ spec:
targetPort: "{{ richie_nginx_port }}-tcp"
to:
kind: Service
name: "richie-nginx-{{ deployment_stamp }}"
name: "richie-nginx-{{ prefix }}"
26 changes: 26 additions & 0 deletions apps/richie/templates/services/nginx/static-svc.yml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
apiVersion: v1
kind: Service
metadata:
labels:
app: richie
service: nginx
service_prefix: "{{ prefix }}"
deployment_stamp: "{{ deployment_stamp }}"
type: static-service
removable: "no"
name: "richie-nginx-{{ prefix }}"
namespace: "{{ project_name }}"
spec:
ports:
- name: {{ richie_nginx_port }}-tcp
port: {{ richie_nginx_port }}
protocol: TCP
targetPort: {{ richie_nginx_port }}
- name: "{{ richie_nginx_healthcheck_port }}-tcp"
port: {{ richie_nginx_healthcheck_port }}
protocol: TCP
targetPort: {{ richie_nginx_healthcheck_port }}
type: ClusterIP
selector:
app: richie
deploymentconfig: "richie-nginx-{{ deployment_stamp | default('undefined', true) }}"
20 changes: 20 additions & 0 deletions create_services.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
- hosts: local
gather_facts: False

pre_tasks:
- import_tasks: tasks/check_configuration.yml

tasks:
- name: Display playbook name
debug: msg="==== Starting create_services playbook ===="
tags: deploy

- import_tasks: tasks/set_vars.yml

- include_tasks: tasks/run_tasks_for_apps.yml
vars:
tasks:
- get_objects_for_app
- create_static_services
tags:
- static_service
4 changes: 2 additions & 2 deletions delete_previous.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
vars:
tasks:
- get_objects_for_app
- deploy_get_stamp_from_route
- deploy_get_stamp_from_static_service
- delete_app
prefix: previous
tags:
- route
- static_service
- switch
8 changes: 4 additions & 4 deletions deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@
- config
- deploy

# Patch all next routes of all apps after deploy
# Patch all next static services of all apps after deploy
- include_tasks: tasks/run_tasks_for_apps.yml
vars:
prefix: "next"
tasks:
- get_objects_for_app
- deploy_get_stamp_from_route
- deploy_patch_route
- deploy_get_stamp_from_static_service
- deploy_patch_static_service
- delete_app
tags:
- route
- static_service
- deploy
Loading

0 comments on commit 88bfac9

Please sign in to comment.