Skip to content

Commit a6811b9

Browse files
authored
Separate save and cosv services (#2908)
* save and cosv divide in gateway * added cosv deployment templates for helm chart * Update values.yaml * modified agent service templates
1 parent 6656348 commit a6811b9

15 files changed

Lines changed: 300 additions & 1 deletion

api-gateway/src/main/resources/application-dev.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,23 @@
11
gateway:
22
backend:
33
url: http://localhost:5800
4+
backend-cosv:
5+
url: http://localhost:5700
46
frontend:
57
# In the "dev" environment, the front-end uses TCP port 8080 when run using `webpack-dev-server` (i.e. `browserDevelopmentRun` or `run` Gradle task).
68
url: http://localhost:8080
9+
frontend-cosv:
10+
# In the "dev" environment, the frontend-cosv uses TCP port 8081 when run using `webpack-dev-server` (i.e. `browserDevelopmentRun` or `run` Gradle task).
11+
url: http://localhost:8081
712
demo:
813
url: http://localhost:5421
914
demo-cpg:
1015
url: http://localhost:5500
16+
# for local test add additional lines in hosts file in your OS
17+
# then you can access application using <domain>:5300
18+
hosts:
19+
save: save.local.test
20+
cosv: cosv.local.test
1121
spring:
1222
security:
1323
oauth2:

api-gateway/src/main/resources/application.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,12 @@ server:
55
gateway:
66
backend:
77
url: http://backend:5800
8+
backend-cosv:
9+
url: http://backend-cosv:5700
810
frontend:
911
url: http://frontend:5810
12+
frontend-cosv:
13+
url: http://frontend-cosv:5820
1014
demo:
1115
url: http://demo:5421
1216
demo-cpg:
@@ -43,6 +47,16 @@ spring:
4347
- id: api_route
4448
uri: ${gateway.backend.url}
4549
predicates:
50+
- Host=**.${hosts.save}:5300
51+
- Path=/api/**
52+
filters:
53+
# If SESSION cookie is passed to downstream, it is then removed, because downstream discards it
54+
- RemoveRequestHeader=Cookie
55+
- AuthorizationHeaders=
56+
- id: cosv_api_route
57+
uri: ${gateway.backend-cosv.url}
58+
predicates:
59+
- Host=**.${hosts.cosv}:5300
4660
- Path=/api/**
4761
filters:
4862
# If SESSION cookie is passed to downstream, it is then removed, because downstream discards it
@@ -57,13 +71,31 @@ spring:
5771
- id: resource_route
5872
uri: ${gateway.frontend.url}
5973
predicates:
74+
- Host=**.${hosts.save}:5300
6075
- Path=/*.html,/*.js*,/*.css,/img/**,/*.ico,/*.png
6176
filters:
6277
# If SESSION cookie is passed to downstream, it is then removed, because downstream discards it
6378
- RemoveRequestHeader=Cookie
6479
- id: index_route
6580
uri: ${gateway.frontend.url}/index.html
6681
predicates:
82+
- Host=**.${hosts.save}:5300
83+
- Path=/**
84+
filters:
85+
# If SESSION cookie is passed to downstream, it is then removed, because downstream discards it
86+
- RemoveRequestHeader=Cookie
87+
- id: resource_route_cosv
88+
uri: ${gateway.frontend-cosv.url}
89+
predicates:
90+
- Host=**.${hosts.cosv}:5300
91+
- Path=/*.html,/*.js*,/*.css,/img/**,/*.ico,/*.png
92+
filters:
93+
# If SESSION cookie is passed to downstream, it is then removed, because downstream discards it
94+
- RemoveRequestHeader=Cookie
95+
- id: index_route_cosv
96+
uri: ${gateway.frontend-cosv.url}/index.html
97+
predicates:
98+
- Host=**.${hosts.cosv}:5300
6799
- Path=/**
68100
filters:
69101
# If SESSION cookie is passed to downstream, it is then removed, because downstream discards it
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{{ if .Values.agentNamespace }}
2+
3+
apiVersion: v1
4+
kind: Service
5+
metadata:
6+
name: {{ .Values.backend_cosv.name }}
7+
namespace: {{ .Values.agentNamespace }}
8+
spec:
9+
type: ExternalName
10+
externalName: {{ .Values.backend_cosv.name }}.{{ .Values.namespace }}.svc.cluster.local
11+
ports:
12+
- port: {{ .Values.backend_cosv.containerPort }}
13+
14+
{{ end }}

save-cloud-charts/save-cloud/templates/agent-network-policy-general.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ spec:
1515
cidr: 0.0.0.0/0
1616
# Forbid private IP ranges effectively allowing only egress to the Internet
1717
except:
18+
# - 12.0.0.0/8
1819
- 10.0.0.0/8
1920
- 172.16.0.0/12
2021
- 192.168.0.0/16

save-cloud-charts/save-cloud/templates/agent-network-policy-orchestrator.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,14 @@ spec:
3535
ports:
3636
- protocol: TCP
3737
port: {{ .Values.backend.containerPort }}
38+
- to:
39+
# Allow traffic to save-backend-cosv
40+
- namespaceSelector:
41+
matchLabels:
42+
name: {{ .Values.namespace }}
43+
- podSelector:
44+
matchLabels:
45+
io.kompose.service: backend-cosv
46+
ports:
47+
- protocol: TCP
48+
port: {{ .Values.backend_cosv.containerPort }}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: {{ .Values.backend_cosv.name }}-config
5+
data:
6+
application.properties: |
7+
backend.preprocessor-url=http://preprocessor
8+
backend.orchestrator-url=http://orchestrator
9+
backend.demo-url=http://demo
10+
backend.loki.url=http://loki:3100
11+
backend.loki.labels.agent-container-name=pod
12+
backend.loki.labels.application-name=app
13+
backend.agent-settings.backend-url=http://{{ .Values.backend_cosv.name }}
14+
server.shutdown=graceful
15+
management.endpoints.web.exposure.include=*
16+
management.server.port={{ .Values.backend_cosv.managementPort }}
17+
spring.datasource.url=${spring.datasource.backend-cosv-url}
18+
logging.level.org.springframework=DEBUG
19+
logging.level.com.saveourtool=DEBUG
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: backend-cosv
5+
labels:
6+
{{- include "common.labels" (merge (dict "service" .Values.backend_cosv) .) | nindent 4 }}
7+
spec:
8+
selector:
9+
matchLabels:
10+
io.kompose.service: backend-cosv
11+
strategy:
12+
# Because of shared volume with multi-attach problem
13+
type: Recreate
14+
template:
15+
metadata:
16+
labels:
17+
{{- include "pod.common.labels" (merge (dict "service" .Values.backend_cosv ) .) | nindent 8 }}
18+
annotations:
19+
{{- include "pod.common.annotations" (dict "service" .Values.backend_cosv ) | nindent 8 }}
20+
spec:
21+
restartPolicy: Always
22+
{{- include "cnb.securityContext" . | nindent 6 }}
23+
containers:
24+
- name: backend-cosv
25+
{{- include "spring-boot.common" (merge (dict "service" .Values.backend_cosv) .) | nindent 10 }}
26+
env:
27+
{{- include "spring-boot.common.env" (merge (dict "service" .Values.backend_cosv) .) | nindent 12 }}
28+
- name: DATABASE_SECRETS_PATH
29+
value: {{ .Values.mysql.dbPasswordFile }}
30+
- name: S3_SECRETS_PATH
31+
value: {{ .Values.s3.secretFile }}
32+
- name: JAVA_TOOL_OPTIONS
33+
value: -XX:ReservedCodeCacheSize=48M
34+
volumeMounts:
35+
- {{ include "spring-boot.config-volume-mount" . | indent 14 | trim }}
36+
- name: database-secret
37+
mountPath: {{ .Values.mysql.dbPasswordFile }}
38+
- name: s3-secrets
39+
mountPath: {{ .Values.s3.secretFile }}
40+
{{- include "spring-boot.management" .Values.backend_cosv | nindent 10 }}
41+
resources:
42+
limits:
43+
memory: 2G
44+
requests:
45+
memory: 1G
46+
{{ if .Values.mysql.migrations.enabled }}
47+
initContainers:
48+
- name: git-cloner
49+
image: alpine/git
50+
env:
51+
{{ if .Values.proxy.enabled }}
52+
{{- with .Values.proxy.extraEnv }}
53+
{{- toYaml . | nindent 12 }}
54+
{{- end }}
55+
{{ end }}
56+
args:
57+
- clone
58+
- --progress
59+
- --verbose
60+
{{ if .Values.proxy.enabled }}
61+
{{- with .Values.proxy.extraArgs }}
62+
{{- toYaml . | nindent 12 }}
63+
{{- end }}
64+
{{ end }}
65+
- --single-branch
66+
- --branch
67+
- {{ .Values.mysql.migrations.branch | default "master" }}
68+
- --
69+
- https://github.com/saveourtool/save-cloud.git
70+
- /data
71+
volumeMounts:
72+
- mountPath: /data
73+
name: migrations-data
74+
- name: liquibase-runner
75+
image: liquibase/liquibase:4.20
76+
securityContext:
77+
runAsUser: 1001
78+
runAsGroup: 1001
79+
args:
80+
- --url=$(DB_URL)?createDatabaseIfNotExist=true
81+
- --changeLogFile=db/db.changelog-master.xml
82+
- --username=$(DB_USERNAME)
83+
- --password=$(DB_PASSWORD)
84+
- --log-level=info
85+
- --contexts={{ .Values.profile }}
86+
- update
87+
resources:
88+
requests:
89+
memory: 100M
90+
limits:
91+
memory: 300M
92+
env:
93+
# See https://hub.docker.com/r/liquibase/liquibase, section 'Notice for MySQL Users'
94+
- name: INSTALL_MYSQL
95+
value: 'true'
96+
- name: DB_URL
97+
valueFrom:
98+
secretKeyRef:
99+
name: db-secrets
100+
key: spring.datasource.backend-url
101+
- name: DB_USERNAME
102+
valueFrom:
103+
secretKeyRef:
104+
name: db-secrets
105+
key: spring.datasource.username
106+
- name: DB_PASSWORD
107+
valueFrom:
108+
secretKeyRef:
109+
name: db-secrets
110+
key: spring.datasource.password
111+
{{ if .Values.proxy.enabled }}
112+
{{- with .Values.proxy.extraEnv }}
113+
{{- toYaml . | nindent 12 }}
114+
{{- end }}
115+
{{ end }}
116+
volumeMounts:
117+
- mountPath: /liquibase/changelog
118+
name: migrations-data
119+
- mountPath: {{ .Values.mysql.dbPasswordFile }}
120+
name: database-secret
121+
- mountPath: /etc/ssl/certs/ca-certificates.crt
122+
name: ca-certs
123+
subPath: cert-check.crt
124+
readOnly: false
125+
{{ end }}
126+
volumes:
127+
- {{ include "spring-boot.config-volume" (dict "service" .Values.backend_cosv) | indent 10 | trim }}
128+
- name: database-secret
129+
secret:
130+
secretName: db-secrets
131+
- name: s3-secrets
132+
secret:
133+
secretName: s3-secrets
134+
- name: migrations-data
135+
emptyDir: {}
136+
- name: ca-certs
137+
configMap:
138+
name: ca-certs
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
{{- include "service.common.metadata" (dict "service" .Values.backend_cosv) | nindent 2 }}
5+
spec:
6+
{{ if .Values.backend_cosv.clusterIP }}
7+
clusterIP: {{ .Values.backend_cosv.clusterIP }}
8+
{{ end }}
9+
ports:
10+
{{- include "service.common.ports" (dict "service" .Values.backend_cosv) | nindent 4 }}
11+
selector:
12+
{{- include "service.common.selectors" (dict "service" .Values.backend_cosv) | nindent 4 }}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: frontend-cosv
5+
labels:
6+
{{- include "common.labels" (merge (dict "service" .Values.frontend_cosv) .) | nindent 4 }}
7+
spec:
8+
selector:
9+
matchLabels:
10+
io.kompose.service: frontend-cosv
11+
strategy:
12+
type: RollingUpdate
13+
template:
14+
metadata:
15+
labels:
16+
{{- include "pod.common.labels" (merge (dict "service" .Values.frontend_cosv ) .) | nindent 8 }}
17+
spec:
18+
restartPolicy: Always
19+
{{- include "cnb.securityContext" . | nindent 6 }}
20+
containers:
21+
- name: frontend-cosv
22+
{{- include "spring-boot.common" (merge (dict "service" .Values.frontend_cosv) .) | nindent 10 }}
23+
env:
24+
- name: PORT
25+
value: '{{ .Values.frontend_cosv.containerPort | toString }}'
26+
resources:
27+
limits:
28+
memory: 200M
29+
requests:
30+
memory: 100M
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
{{- include "service.common.metadata" (dict "service" .Values.frontend_cosv) | nindent 2 }}
5+
spec:
6+
ports:
7+
{{- include "service.common.ports" (dict "service" .Values.frontend_cosv) | nindent 4 }}
8+
selector:
9+
{{- include "service.common.selectors" (dict "service" .Values.frontend_cosv) | nindent 4 }}

0 commit comments

Comments
 (0)