Skip to content
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

✨(playbook) introduce static services #427

Merged
merged 2 commits into from
Feb 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,8 @@ Versioning](http://semver.org/spec/v2.0.0.html).
- `edxec`
- `edxapp`
- Handle `CronJob` object type
- Introduce static services to expose services to other apps with a fixed name
- Add a static service for the elasticsearch forum

### 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
referred to 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`) will target 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 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"
```
2 changes: 1 addition & 1 deletion apps/ashley/templates/services/nginx/route.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ spec:
targetPort: "{{ ashley_nginx_port }}-tcp"
to:
kind: Service
name: "ashley-nginx-{{ deployment_stamp }}"
name: "ashley-nginx-{{ prefix }}"
26 changes: 26 additions & 0 deletions apps/ashley/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: ashley
service: nginx
deployment_stamp: "{{ deployment_stamp }}"
service_prefix: "{{ prefix }}"
type: static-service
removable: "no"
name: "ashley-nginx-{{ prefix }}"
namespace: "{{ project_name }}"
spec:
ports:
- name: {{ ashley_nginx_port }}-tcp
port: {{ ashley_nginx_port }}
protocol: TCP
targetPort: {{ ashley_nginx_port }}
- name: "{{ ashley_nginx_healthcheck_port }}-tcp"
port: {{ ashley_nginx_healthcheck_port }}
protocol: TCP
targetPort: {{ ashley_nginx_healthcheck_port }}
selector:
app: ashley
deploymentconfig: "ashley-nginx-{{ deployment_stamp | default('undefined', true) }}"
type: ClusterIP
2 changes: 1 addition & 1 deletion apps/edxapp/templates/services/nginx/route_cms.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ spec:
targetPort: "{{ edxapp_nginx_cms_port }}-tcp"
to:
kind: Service
name: "edxapp-nginx-{{ deployment_stamp }}"
name: "edxapp-nginx-{{ prefix }}"
2 changes: 1 addition & 1 deletion apps/edxapp/templates/services/nginx/route_lms.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ spec:
targetPort: "{{ edxapp_nginx_lms_port }}-tcp"
to:
kind: Service
name: "edxapp-nginx-{{ deployment_stamp }}"
name: "edxapp-nginx-{{ prefix }}"
2 changes: 1 addition & 1 deletion apps/edxapp/templates/services/nginx/route_preview.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,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 @@ -26,4 +25,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
2 changes: 1 addition & 1 deletion apps/etherpad/templates/services/nginx/route.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ spec:
targetPort: "{{ etherpad_nginx_port }}-tcp"
to:
kind: Service
name: "etherpad-nginx-{{ deployment_stamp }}"
name: "etherpad-nginx-{{ prefix }}"
26 changes: 26 additions & 0 deletions apps/etherpad/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: etherpad
service: nginx
deployment_stamp: "{{ deployment_stamp }}"
service_prefix: "{{ prefix }}"
type: static-service
removable: "no"
name: "etherpad-nginx-{{ deployment_stamp }}"
namespace: "{{ project_name }}"
spec:
ports:
- name: {{ etherpad_nginx_port }}-tcp
port: {{ etherpad_nginx_port }}
protocol: TCP
targetPort: {{ etherpad_nginx_port }}
- name: "{{ etherpad_nginx_healthcheck_port }}-tcp"
port: {{ etherpad_nginx_healthcheck_port }}
protocol: TCP
targetPort: {{ etherpad_nginx_healthcheck_port }}
selector:
app: etherpad
deploymentconfig: "etherpad-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 @@ -26,4 +25,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
23 changes: 23 additions & 0 deletions apps/forum/templates/services/elasticsearch/static-svc.yml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
apiVersion: v1
kind: Service
metadata:
labels:
app: forum
service: elasticsearch
deployment_stamp: "{{ deployment_stamp }}"
service_prefix: "{{ prefix }}"
type: static-service
removable: "no"
# name of the service should be database host name in settings
name: "{{ forum_elasticsearch_host }}-{{ prefix }}"
namespace: "{{ project_name }}"
spec:
ports:
- name: {{ forum_elasticsearch_port }}-tcp
port: {{ forum_elasticsearch_port }}
protocol: TCP
targetPort: {{ forum_elasticsearch_port }}
selector:
app: forum
deploymentconfig: "forum-elasticsearch-{{ 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 @@ -23,4 +23,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) }}"
2 changes: 1 addition & 1 deletion apps/kibana/templates/services/nginx/route.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ spec:
targetPort: "{{ kibana_nginx_port }}-tcp"
to:
kind: Service
name: "kibana-nginx-{{ deployment_stamp }}"
name: "kibana-nginx-{{ prefix }}"
26 changes: 26 additions & 0 deletions apps/kibana/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: kibana
service: nginx
deployment_stamp: "{{ deployment_stamp }}"
service_prefix: "{{ prefix }}"
type: static-service
removable: "no"
name: "kibana-nginx-{{ deployment_stamp }}"
namespace: "{{ project_name }}"
spec:
ports:
- name: {{ kibana_nginx_port }}-tcp
port: {{ kibana_nginx_port }}
protocol: TCP
targetPort: {{ kibana_nginx_port }}
- name: "{{ kibana_nginx_healthcheck_port }}-tcp"
port: {{ kibana_nginx_healthcheck_port }}
protocol: TCP
targetPort: {{ kibana_nginx_healthcheck_port }}
selector:
app: kibana
deploymentconfig: "kibana-nginx-{{ deployment_stamp | default('undefined', true) }}"
type: ClusterIP
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:
{% if prefix in acme_enabled_route_prefix %}
Expand All @@ -25,4 +24,4 @@ spec:
targetPort: "{{ learninglocker_nginx_port }}-tcp"
to:
kind: Service
name: "learninglocker-nginx-{{ deployment_stamp }}"
name: "learninglocker-nginx-{{ prefix }}"
Loading