Skip to content

Commit

Permalink
kaniko pod antiaffinity
Browse files Browse the repository at this point in the history
  • Loading branch information
dsavchenko committed Aug 28, 2024
1 parent a1d40d6 commit 38ebbdd
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
10 changes: 8 additions & 2 deletions nb2workflow/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,10 @@ def build_with_kaniko(self,
build_timestamp: bool = False,
namespace: str = "oda-staging",
cleanup: bool = True,
nb2wversion=version(print_it=False)) -> dict:
nb2wversion=version(print_it=False),
kaniko_pod_antiaffinity=True,
dispatcher_app_label='oda-dispatcher',
frontend_app_label='frontend') -> dict:

#secret should be created beforehand https://github.com/GoogleContainerTools/kaniko#pushing-to-docker-hub

Expand All @@ -291,7 +294,10 @@ def build_with_kaniko(self,
suffix = suffix,
namespace = namespace,
no_push = no_push,
image = image
image = image,
kaniko_pod_antiaffinity = kaniko_pod_antiaffinity,
dispatcher_app_label = dispatcher_app_label,
frontend_app_label = frontend_app_label
))

tmpl = jenv.get_template('dockerfile_cm.yaml.jinja')
Expand Down
13 changes: 13 additions & 0 deletions nb2workflow/templates/buildjob.yaml.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,19 @@ spec:
ttlSecondsAfterFinished: 86400
template:
spec:
{% if kaniko_pod_antiaffinity %}
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: app.kubernetes.io/name
operator: In
values:
- {{ dispatcher_app_label }}
- {{ frontend_app_label }}
topologyKey: "kubernetes.io/hostname"
{% endif %}
containers:
- name: kaniko-build
image: gcr.io/kaniko-project/executor:v1.22.0
Expand Down

0 comments on commit 38ebbdd

Please sign in to comment.