Skip to content

Commit 13a1675

Browse files
author
Alan Christie
committed
refactor: Rework object names and working ws connections
1 parent f7a2f84 commit 13a1675

File tree

10 files changed

+51
-34
lines changed

10 files changed

+51
-34
lines changed

README.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,21 @@ accidental commits as it's in the project's `.gitignore` file: -
8585
Then, when you have set your variables, identify your **KUBECONFIG** file,
8686
and run the playbook: -
8787

88-
export KUBECONFIG=<path-to-your-kubeconfig>
88+
export KUBECONFIG=~/k8s-config/nw-xch-dev.yaml
8989
ansible-playbook site.yaml -e @parameters.yaml
9090

9191
Once deployed the application's internal API will be behind the service
92-
`ess-internal-api` on port `8001`. The Account Server will be able to
93-
manage event streams via the URL `http://ess-internal-api:8001/event-stream/`.
92+
`ess-internal-api` on port `8081`, and available to any application running in the
93+
cluster. The Account Server will be able to manage event streams via the URL
94+
`http://ess-internal-api:8081/event-stream/`.
95+
96+
The external web-socket service will be available on the ingress host you've specified,
97+
as either a `ws://` or `wss://` service, depending on the ingress configuration. If
98+
the host is `example.com` you should be able to connect to unsecure web sockets using
99+
the URL `ws://example.com/event-stream/{uuid}`.
94100

95101
To update the running image (to deploy a new tagged version) just re-run the
96-
playbook with the a suitable value for `ess_image_tag`.
102+
playbook with a suitable value for `ess_image_tag`.
97103

98104
To remove the application run the playbook again, but set the `ess_state` variable
99105
to `absent`: -

ansible/roles/app/defaults/main.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ ess_pull_policy_always: IfNotPresent
3838
ess_shared_volume_volume_storageclass: ' '
3939

4040
# Pod resource requests and limits
41-
ess_api_cpu_request: 500m
42-
ess_api_cpu_limit: 1
43-
ess_api_mem_request: 1G
44-
ess_api_mem_limit: 1Gi
41+
ess_api_cpu_request: 100m
42+
ess_api_cpu_limit:
43+
ess_api_mem_request: 256Mi
44+
ess_api_mem_limit: 256Mi

ansible/roles/app/tasks/deploy.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
loop:
5454
- deployment
5555
- service-internal
56-
- service-public
56+
- service-ws
5757

5858
- name: Deploy ingress ({{ ess_namespace }})
5959
kubernetes.core.k8s:

ansible/roles/app/tasks/undeploy.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
state: absent
88
loop:
99
- ingress
10-
- service-public
10+
- service-ws
1111
- service-internal
1212
- deployment
1313
- pvc

ansible/roles/app/templates/deployment.yaml.j2

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@ metadata:
77
spec:
88
replicas: 1
99
strategy:
10-
type: RollingUpdate
11-
rollingUpdate:
12-
maxSurge: 1
13-
maxUnavailable: 0
10+
type: Recreate
1411
selector:
1512
matchLabels:
1613
name: ess
@@ -81,22 +78,24 @@ spec:
8178
# a roll-out will not occur if the tag has not changed.
8279
- name: CICD_TRIGGER_ID
8380
value: '{{ ansible_date_time.iso8601_micro }}'
81+
startupProbe:
82+
httpGet:
83+
path: /event-stream
84+
port: internal
85+
failureThreshold: 60
86+
periodSeconds: 5
8487
readinessProbe:
85-
tcpSocket:
86-
port: 8081
87-
initialDelaySeconds: 10
88-
timeoutSeconds: 3
89-
periodSeconds: 10
90-
successThreshold: 1
91-
failureThreshold: 10
88+
httpGet:
89+
path: /event-stream
90+
port: internal
91+
initialDelaySeconds: 5
92+
periodSeconds: 5
9293
livenessProbe:
93-
tcpSocket:
94-
port: 8081
95-
initialDelaySeconds: 20
96-
timeoutSeconds: 3
97-
periodSeconds: 10
98-
successThreshold: 1
99-
failureThreshold: 3
94+
httpGet:
95+
path: /event-stream
96+
port: internal
97+
initialDelaySeconds: 5
98+
periodSeconds: 5
10099
resources:
101100
requests:
102101
cpu: {{ ess_api_cpu_request }}

ansible/roles/app/templates/ingress.yaml.j2

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22
kind: Ingress
33
apiVersion: networking.k8s.io/v1
44
metadata:
5-
name: ess
5+
name: ess-ws
66
namespace: {{ ess_namespace }}
77
annotations:
8+
nginx.ingress.kubernetes.io/proxy-connect-timeout: "3600"
9+
nginx.ingress.kubernetes.io/proxy-send-timeout: "3600"
10+
nginx.ingress.kubernetes.io/proxy-read-timeout: "3600"
811
{% if ess_cert_issuer %}
912
cert-manager.io/cluster-issuer: "{{ ess_cert_manager_issuer_base|lower }}-{{ ess_cert_issuer|lower }}"
1013
{% endif %}
@@ -24,6 +27,6 @@ spec:
2427
pathType: Prefix
2528
backend:
2629
service:
27-
name: ess-public
30+
name: ess-ws
2831
port:
2932
name: ws

ansible/roles/app/templates/service-public.yaml.j2 renamed to ansible/roles/app/templates/service-ws.yaml.j2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
kind: Service
33
apiVersion: v1
44
metadata:
5-
name: ess-public
5+
name: ess-ws
66
namespace: {{ ess_namespace }}
77
labels:
8-
name: ess-public
8+
name: ess-ws
99
spec:
1010
selector:
1111
name: ess

ansible/roles/app/vars/main.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ ess_ingress_class: nginx
88
# and 'letsencrypt-nginx-production'
99
ess_cert_manager_issuer_base: letsencrypt-{{ ess_ingress_class }}
1010
# SSL certificate issuer?
11-
ess_cert_issuer: ''
11+
# One of 'production', 'staging' or blank (for no SSL).
12+
ess_cert_issuer:
1213

13-
ess_priority_class: ''
14+
ess_priority_class:
1415
ess_api_termination_grace_period_seconds: 30

simple_es_publisher.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
OperationEnum,
1717
)
1818

19+
if len(sys.argv) != 2:
20+
print("Usage: simple_es_publisher.py <routing-key>")
21+
sys.exit(1)
22+
1923
_ROUTING_KEY: str = sys.argv[1]
2024

2125
_AMPQ_EXCHANGE: str = "event-streams"

simple_es_subscriber.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88

99
from simple_websocket import AioClient, ConnectionClosed
1010

11+
if len(sys.argv) != 2:
12+
print("Usage: simple_es_subscriber.py <location>")
13+
sys.exit(1)
14+
1115
_LOCATION: str = sys.argv[1]
1216

1317

0 commit comments

Comments
 (0)