unip-controller/controller/templates/ml-component/ml-component-deployment.yaml
2025-04-15 20:56:15 +03:00

137 lines
4.8 KiB
YAML
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# ============================================================
# Система: Единая библиотека, Центр ИИ НИУ ВШЭ
# Модуль: MLComponent
# Авторы: Полежаев В.А., Хританков А.С.
# Дата создания: 2024 г.
# ============================================================
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ deployment_name }}
namespace: {{ namespace }}
spec:
replicas: 1
selector:
matchLabels:
app: ml-cmp-{{ name }}
template:
metadata:
labels:
app: ml-cmp-{{ name }}
spec:
containers:
- name: ml-cmp-{{ name }}
image: {{ image_name }}
imagePullPolicy: Always
command: ["/bin/bash"]
args:
- -c
- >-
{% if python_package_version %}
pip3 install "unip-mlcmp {{ python_package_version }}"
{% else %}
pip3 install unip-mlcmp
{% endif %}
{% if python_package_registry_credentials %}
--extra-index-url {{ python_package_registry_credentials }}
--trusted-host {{ python_package_registry_host }}
{% endif %}
&&
{% if file_exchange_copy %}
mkdir -p $(FILES_S3_COPY_INFERENCE_FILES_DIR) &&
{% endif %}
export PYTHONPATH=$PYTHONPATH:$(PYTHONPATH_EXTENSION) &&
export PATH=/home/user/.local/bin:$PATH &&
{% if download_model %}
python3 -m unip.mlcmp.download_model_s3 &&
{% endif %}
hypercorn $(MLCMP_PACKAGE_APP_NAME) -k trio -b 0.0.0.0:{{ container_port }}
{% if env %}
env:
{% for env_var in env %}
- name: {{ env_var['name'] }}
value: "{{ env_var['value'] }}"
{% endfor %}
{% endif %}
{% if env_from %}
envFrom:
{% for env_from_elem in env_from %}
- {{ env_from_elem['key'] }}:
{{ env_from_elem['body'] }}
{% endfor %}
{% endif %}
ports:
- containerPort: {{ container_port }}
{% if volume_mounts %}
volumeMounts:
{% for volume_mount in volume_mounts %}
- name: {{ volume_mount['volume_name'] }}
mountPath: {{ volume_mount['mount_path'] }}
{% if volume_mount['sub_path'] %}
subPath: {{ volume_mount['sub_path'] }}
{% endif %}
{% endfor %}
{% endif %}
{% if resource_limits or resource_requests %}
resources:
{% if resource_limits %}
limits:
{% if resource_limits.memory %}
memory: {{ resource_limits.memory }}
{% endif %}
{% if resource_limits.cpu %}
cpu: {{ resource_limits.cpu }}
{% endif %}
{% if resource_limits.gpu %}
nvidia.com/gpu: {{ resource_limits.gpu }}
{% endif %}
{% endif %}
{% if resource_requests %}
requests:
{% if resource_requests.memory is not none %}
memory: {{ resource_requests.memory }}
{% endif %}
{% if resource_requests.cpu is not none %}
cpu: {{ resource_requests.cpu }}
{% endif %}
{% if resource_requests.gpu %}
nvidia.com/gpu: {{ resource_requests.gpu }}
{% endif %}
{% endif %}
{% endif %}
{% if volumes %}
volumes:
{% for volume in volumes %}
- name: {{ volume['volume_name'] }}
persistentVolumeClaim:
claimName: {{ volume['pvc_name'] }}
{% endfor %}
{% endif %}
{% if image_registry_credentials_secret_name %}
imagePullSecrets:
- name: {{ image_registry_credentials_secret_name }}
{% endif %}
{% if tolerations %}
tolerations:
{% for tol in tolerations %}
- key: "{{ tol.key }}"
operator: "{{ tol.operator }}"
value: "{{ tol.value }}"
effect: "{{ tol.effect }}"
{% endfor %}
{% endif %}
{% if node_affinity %}
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
{% for e in node_affinity.expressions %}
- key: {{ e.key }}
operator: {{ e.operator }}
values:
{% for v in e.vals %}
- "{{ v }}"
{% endfor %}
{% endfor %}
{% endif %}