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 30, 2020
1 parent 7e05c31 commit 2bb2016
Show file tree
Hide file tree
Showing 38 changed files with 515 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
86 changes: 86 additions & 0 deletions Upgrade.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# Upgrade

All instructions to upgrade this project from one release to the next will be
documented in this file. Upgrades must be run sequentially, meaning you should
not skip minor/major releases while upgrading (fix releases can be skipped).

The format is inspired from [Keep a
Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).


## Unreleased

### Static services

This version introduces `Static services` and it is a breaking change in the
blue/green deployment process. The `switch` playbook is patching static services
instead of routes. And the `deployment_stamp` of the deployed stacks is no
longer stored in routes, but in static services instead.

In order to migrate to this new system, you have to apply the following upgrade
process. This will not cause any downtime, but it implies a redeployment of your
applications.

#### Upgrade Procedure

This procedure must be applied for every arnold application deployed.

The `current` stack of your application (before applying this procedure) will be
referenced as `BEFORE-UPGRADE-VERSION`.


##### 1. Upgrade your arnold version

##### 2. Execute the `create_services` ansible playbook :

```
bin/ansible-playbook create_services.yml -e "apps_filter=your-application"
```
It will create the static services required by your application. Each variant of these static services (`previous`, `current`, `next`) willtarget nothing after this step.

##### 3. Execute the `deploy` ansible playbook :

```
bin/deploy -e "apps_filter=your-application"
```

It will deploy your application and the `next` static services will target this
stack.

This step does not affect routes. So your `BEFORE-UPGRADE-VERSION` stays
unchanged and available via the `current` route. On the other hand, the `next`
stack you just deployed will not be reachable by any route.

##### 4. Execute the `switch` ansible playbook :

```
bin/switch -e "apps_filter=your-application"
```

The switch will be done at a the static services level. So, the stack you just
deployed will be considered as the `current` by static services and by the
ansible playbooks.

But again, this step does not affect routes. So your `BEFORE-UPGRADE-VERSION`
stack stays unchanged and available via the `current` route.

##### 5. Execute the `create_routes` playbook :

```
bin/ansible-playbook create_routes.yml -e "apps_filter=your-application"
```

This will patch the routes to target the corresponding static services. After
this step, your `BEFORE-UPGRADE-VERSION` will be unavailable and will be
replaced by the `current` stack you just deployed.


##### 6. Check and clean

Check that everything is OK and execute the `clean` playbook to remove
unreferenced stacks :

```
bin/clean -e "apps_filter=your-application"
```
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) }}"
Loading

0 comments on commit 2bb2016

Please sign in to comment.