Skip to content

Commit b65ecd0

Browse files
🐛 Fixes #472 Remove stateless kai resources when set to false (#533) (#539)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Ensured config always includes a proper models mapping and added a terminating newline to avoid parsing issues. * **Refactor** * Simplified deployment logic to use centralized state flags, reducing nested conditions and improving reliability of component provisioning. * **Chores** * Rendered database-related environment settings only when the corresponding service is enabled to prevent unnecessary configuration exposure. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: Jason Montleon <jmontleo@redhat.com> Signed-off-by: Cherry Picker <noreply@github.com> Signed-off-by: Jason Montleon <jmontleo@redhat.com> Signed-off-by: Cherry Picker <noreply@github.com> Co-authored-by: Jason Montleon <jmontleo@redhat.com>
1 parent 839e956 commit b65ecd0

File tree

3 files changed

+52
-51
lines changed

3 files changed

+52
-51
lines changed

roles/tackle/tasks/kai.yml

Lines changed: 47 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
---
2+
- name: Set Kai deployment state
3+
set_fact:
4+
kai_common_state: "{{ 'present' if (kai_solution_server_enabled | bool or kai_llm_proxy_enabled | bool) else 'absent' }}"
5+
kai_llm_proxy_state: "{{ 'present' if kai_llm_proxy_enabled | bool else 'absent' }}"
6+
kai_solution_server_state: "{{ 'present' if kai_solution_server_enabled | bool else 'absent' }}"
27

38
- name: Get API key secret
49
k8s_info:
@@ -10,7 +15,6 @@
1015

1116
- when: kai_llm_proxy_enabled|bool or kai_solution_server_enabled|bool
1217
block:
13-
1418
- name: Check if DB secret is defined
1519
k8s_info:
1620
api_version: v1
@@ -45,58 +49,53 @@
4549
pg_password: "{{ kai_db_secret_status.resources.0.data.POSTGRESQL_PASSWORD | b64decode }}"
4650
when: (kai_db_secret_status.resources|length) > 0
4751

48-
- name: Deploy KAI DB
49-
k8s:
50-
state: present
51-
template: kai/kai-db-deployment.yaml.j2
52-
53-
- name: Create KAI DB Service
54-
k8s:
55-
state: present
56-
template: kai/kai-db-service.yaml.j2
57-
5852
- name: Create KAI DB PersistentVolumeClaim
5953
k8s:
6054
state: present
6155
template: kai/kai-db-pvc.yaml.j2
6256

63-
64-
- name: Deploy LLM Proxy
65-
when: kai_llm_proxy_enabled | bool
66-
block:
67-
- name: Create LLM Proxy ConfigMap
68-
k8s:
69-
state: present
70-
template: kai/llm-proxy-configmap.yaml.j2
71-
72-
- name: Create LLM Proxy Deployment
73-
k8s:
74-
state: present
75-
template: kai/llm-proxy-deployment.yaml.j2
76-
77-
- name: Create LLM Proxy Service
78-
k8s:
79-
state: present
80-
template: kai/llm-proxy-service.yaml.j2
81-
82-
- name: Create LLM Proxy Client Configuration
83-
k8s:
84-
state: present
85-
template: kai/llm-proxy-client-configmap.yaml.j2
86-
87-
- name: Deploy Solution server
88-
when: kai_solution_server_enabled | bool
89-
block:
90-
- name: Create Kai API deployment
91-
k8s:
92-
state: present
93-
template: kai/kai-api-deployment.yaml.j2
94-
merge_type: merge
95-
96-
- name: Create KAI API Service
97-
k8s:
98-
state: present
99-
template: kai/kai-api-service.yaml.j2
57+
- name: Deploy KAI DB
58+
k8s:
59+
state: "{{ kai_common_state }}"
60+
template: kai/kai-db-deployment.yaml.j2
61+
62+
- name: Create KAI DB Service
63+
k8s:
64+
state: "{{ kai_common_state }}"
65+
template: kai/kai-db-service.yaml.j2
66+
67+
- name: Create LLM Proxy ConfigMap
68+
k8s:
69+
state: present
70+
template: kai/llm-proxy-configmap.yaml.j2
71+
when: kai_llm_proxy_enabled | bool
72+
73+
- name: Create LLM Proxy Deployment
74+
k8s:
75+
state: "{{ kai_llm_proxy_state }}"
76+
template: kai/llm-proxy-deployment.yaml.j2
77+
78+
- name: Create LLM Proxy Service
79+
k8s:
80+
state: "{{ kai_llm_proxy_state }}"
81+
template: kai/llm-proxy-service.yaml.j2
82+
83+
- name: Create LLM Proxy Client Configuration
84+
k8s:
85+
state: present
86+
template: kai/llm-proxy-client-configmap.yaml.j2
87+
when: kai_llm_proxy_enabled | bool
88+
89+
- name: Create Kai API deployment
90+
k8s:
91+
state: "{{ kai_solution_server_state }}"
92+
template: kai/kai-api-deployment.yaml.j2
93+
merge_type: merge
94+
95+
- name: Create KAI API Service
96+
k8s:
97+
state: "{{ kai_solution_server_state }}"
98+
template: kai/kai-api-service.yaml.j2
10099

101100
- name: Update Kai component status conditions
102101
when: ansible_operator_meta is defined

roles/tackle/templates/kai/kai-api-deployment.yaml.j2

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@ spec:
2424
value: /api
2525
- name: KAI_LLM_PARAMS
2626
value: '{{ kai_llm_params | to_json }}'
27+
{% if kai_solution_server_enabled|bool %}
2728
- name: KAI_DB_DSN
2829
value: 'postgresql+asyncpg://kai:{{ pg_password }}@{{ kai_database_address }}:5432/kai'
30+
{% endif %}
2931
{% if kai_api_key_secret_status.resources | length > 0 %}
3032
{% for (key, value) in kai_api_key_secret_status.resources.0.data.items() %}
3133
- name: {{ key }}

roles/tackle/templates/kai/llm-proxy-configmap.yaml.j2

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,14 @@ data:
8787
table_name: llm_proxy_conversations
8888
backend: sql_default
8989
registered_resources:
90-
models:
9190
{% if kai_llm_model %}
91+
models:
9292
- model_id: proxied-model
9393
provider_id: {{ kai_llm_proxy_provider_id }}
9494
model_type: llm
9595
provider_model_id: {{ kai_llm_model }}
9696
{% else %}
97-
[]
97+
models: []
9898
{% endif %}
9999
shields: []
100100
vector_dbs: []
@@ -118,4 +118,4 @@ data:
118118
audience: "{{ keycloak_api_audience }}"
119119
{% endif %}
120120
telemetry:
121-
enabled: false
121+
enabled: false

0 commit comments

Comments
 (0)