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

EW-1025: Add new tsp sync cronjob. #5258

Merged
merged 19 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from 11 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
30 changes: 30 additions & 0 deletions ansible/roles/schulcloud-server-tspsync/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,33 @@
when: not WITH_TSP
tags:
- cronjob

- name: API TSP Sync CronJob
kubernetes.core.k8s:
kubeconfig: ~/.kube/config
namespace: "{{ NAMESPACE }}"
template: api-tsp-sync-cronjob.yml.j2
when: WITH_TSP
mkreuzkam-cap marked this conversation as resolved.
Show resolved Hide resolved
tags:
- cronjob

- name: remove API TSP Sync CronJob
kubernetes.core.k8s:
kubeconfig: ~/.kube/config
state: absent
api_version: batch/v1
kind: CronJob
namespace: "{{ NAMESPACE }}"
name: api-tsp-sync-cronjob
when: not WITH_TSP
mkreuzkam-cap marked this conversation as resolved.
Show resolved Hide resolved
tags:
- cronjob

- name: API TSP Sync CronJob ConfigMap
kubernetes.core.k8s:
kubeconfig: ~/.kube/config
namespace: "{{ NAMESPACE }}"
template: api-tsp-sync-cronjob-configmap.yml.j2
when: WITH_TSP
mkreuzkam-cap marked this conversation as resolved.
Show resolved Hide resolved
tags:
- configmap
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1
kind: ConfigMap
metadata:
namespace: {{ NAMESPACE }}
name: api-tsp-sync-cronjob-configmap
labels:
app: api-tsp-sync-cronjob
data:
NODE_OPTIONS: "--max-old-space-size=3072"
NEST_LOG_LEVEL: "info"
mkreuzkam-cap marked this conversation as resolved.
Show resolved Hide resolved
EXIT_ON_ERROR: "true"
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
apiVersion: batch/v1
kind: CronJob
metadata:
namespace: {{ NAMESPACE }}
labels:
app: api-tsp-sync-cronjob
app.kubernetes.io/part-of: schulcloud-verbund
app.kubernetes.io/version: {{ SCHULCLOUD_SERVER_IMAGE_TAG }}
app.kubernetes.io/name: api-tsp-sync-cronjob
app.kubernetes.io/component: tsp-sync
mkreuzkam-cap marked this conversation as resolved.
Show resolved Hide resolved
app.kubernetes.io/managed-by: ansible
git.branch: {{ SCHULCLOUD_SERVER_BRANCH_NAME }}
git.repo: {{ SCHULCLOUD_SERVER_REPO_NAME }}
name: api-tsp-sync-cronjob
spec:
concurrencyPolicy: Forbid
schedule: "{{ SERVER_TSP_SYNC_CRONJOB_SCHEDULE|default("9 3 * * *", true) }}"
mkreuzkam-cap marked this conversation as resolved.
Show resolved Hide resolved
jobTemplate:
metadata:
labels:
app: api-tsp-sync-cronjob
app.kubernetes.io/part-of: schulcloud-verbund
app.kubernetes.io/version: {{ SCHULCLOUD_SERVER_IMAGE_TAG }}
app.kubernetes.io/name: api-tsp-sync-cronjob
app.kubernetes.io/component: tsp-sync
mkreuzkam-cap marked this conversation as resolved.
Show resolved Hide resolved
app.kubernetes.io/managed-by: ansible
git.branch: {{ SCHULCLOUD_SERVER_BRANCH_NAME }}
git.repo: {{ SCHULCLOUD_SERVER_REPO_NAME }}
spec:
template:
spec:
securityContext:
runAsUser: 1000
runAsGroup: 1000
fsGroup: 1000
runAsNonRoot: true
containers:
- name: api-tsp-sync-cronjob
image: {{ SCHULCLOUD_SERVER_IMAGE }}:{{ SCHULCLOUD_SERVER_IMAGE_TAG }}
envFrom:
- configMapRef:
name: api-configmap
mkreuzkam-cap marked this conversation as resolved.
Show resolved Hide resolved
- configMapRef:
name: api-tsp-sync-cronjob-configmap
- secretRef:
name: api-secret
command: ['/bin/sh', '-c']
args: ['npm run nest:start:sync tsp']
resources:
limits:
cpu: {{ API_CPU_LIMITS|default("2000m", true) }}
memory: {{ API_MEMORY_LIMITS|default("2Gi", true) }}
requests:
cpu: {{ API_CPU_REQUESTS|default("100m", true) }}
memory: {{ API_MEMORY_REQUESTS|default("150Mi", true) }}
restartPolicy: OnFailure
{% if AFFINITY_ENABLE is defined and AFFINITY_ENABLE|bool %}
affinity:
podAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 20
podAffinityTerm:
labelSelector:
matchExpressions:
- key: app.kubernetes.io/part-of
operator: In
values:
- schulcloud-verbund
topologyKey: "kubernetes.io/hostname"
namespaceSelector: {}
- weight: 10
podAffinityTerm:
labelSelector:
matchExpressions:
- key: git.repo
operator: In
values:
- {{ SCHULCLOUD_SERVER_REPO_NAME }}
topologyKey: "kubernetes.io/hostname"
namespaceSelector: {}
- weight: 10
podAffinityTerm:
labelSelector:
matchExpressions:
- key: git.branch
operator: In
values:
- {{ SCHULCLOUD_SERVER_BRANCH_NAME }}
topologyKey: "kubernetes.io/hostname"
namespaceSelector: {}
- weight: 10
podAffinityTerm:
labelSelector:
matchExpressions:
- key: app.kubernetes.io/version
operator: In
values:
- {{ SCHULCLOUD_SERVER_IMAGE_TAG }}
topologyKey: "kubernetes.io/hostname"
namespaceSelector: {}
{% endif %}
metadata:
labels:
app: api-tsp-sync-cronjob
app.kubernetes.io/part-of: schulcloud-verbund
app.kubernetes.io/version: {{ SCHULCLOUD_SERVER_IMAGE_TAG }}
app.kubernetes.io/name: api-tsp-sync-cronjob
app.kubernetes.io/component: tsp-sync
app.kubernetes.io/managed-by: ansible
git.branch: {{ SCHULCLOUD_SERVER_BRANCH_NAME }}
git.repo: {{ SCHULCLOUD_SERVER_REPO_NAME }}
mkreuzkam-cap marked this conversation as resolved.
Show resolved Hide resolved
Loading