Skip to content

Commit

Permalink
feat: Replace NATS Streaming with CloudEvents broker (#1082)
Browse files Browse the repository at this point in the history
Fixes #930.

- [x] pdcout: Subscriber
- [x] pdcout: Publisher
- [x] crcin: Publisher
- [x] crcin: Subscriber
- [x] Remove all traces of NATS / Stan.
- [x] Delete unused methods from `ParcelStore`.
- [x] Update docs.
- [x] Undo 59bfafd

BREAKING CHANGE: Use a CloudEvents-compatible broker instead of NATS.
  • Loading branch information
gnarea authored Oct 21, 2023
1 parent 0a82395 commit 2132538
Show file tree
Hide file tree
Showing 105 changed files with 2,412 additions and 3,256 deletions.
1 change: 0 additions & 1 deletion .github/scripts/port-forward.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ kubectl port-forward --address 127.0.0.1 svc/public-gateway-poweb 8080:8082 &
kubectl port-forward --address 127.0.0.1 svc/public-gateway-pohttp 8081:80 &
kubectl port-forward --address 127.0.0.1 svc/public-gateway-cogrpc 8082:8081 &
kubectl port-forward --address 127.0.0.1 svc/pong-pohttp 8083:80 &
kubectl port-forward --address 127.0.0.1 svc/nats 4222:4222 &
kubectl port-forward --address 127.0.0.1 svc/minio 9000:9000 &

# Check at least one of the ports:
Expand Down
16 changes: 5 additions & 11 deletions chart/dev-backing-services/Chart.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,11 @@ dependencies:
- name: mongodb
repository: https://charts.bitnami.com/bitnami
version: 12.1.20
- name: nats
repository: https://nats-io.github.io/k8s/helm/charts
version: 0.7.2
- name: stan
repository: https://nats-io.github.io/k8s/helm/charts
version: 0.7.2
- name: relaynet-pong
repository: https://h.cfcr.io/relaycorp/public
version: 3.0.37
- name: redis
repository: https://charts.bitnami.com/bitnami
version: 16.12.2
digest: sha256:7c2f79a8d9d07692e87b8812cdb92d010a06f2d523966c70236a22d91789b0b0
generated: "2022-08-19T17:01:14.652985945+01:00"
- name: relaynet-pong
repository: https://h.cfcr.io/relaycorp/public
version: 3.0.37
digest: sha256:3a6af898672e34c94198a98b7b46e849e606ee0fa084ae0675a8e81c02e8ef05
generated: "2023-10-21T11:39:00.465509372+01:00"
6 changes: 0 additions & 6 deletions chart/dev-backing-services/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@ dependencies:
- name: mongodb
version: 12.1.20
repository: https://charts.bitnami.com/bitnami
- name: nats
version: 0.7.2
repository: https://nats-io.github.io/k8s/helm/charts
- name: stan
version: 0.7.2
repository: https://nats-io.github.io/k8s/helm/charts
- name: redis
version: 16.12.2
repository: https://charts.bitnami.com/bitnami
Expand Down
13 changes: 0 additions & 13 deletions chart/dev-backing-services/values.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,6 @@ mongodb:
persistence:
enabled: false

nats:
nameOverride: nats
natsbox:
enabled: false

stan:
nameOverride: stan
stan:
nats:
url: nats://nats:4222
store:
type: memory

redis:
fullnameOverride: redis
auth:
Expand Down
2 changes: 0 additions & 2 deletions chart/templates/certrotator-cronjob.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,3 @@ spec:
name: {{ include "relaynet-internet-gateway.fullname" . }}-keystore
- secretRef:
name: {{ include "relaynet-internet-gateway.fullname" . }}-keystore
resources:
{{- toYaml .Values.crcQueue.resources | nindent 16 }}
5 changes: 2 additions & 3 deletions chart/templates/global-cm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ data:
LOG_ENV_NAME: {{ .Values.logging.envName }}
{{- end }}

NATS_SERVER_URL: {{ .Values.nats.serverUrl }}
NATS_CLUSTER_ID: {{ .Values.nats.clusterId }}

REDIS_URL: {{ .Values.redis.url }}

OBJECT_STORE_BACKEND: {{ .Values.objectStore.backend }}
Expand All @@ -31,3 +28,5 @@ data:
OBJECT_STORE_ACCESS_KEY_ID: {{ .Values.objectStore.accessKeyId }}
{{- end }}
OBJECT_STORE_TLS_ENABLED: '{{ .Values.objectStore.tlsEnabled }}'

CE_CHANNEL: {{ .Values.queueChannel }}
2 changes: 1 addition & 1 deletion chart/templates/global-secret.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
{{- include "relaynet-internet-gateway.labels" . | nindent 4 }}
type: Opaque
data:
MONGO_PASSWORD: {{ .Values.mongo.password | b64enc }}
MONGODB_PASSWORD: {{ .Values.mongo.password | b64enc }}

{{- if .Values.objectStore.secretKey }}
OBJECT_STORE_SECRET_KEY: {{ .Values.objectStore.secretKey | b64enc }}
Expand Down
6 changes: 3 additions & 3 deletions chart/templates/keygen-cm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ data:
LOG_ENV_NAME: {{ .Values.logging.envName }}
{{- end }}

MONGO_URI: {{ .Values.mongo.uri }}
MONGO_DB: {{ .Values.mongo.db }}
MONGO_USER: {{ .Values.mongo.user }}
MONGODB_URI: {{ .Values.mongo.uri }}
MONGODB_DB: {{ .Values.mongo.db }}
MONGODB_USER: {{ .Values.mongo.user }}

{{- include "relaynet-internet-gateway.keystoreNonSecretEnvVars" . | nindent 2 }}
2 changes: 1 addition & 1 deletion chart/templates/keygen-secret.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ metadata:
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
type: Opaque
data:
MONGO_PASSWORD: {{ .Values.mongo.password | b64enc }}
MONGODB_PASSWORD: {{ .Values.mongo.password | b64enc }}

{{- include "relaynet-internet-gateway.keystoreSecretEnvVars" . | nindent 2 }}
6 changes: 3 additions & 3 deletions chart/templates/mongo-cm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ metadata:
labels:
{{- include "relaynet-internet-gateway.labels" . | nindent 4 }}
data:
MONGO_URI: {{ .Values.mongo.uri }}
MONGO_DB: {{ .Values.mongo.db }}
MONGO_USER: {{ .Values.mongo.user }}
MONGODB_URI: {{ .Values.mongo.uri }}
MONGODB_DB: {{ .Values.mongo.db }}
MONGODB_USER: {{ .Values.mongo.user }}
63 changes: 0 additions & 63 deletions chart/templates/pdcout-deploy.yml

This file was deleted.

28 changes: 0 additions & 28 deletions chart/templates/pdcout-hpa.yaml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "relaynet-internet-gateway.fullname" . }}-crcin
name: {{ include "relaynet-internet-gateway.fullname" . }}-queue
labels:
{{- include "relaynet-internet-gateway.labels" (merge (dict "Component" "crcin") .) | nindent 4 }}
{{- include "relaynet-internet-gateway.labels" (merge (dict "Component" "queue") .) | nindent 4 }}
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.crcQueue.replicas }}
replicas: {{ .Values.queue.replicas }}
{{- end }}
selector:
matchLabels:
{{- include "relaynet-internet-gateway.selectorLabels" (merge (dict "Component" "crcin") .) | nindent 6 }}
{{- include "relaynet-internet-gateway.selectorLabels" (merge (dict "Component" "queue") .) | nindent 6 }}
template:
metadata:
annotations:
Expand All @@ -23,25 +23,27 @@ spec:
keystore-cm-digest: {{ include "relaynet-internet-gateway.resourceDigest" (merge (dict "fileName" "keystore-cm.yml") .) }}
keystore-secret-digest: {{ include "relaynet-internet-gateway.resourceDigest" (merge (dict "fileName" "keystore-secret.yml") .) }}
labels:
{{- include "relaynet-internet-gateway.selectorLabels" (merge (dict "Component" "crcin") .) | nindent 8 }}
{{- include "relaynet-internet-gateway.selectorLabels" (merge (dict "Component" "queue") .) | nindent 8 }}
spec:
serviceAccountName: {{ include "relaynet-internet-gateway.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
shareProcessNamespace: true
containers:
- name: crcin
- name: queue
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: {{ include "relaynet-internet-gateway.image" . }}
imagePullPolicy: IfNotPresent
args:
- build/main/bin/crc-queue-worker.js
- build/main/bin/queue-server.js
env:
- name: WORKER_ID
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: POHTTP_USE_TLS
value: {{ ternary "false" "true" .Values.tags.gwDev | quote }}
{{- if .Values.proxyRequestIdHeader }}
- name: REQUEST_ID_HEADER
value: {{ .Values.proxyRequestIdHeader | quote }}
{{- end }}
envFrom:
- configMapRef:
name: {{ include "relaynet-internet-gateway.fullname" . }}
Expand All @@ -53,13 +55,25 @@ spec:
name: {{ include "relaynet-internet-gateway.fullname" . }}-keystore
- secretRef:
name: {{ include "relaynet-internet-gateway.fullname" . }}-keystore
ports:
- name: queue
containerPort: 8080
protocol: TCP
livenessProbe:
httpGet:
path: /
port: queue
readinessProbe:
httpGet:
path: /
port: queue
resources:
{{- toYaml .Values.crcQueue.resources | nindent 12 }}
{{- toYaml .Values.queue.resources | nindent 12 }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.crcQueue.affinity }}
{{- with .Values.queue.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "relaynet-internet-gateway.fullname" . }}-crcin
name: {{ include "relaynet-internet-gateway.fullname" . }}-queue
labels:
{{- include "relaynet-internet-gateway.labels" (merge (dict "Component" "crcin") .) | nindent 4 }}
{{- include "relaynet-internet-gateway.labels" (merge (dict "Component" "queue") .) | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "relaynet-internet-gateway.fullname" . }}-crcin
name: {{ include "relaynet-internet-gateway.fullname" . }}-queue
minReplicas: {{ .Values.autoscaling.minReplicas }}
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
metrics:
Expand Down
19 changes: 19 additions & 0 deletions chart/templates/queue-svc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "relaynet-internet-gateway.fullname" . }}-queue
labels:
{{- include "relaynet-internet-gateway.labels" (merge (dict "Component" "queue") .) | nindent 4 }}
{{- with .Values.service.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
type: {{ .Values.service.type }}
ports:
- port: 80
targetPort: queue
protocol: TCP
name: http
selector:
{{- include "relaynet-internet-gateway.selectorLabels" (merge (dict "Component" "queue") .) | nindent 4 }}
8 changes: 2 additions & 6 deletions chart/values.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,15 @@ ingress:

internetAddress: gateway.tld

pdcQueue:
replicas: 2
# Skip the broker; post directly to the CloudEvents endpoint in development
queueChannel: http://public-gateway-queue

mongo:
uri: mongodb://mongodb
db: gw
user: root
password: letmein

nats:
serverUrl: nats://nats:4222
clusterId: stan

redis:
url: redis://redis-headless:6379

Expand Down
Loading

0 comments on commit 2132538

Please sign in to comment.