|
| 1 | +# Installing on Kubernetes |
| 2 | + |
| 3 | +## Using pre-built operator image |
| 4 | + |
| 5 | +This operator is available as an [image on Quay.io](https://quay.io/repository/trustyai/trustyai-service-operator?tab=history). |
| 6 | +To deploy it on your cluster: |
| 7 | + |
| 8 | +1. **Install the Custom Resource Definition (CRD):** |
| 9 | + |
| 10 | + Apply the CRD to your cluster (replace the URL with the relevant one, if using another repository): |
| 11 | + |
| 12 | + ```bash |
| 13 | + kubectl apply -f https://raw.githubusercontent.com/trustyai-explainability/trustyai-service-operator/main/config/crd/bases/trustyai.opendatahub.io.trustyai.opendatahub.io_trustyaiservices.yaml |
| 14 | + ``` |
| 15 | + |
| 16 | +2. **Deploy the Operator:** |
| 17 | + |
| 18 | + Apply the following Kubernetes manifest to deploy the operator: |
| 19 | + |
| 20 | + ```yaml |
| 21 | + apiVersion: apps/v1 |
| 22 | + kind: Deployment |
| 23 | + metadata: |
| 24 | + name: trustyai-operator |
| 25 | + namespace: trustyai-operator-system |
| 26 | + spec: |
| 27 | + replicas: 1 |
| 28 | + selector: |
| 29 | + matchLabels: |
| 30 | + control-plane: trustyai-operator |
| 31 | + template: |
| 32 | + metadata: |
| 33 | + labels: |
| 34 | + control-plane: trustyai-operator |
| 35 | + spec: |
| 36 | + containers: |
| 37 | + - name: trustyai-operator |
| 38 | + image: quay.io/trustyai/trustyai-service-operator:latest |
| 39 | + command: |
| 40 | + - /manager |
| 41 | + resources: |
| 42 | + limits: |
| 43 | + cpu: 100m |
| 44 | + memory: 30Mi |
| 45 | + requests: |
| 46 | + cpu: 100m |
| 47 | + memory: 20Mi |
| 48 | + ``` |
| 49 | + |
| 50 | + or run |
| 51 | + |
| 52 | + ```shell |
| 53 | + kubectl apply -f https://raw.githubusercontent.com/trustyai-explainability/trustyai-service-operator/main/artifacts/examples/deploy-operator.yaml |
| 54 | + ``` |
| 55 | + |
| 56 | +## Usage |
| 57 | + |
| 58 | +Once the operator is installed, you can create `TrustyAIService` resources, and the operator will create corresponding TrustyAI deployments, services, and (on OpenShift) routes. |
| 59 | + |
| 60 | +Here's an example `TrustyAIService` manifest: |
| 61 | +
|
| 62 | +```yaml |
| 63 | +apiVersion: trustyai.opendatahub.io.trusty.opendatahub.io/v1 |
| 64 | +kind: TrustyAIService |
| 65 | +metadata: |
| 66 | + name: trustyai-service-example |
| 67 | +spec: |
| 68 | + storage: |
| 69 | + format: "PVC" |
| 70 | + folder: "/inputs" |
| 71 | + size: "1Gi" |
| 72 | + data: |
| 73 | + filename: "data.csv" |
| 74 | + format: "CSV" |
| 75 | + metrics: |
| 76 | + schedule: "5s" |
| 77 | + batchSize: 5000 # Optional, defaults to 5000 |
| 78 | +``` |
| 79 | +
|
| 80 | +You can apply this manifest with |
| 81 | +
|
| 82 | +```shell |
| 83 | +kubectl apply -f <file-name.yaml> -n $NAMESPACE |
| 84 | +``` |
| 85 | +to create a service, where `$NAMESPACE` is the namespace where you want to deploy it. |
| 86 | +
|
| 87 | +
|
| 88 | +Additionally, in that namespace: |
| 89 | +
|
| 90 | +* a `ServiceMonitor` will be created to allow Prometheus to scrape metrics from the service. |
| 91 | +* (if on OpenShift) a `Route` will be created to allow external access to the service. |
| 92 | +
|
| 93 | +### Custom Image Configuration using ConfigMap |
| 94 | +You can specify a custom TrustyAI-service image via adding parameters to the TrustyAI-Operator KFDef, for example: |
| 95 | +
|
| 96 | +```yaml |
| 97 | +apiVersion: kfdef.apps.kubeflow.org/v1 |
| 98 | +kind: KfDef |
| 99 | +metadata: |
| 100 | + name: trustyai-service-operator |
| 101 | + namespace: opendatahub |
| 102 | +spec: |
| 103 | + applications: |
| 104 | + - kustomizeConfig: |
| 105 | + repoRef: |
| 106 | + name: manifests |
| 107 | + path: config |
| 108 | + parameters: |
| 109 | + - name: trustyaiServiceImage |
| 110 | + value: NEW_IMAGE_NAME |
| 111 | + name: trustyai-service-operator |
| 112 | + repos: |
| 113 | + - name: manifests |
| 114 | + uri: https://github.com/trustyai-explainability/trustyai-service-operator/tarball/main |
| 115 | + version: v1.0.0 |
| 116 | +``` |
| 117 | +If these parameters are unspecified, the [default image and tag](config/base/params.env) will be used. |
| 118 | +
|
| 119 | +
|
| 120 | +If you'd like to change the service image/tag after deploying the operator, simply change the parameters in the KFDef. Any |
| 121 | +TrustyAI service deployed subsequently will use the new image and tag. |
| 122 | + |
| 123 | +### `TrustyAIService` Status Updates |
| 124 | + |
| 125 | +The `TrustyAIService` custom resource tracks the availability of `InferenceServices` and `PersistentVolumeClaims (PVCs)` |
| 126 | +through its `status` field. Below are the status types and reasons that are available: |
| 127 | + |
| 128 | +#### `InferenceService` Status |
| 129 | + |
| 130 | +| Status Type | Status Reason | Description | |
| 131 | +|-------------------------------|-----------------------------------|-----------------------------------| |
| 132 | +| `InferenceServicesPresent` | `InferenceServicesNotFound` | InferenceServices were not found. | |
| 133 | +| `InferenceServicesPresent` | `InferenceServicesFound` | InferenceServices were found. | |
| 134 | + |
| 135 | +#### `PersistentVolumeClaim` (PVCs) Status |
| 136 | + |
| 137 | +| Status Type | Status Reason | Description | |
| 138 | +|------------------|-----------------|------------------------------------| |
| 139 | +| `PVCAvailable` | `PVCNotFound` | `PersistentVolumeClaim` not found. | |
| 140 | +| `PVCAvailable` | `PVCFound` | `PersistentVolumeClaim` found. | |
| 141 | + |
| 142 | + |
| 143 | +#### Status Behavior |
| 144 | + |
| 145 | +- If a PVC is not available, the `Ready` status of `TrustyAIService` will be set to `False`. |
| 146 | +- However, if `InferenceServices` are not found, the `Ready` status of `TrustyAIService` will not be affected, _i.e._, it is `Ready` by all other conditions, it will remain so. |
0 commit comments