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

BC-7101 collaboration service deployment #4982

Merged
merged 21 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
50af77c
initial commit
hoeppner-dataport May 2, 2024
1f8d37f
fix shortened container port name
hoeppner-dataport May 2, 2024
9621cb6
add script to run board collaboration on prod
hoeppner-dataport May 2, 2024
c1f0ce5
chore
hoeppner-dataport May 3, 2024
0175083
chore: testwise chore origin configuration
hoeppner-dataport May 3, 2024
f0c2c09
fix frontend port in cors configuration
hoeppner-dataport May 3, 2024
c19ca33
chore: remove unused unimplemented handler
hoeppner-dataport May 6, 2024
6ee40ad
chore: improve naming
hoeppner-dataport May 6, 2024
cf0b85c
add configuration for board collaboration ws uri
hoeppner-dataport May 6, 2024
d2cd455
Merge branch 'main' of github.com:hpi-schul-cloud/schulcloud-server i…
hoeppner-dataport May 6, 2024
6b8ea38
Merge branch 'main' of github.com:hpi-schul-cloud/schulcloud-server i…
hoeppner-dataport May 6, 2024
e9ad572
fix indentation
hoeppner-dataport May 6, 2024
5d60347
fix quotation
hoeppner-dataport May 6, 2024
07cb39d
remove spacing correction
hoeppner-dataport May 6, 2024
ca831bd
fix: board collaboration uri default to work for localhost
hoeppner-dataport May 7, 2024
cdc58a1
Merge branch 'main' of github.com:hpi-schul-cloud/schulcloud-server i…
hoeppner-dataport May 7, 2024
9daef3d
fix config test
Metauriel May 7, 2024
ef634e7
chore: undo space character
hoeppner-dataport May 7, 2024
07a374f
Merge branch 'BC-7101-collaboration-service-deployment' of github.com…
hoeppner-dataport May 7, 2024
dc714cf
Merge branch 'main' of github.com:hpi-schul-cloud/schulcloud-server i…
hoeppner-dataport May 7, 2024
db2a808
add default for board collaboration uri
hoeppner-dataport May 7, 2024
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
30 changes: 29 additions & 1 deletion ansible/roles/schulcloud-server-core/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,6 @@
- KEDA_ENABLED is defined and KEDA_ENABLED|bool
- SCALED_PREVIEW_GENERATOR_ENABLED is defined and SCALED_PREVIEW_GENERATOR_ENABLED|bool


- name: admin api server deployment
kubernetes.core.k8s:
kubeconfig: ~/.kube/config
Expand Down Expand Up @@ -256,3 +255,32 @@
namespace: "{{ NAMESPACE }}"
template: tldraw-svc-monitor.yml.j2
when: WITH_TLDRAW is defined and WITH_TLDRAW|bool

- name: BoardCollaboration configmap
kubernetes.core.k8s:
kubeconfig: ~/.kube/config
namespace: "{{ NAMESPACE }}"
template: board-collaboration-configmap.yml.j2
state: "{{ 'present' if WITH_BOARD_COLLABORATION else 'absent'}}"

- name: BoardCollaboration deployment
kubernetes.core.k8s:
kubeconfig: ~/.kube/config
namespace: "{{ NAMESPACE }}"
template: board-collaboration-deployment.yml.j2
state: "{{ 'present' if WITH_BOARD_COLLABORATION else 'absent'}}"

- name: BoardCollaboration service
kubernetes.core.k8s:
kubeconfig: ~/.kube/config
namespace: "{{ NAMESPACE }}"
template: board-collaboration-service.yml.j2
state: "{{ 'present' if WITH_BOARD_COLLABORATION else 'absent'}}"

