Add OPA and Openshift AI
This commit is contained in:
143
roles/rhoai_maas/tasks/rhoai.yml
Normal file
143
roles/rhoai_maas/tasks/rhoai.yml
Normal file
@@ -0,0 +1,143 @@
|
||||
---
|
||||
- name: Wait for RHOAI CRDs
|
||||
kubernetes.core.k8s_info:
|
||||
api_version: apiextensions.k8s.io/v1
|
||||
kind: CustomResourceDefinition
|
||||
name: "{{ item }}"
|
||||
register: __rhoai_maas_crd
|
||||
until: >-
|
||||
__rhoai_maas_crd.resources | length > 0 and
|
||||
(__rhoai_maas_crd.resources[0].status.conditions | default([])
|
||||
| selectattr('type', 'equalto', 'Established') | selectattr('status', 'equalto', 'True') | list | length) > 0
|
||||
retries: "{{ __rhoai_maas_wait_retries }}"
|
||||
delay: 10
|
||||
loop:
|
||||
- dscinitializations.dscinitialization.opendatahub.io
|
||||
- datascienceclusters.datasciencecluster.opendatahub.io
|
||||
|
||||
- name: Configure DSCInitialization
|
||||
kubernetes.core.k8s:
|
||||
state: present
|
||||
definition:
|
||||
apiVersion: dscinitialization.opendatahub.io/v2
|
||||
kind: DSCInitialization
|
||||
metadata:
|
||||
name: default-dsci
|
||||
spec:
|
||||
applicationsNamespace: "{{ __rhoai_maas_apps_namespace }}"
|
||||
monitoring:
|
||||
managementState: Managed
|
||||
trustedCABundle:
|
||||
managementState: Managed
|
||||
customCABundle: ""
|
||||
register: __rhoai_maas_dsci_result
|
||||
# The operator webhook may not be serving yet right after the CSV succeeds
|
||||
until: __rhoai_maas_dsci_result is not failed
|
||||
retries: 30
|
||||
delay: 10
|
||||
|
||||
- name: Resolve DataScienceCluster components
|
||||
ansible.builtin.set_fact:
|
||||
__rhoai_maas_dsc_components: >-
|
||||
{{ dict(rhoai_maas_dsc_managed_components | product([{'managementState': 'Managed'}]))
|
||||
| combine(dict(rhoai_maas_dsc_removed_components | product([{'managementState': 'Removed'}])))
|
||||
| combine(__rhoai_maas_dsc_component_overrides, recursive=True) }}
|
||||
|
||||
- name: Configure DataScienceCluster
|
||||
kubernetes.core.k8s:
|
||||
state: present
|
||||
definition:
|
||||
apiVersion: datasciencecluster.opendatahub.io/v2
|
||||
kind: DataScienceCluster
|
||||
metadata:
|
||||
name: "{{ rhoai_maas_dsc_name }}"
|
||||
spec:
|
||||
components: "{{ __rhoai_maas_dsc_components }}"
|
||||
register: __rhoai_maas_dsc_result
|
||||
until: __rhoai_maas_dsc_result is not failed
|
||||
retries: 30
|
||||
delay: 10
|
||||
|
||||
# The API server silently prunes unknown fields, so a misspelled component
|
||||
# setting applies cleanly but leaves MaaS Removed and its CRDs never appear.
|
||||
- name: Verify MaaS is enabled in the DataScienceCluster
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- >-
|
||||
(__rhoai_maas_dsc_result.result.spec.components.aigateway.modelsAsAService.managementState
|
||||
| default('')) == 'Managed'
|
||||
fail_msg: >-
|
||||
DataScienceCluster {{ rhoai_maas_dsc_name }} does not have
|
||||
aigateway.modelsAsAService Managed after apply (field pruned or overridden):
|
||||
{{ __rhoai_maas_dsc_result.result.spec.components.aigateway | default({}) }}
|
||||
|
||||
- name: Wait for MaaS CRDs
|
||||
kubernetes.core.k8s_info:
|
||||
api_version: apiextensions.k8s.io/v1
|
||||
kind: CustomResourceDefinition
|
||||
name: "{{ item }}"
|
||||
register: __rhoai_maas_crd
|
||||
until: >-
|
||||
__rhoai_maas_crd.resources | length > 0 and
|
||||
(__rhoai_maas_crd.resources[0].status.conditions | default([])
|
||||
| selectattr('type', 'equalto', 'Established') | selectattr('status', 'equalto', 'True') | list | length) > 0
|
||||
retries: "{{ __rhoai_maas_wait_retries }}"
|
||||
delay: 10
|
||||
loop:
|
||||
- maasmodelrefs.maas.opendatahub.io
|
||||
- maasauthpolicies.maas.opendatahub.io
|
||||
- maassubscriptions.maas.opendatahub.io
|
||||
- externalproviders.inference.opendatahub.io
|
||||
- externalmodels.inference.opendatahub.io
|
||||
- odhdashboardconfigs.opendatahub.io
|
||||
|
||||
# The operator normally labels this itself; keep it as a safety net
|
||||
- name: Allow the MaaS infrastructure namespace to attach to the Gateway
|
||||
kubernetes.core.k8s:
|
||||
state: patched
|
||||
api_version: v1
|
||||
kind: Namespace
|
||||
name: "{{ rhoai_maas_infra_namespace }}"
|
||||
definition:
|
||||
metadata:
|
||||
labels:
|
||||
maas.opendatahub.io/gateway-access: "true"
|
||||
|
||||
- name: Wait for maas-api to be available
|
||||
kubernetes.core.k8s_info:
|
||||
api_version: apps/v1
|
||||
kind: Deployment
|
||||
namespace: "{{ rhoai_maas_infra_namespace }}"
|
||||
name: maas-api
|
||||
register: __rhoai_maas_api
|
||||
until: >-
|
||||
__rhoai_maas_api.resources | length > 0 and
|
||||
(__rhoai_maas_api.resources[0].status.availableReplicas | default(0)) >= 1
|
||||
retries: "{{ __rhoai_maas_wait_retries }}"
|
||||
delay: 10
|
||||
|
||||
- name: Wait for the dashboard config
|
||||
kubernetes.core.k8s_info:
|
||||
api_version: opendatahub.io/v1alpha
|
||||
kind: OdhDashboardConfig
|
||||
namespace: "{{ __rhoai_maas_apps_namespace }}"
|
||||
name: odh-dashboard-config
|
||||
register: __rhoai_maas_dashboard
|
||||
until: __rhoai_maas_dashboard.resources | length > 0
|
||||
retries: "{{ __rhoai_maas_wait_retries }}"
|
||||
delay: 10
|
||||
|
||||
- name: Enable MaaS and external models in the dashboard
|
||||
kubernetes.core.k8s:
|
||||
state: patched
|
||||
api_version: opendatahub.io/v1alpha
|
||||
kind: OdhDashboardConfig
|
||||
namespace: "{{ __rhoai_maas_apps_namespace }}"
|
||||
name: odh-dashboard-config
|
||||
merge_type: merge
|
||||
definition:
|
||||
spec:
|
||||
dashboardConfig:
|
||||
modelAsService: true
|
||||
externalModels: true
|
||||
genAiStudio: true
|
||||
Reference in New Issue
Block a user