Compare commits

...

2 commits

Author SHA1 Message Date
805217bcb6 hh 2026-07-20 17:09:19 +03:00
eebf9e6b6c refactor(vllm): restructure vllm role directory and add initial skeleton 2026-07-20 17:09:19 +03:00
7 changed files with 156 additions and 0 deletions

48
roles/vllm/README.md Normal file
View file

@ -0,0 +1,48 @@
# vLLM
Installs vLLM via Helm for GPU-enabled inference workloads.
## Requirements
- Kubernetes cluster with NVIDIA GPU workers
- NVIDIA device plugin deployed
- NGC API key for downloading models (stored in secret `vllm-ngc-secret`)
## Role Variables
| Variable | Default | Description |
|----------|---------|-------------|
| `vllm_chart_version` | `0.1.0` | vLLM Helm chart version |
| `vllm_namespace` | `vllm-system` | Kubernetes namespace |
| `vllm_num_replicas` | `2` | Number of replicas for HA |
| `vllm_image.repository` | `vllm/vllm-openai` | Container image repository |
| `vllm_image.tag` | `latest` | Container image tag |
| `vllm_image.pull_policy` | `IfNotPresent` | Image pull policy |
| `vllm_resources.limits.nvidia.com/gpu` | `1` | GPU limit per pod |
| `vllm_resources.requests.nvidia.com/gpu` | `1` | GPU request per pod |
| `vllm_env` | `[]` | Environment variables (e.g., NGC_API_KEY) |
| `vllm_extra_args` | `[]` | Additional CLI arguments |
| `vllm_kubeconfig` | `/home/{{ ansible_user }}/.kube/config` | Path to kubeconfig |
## Example Playbook
```yaml
- hosts: k8s_manager
become: false
roles:
- vllm
```
## Prerequisites
- Create secret with NGC API key:
```bash
kubectl create secret generic vllm-ngc-secret \
--from-literal=api-key=your-ngc-api-key \
-n vllm-system
```
- Ensure GPU workers are labeled:
```bash
kubectl label nodes <node> nvidia.com/gpu.present=true
```

View file

@ -0,0 +1,28 @@
---
vllm_chart_version: "0.1.0"
vllm_namespace: vllm-system
vllm_deployment_mode: "distributed"
vllm_num_replicas: 2
vllm_image:
repository: "vllm/vllm-openai"
tag: "latest"
pull_policy: "IfNotPresent"
vllm_resources:
limits:
nvidia.com/gpu: "1"
requests:
nvidia.com/gpu: "1"
vllm_env:
- name: "NGC_API_KEY"
valueFrom:
secretKeyRef:
name: "vllm-ngc-secret"
key: "api-key"
vllm_extra_args: []
vllm_kubeconfig: "/home/{{ ansible_user }}/.kube/config"

12
roles/vllm/meta/main.yml Normal file
View file

@ -0,0 +1,12 @@
---
galaxy_info:
role_name: vllm
author: ops
description: Installs vLLM via Helm for GPU-enabled inference workloads
license: MIT
min_ansible_version: "2.14"
platforms:
- name: EL
versions:
- "9"
dependencies: []

View file

@ -0,0 +1,36 @@
---
- name: Helm | Add vLLM chart repository
ansible.builtin.command: helm repo add vllm https://vllm-project.github.io/charts
environment:
KUBECONFIG: "{{ vllm_kubeconfig }}"
PATH: "/usr/local/bin:/usr/bin:/bin"
register: _helm_repo_add
changed_when: "'already exists' not in _helm_repo_add.stdout"
failed_when: _helm_repo_add.rc != 0 and 'already exists' not in _helm_repo_add.stdout
- name: Helm | Update chart repositories
ansible.builtin.command: helm repo update
environment:
KUBECONFIG: "{{ vllm_kubeconfig }}"
PATH: "/usr/local/bin:/usr/bin:/bin"
changed_when: false
- name: vLLM | Render values
ansible.builtin.template:
src: vllm-values.yml.j2
dest: /tmp/vllm-values.yml
mode: "0600"
- name: vLLM | Install or upgrade
ansible.builtin.command: >
helm upgrade --install vllm vllm/vllm
--namespace {{ vllm_namespace }}
--version {{ vllm_chart_version }}
--values /tmp/vllm-values.yml
--timeout 15m0s
--wait
environment:
KUBECONFIG: "{{ vllm_kubeconfig }}"
PATH: "/usr/local/bin:/usr/bin:/bin"
register: _helm_install
changed_when: "'STATUS: deployed' in _helm_install.stdout or 'has been upgraded' in _helm_install.stdout"

View file

@ -0,0 +1,6 @@
---
- name: Create vLLM namespace
ansible.builtin.include_tasks: namespace.yml
- name: Deploy vLLM via Helm
ansible.builtin.include_tasks: deploy.yml

View file

@ -0,0 +1,10 @@
---
- name: Create namespace
ansible.builtin.kubectl:
name: "{{ vllm_namespace }}"
api_version: "v1"
kind: "Namespace"
state: "present"
environment:
KUBECONFIG: "{{ vllm_kubeconfig }}"
PATH: "/usr/local/bin:/usr/bin:/bin"

View file

@ -0,0 +1,16 @@
replicaCount: {{ vllm_num_replicas }}
image:
repository: {{ vllm_image.repository }}
tag: {{ vllm_image.tag }}
pullPolicy: {{ vllm_image.pull_policy }}
resources:
limits:
nvidia.com/gpu: {{ vllm_resources.limits.nvidia.com/gpu | default('1') }}
requests:
nvidia.com/gpu: {{ vllm_resources.requests.nvidia.com/gpu | default('1') }}
env: {{ vllm_env | default([]) | to_json }}
extraArgs: {{ vllm_extra_args | default([]) | to_json }}