- name: BoardCollaboration ingress
kubernetes.core.k8s:
kubeconfig: ~/.kube/config
namespace: "{{ NAMESPACE }}"
template: board-collaboration-ingress.yml.j2
apply: yes
state: "{{ 'present' if WITH_BOARD_COLLABORATION else 'absent'}}"
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: board-collaboration-configmap
namespace: {{ NAMESPACE }}
labels:
app: board-collaboration
data:
NEST_LOG_LEVEL: "{{ NEST_LOG_LEVEL }}"
EXIT_ON_ERROR: "true"
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: board-collaboration-deployment
namespace: {{ NAMESPACE }}
labels:
app: board-collaboration
app.kubernetes.io/part-of: schulcloud-verbund
app.kubernetes.io/version: {{ SCHULCLOUD_SERVER_IMAGE_TAG }}
app.kubernetes.io/name: board-collaboration
app.kubernetes.io/component: server
app.kubernetes.io/managed-by: ansible
git.branch: {{ SCHULCLOUD_SERVER_BRANCH_NAME }}
git.repo: {{ SCHULCLOUD_SERVER_REPO_NAME }}
spec:
replicas: {{ BOARD_COLLABORATION_SERVER_REPLICAS|default("1", true) }}
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
#maxUnavailable: 1
revisionHistoryLimit: 4
paused: false
selector:
matchLabels:
app: board-collaboration
template:
metadata:
labels:
app: board-collaboration
app.kubernetes.io/part-of: schulcloud-verbund
app.kubernetes.io/version: {{ SCHULCLOUD_SERVER_IMAGE_TAG }}
app.kubernetes.io/name: board-collaboration
app.kubernetes.io/component: board-collaboration
app.kubernetes.io/managed-by: ansible
git.branch: {{ SCHULCLOUD_SERVER_BRANCH_NAME }}
git.repo: {{ SCHULCLOUD_SERVER_REPO_NAME }}
spec:
securityContext:
runAsUser: 1000
runAsGroup: 1000
fsGroup: 1000
runAsNonRoot: true
containers:
- name: board-collaboration
image: {{ SCHULCLOUD_SERVER_IMAGE }}:{{ SCHULCLOUD_SERVER_IMAGE_TAG }}
imagePullPolicy: IfNotPresent
ports:
- containerPort: 4450
name: websocket
protocol: TCP
# - containerPort: 9090
# name: api-metrics
# protocol: TCP
envFrom:
- configMapRef:
name: api-configmap
- configMapRef:
name: board-collaboration-configmap
- secretRef:
name: api-secret
command: ['npm', 'run', 'nest:start:board-collaboration:prod']
resources:
limits:
cpu: {{ BOARD_COLLABORATION_CPU_LIMITS|default("2000m", true) }}
memory: {{ BOARD_COLLABORATION_MEMORY_LIMITS|default("2Gi", true) }}
requests:
cpu: {{ BOARD_COLLABORATION_CPU_REQUESTS|default("100m", true) }}
memory: {{ BOARD_COLLABORATION_MEMORY_REQUESTS|default("150Mi", true) }}
{% if AFFINITY_ENABLE is defined and AFFINITY_ENABLE|bool %}
affinity:
podAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 9
podAffinityTerm:
labelSelector:
matchExpressions:
- key: app.kubernetes.io/part-of
operator: In
values:
- schulcloud-verbund
topologyKey: "kubernetes.io/hostname"
namespaceSelector: {}
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
{% if ANIT_AFFINITY_NODEPOOL_ENABLE is defined and ANIT_AFFINITY_NODEPOOL_ENABLE|bool %}
- weight: 10
podAffinityTerm:
labelSelector:
matchExpressions:
- key: app.kubernetes.io/name
operator: In
values:
- board-collaboration
topologyKey: {{ ANIT_AFFINITY_NODEPOOL_TOPOLOGY_KEY }}
{% endif %}
- weight: 20
podAffinityTerm:
labelSelector:
matchExpressions:
- key: app.kubernetes.io/name
operator: In
values:
- board-collaboration
topologyKey: "topology.kubernetes.io/zone"
{% endif %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: board-collaboration-ingress
namespace: {{ NAMESPACE }}
annotations:
nginx.ingress.kubernetes.io/proxy-send-timeout: "3600"
nginx.ingress.kubernetes.io/proxy-read-timeout: "3600"
nginx.ingress.kubernetes.io/proxy-body-size: "{{ INGRESS_MAX_BODY_SIZE|default("2560") }}m"
nginx.org/client-max-body-size: "{{ INGRESS_MAX_BODY_SIZE|default("2560") }}m"
# The following properties added with BC-3606.
# The header size of the request is too big. For e.g. state and the permanent growing jwt.
# Nginx throws away the Location header, resulting in the 502 Bad Gateway.
nginx.ingress.kubernetes.io/client-header-buffer-size: 100k
nginx.ingress.kubernetes.io/http2-max-header-size: 96k
nginx.ingress.kubernetes.io/large-client-header-buffers: 4 100k
nginx.ingress.kubernetes.io/proxy-buffer-size: 96k
nginx.org/websocket-services: "board-collaboration-svc"
{% if CLUSTER_ISSUER is defined %}
cert-manager.io/cluster-issuer: {{ CLUSTER_ISSUER }}
{% endif %}

spec:
ingressClassName: {{ INGRESS_CLASS }}
{% if CLUSTER_ISSUER is defined or (TLS_ENABLED is defined and TLS_ENABLED|bool) %}
tls:
- hosts:
- {{ DOMAIN }}
{% if CLUSTER_ISSUER is defined %}
secretName: {{ DOMAIN }}-tls
{% endif %}
{% endif %}
rules:
- host: {{ DOMAIN }}
http:
paths:
- path: /board-collaboration
backend:
service:
name: board-collaboration-svc
port:
number: 4450
pathType: Prefix
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: v1
kind: Service
metadata:
name: board-collaboration-svc
namespace: {{ NAMESPACE }}
labels:
app: board-collaboration
spec:
type: ClusterIP
ports:
# port for WebSocket connection
- port: 4450
targetPort: 4450
protocol: TCP
name: websocket
#- port: {{ PORT_METRICS_SERVER }}
# targetPort: 9090 # TODO
# protocol: TCP
# name: api-metrics
selector:
app: board-collaboration
2 changes: 1 addition & 1 deletion apps/server/src/apps/board-collaboration.app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ async function bootstrap() {
await nestApp.init();

const port = 4450;
const basePath = '/api/v3';
const basePath = '/board-collaboration';

nestApp.setGlobalPrefix(basePath);
await nestApp.listen(port);
Expand Down
4 changes: 2 additions & 2 deletions apps/server/src/modules/board/board-ws-api.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import { CourseRepo } from '@shared/repo';
import { LoggerModule } from '@src/core/logger';
import { AuthorizationModule } from '../authorization';
import { BoardModule } from './board.module';
import { SocketGateway } from './gateway/socket.gateway';
import { BoardCollaborationGateway } from './gateway/board-collaboration.gateway';
import { BoardUc, ColumnUc } from './uc';

@Module({
imports: [BoardModule, forwardRef(() => AuthorizationModule), LoggerModule],
providers: [SocketGateway, ColumnUc, BoardUc, CourseRepo],
providers: [BoardCollaborationGateway, ColumnUc, BoardUc, CourseRepo],
exports: [],
})
export class BoardWsApiModule {}
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import {
import { getSocketApiClient, waitForEvent } from '@shared/testing/test-socket-api-client';
import { Socket } from 'socket.io-client';
import { BoardCollaborationTestingModule } from '../../board-collaboration.testing.module';
import { SocketGateway } from '../socket.gateway';
import { BoardCollaborationGateway } from '../board-collaboration.gateway';

describe('SocketGateway', () => {
let gateway: SocketGateway;
describe(BoardCollaborationGateway.name, () => {
let ws: BoardCollaborationGateway;
let app: INestApplication;
let ioClient: Socket;
let em: EntityManager;
Expand All @@ -28,8 +28,8 @@ describe('SocketGateway', () => {
}).compile();
app = testingModule.createNestApplication();

em = app.get<EntityManager>(EntityManager);
gateway = app.get<SocketGateway>(SocketGateway);
em = app.get(EntityManager);
ws = app.get(BoardCollaborationGateway);

await app.listen(0);
});
Expand Down Expand Up @@ -65,7 +65,7 @@ describe('SocketGateway', () => {
};

it('should be defined', () => {
expect(gateway).toBeDefined();
expect(ws).toBeDefined();
});

describe('create card', () => {
Expand Down
Loading
Loading