Skip to content

Commit

Permalink
Merge pull request #5 from ruivieira/install-k8s
Browse files Browse the repository at this point in the history
Add Kubernetes installation
  • Loading branch information
ruivieira authored Oct 24, 2023
2 parents c1843ec + 5edabab commit 8109d44
Show file tree
Hide file tree
Showing 7 changed files with 177 additions and 118 deletions.
2 changes: 2 additions & 0 deletions Writerside/c.list
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@
SYSTEM "https://resources.jetbrains.com/writerside/1.0/categories.dtd">
<categories>
<category id="wrs" name="Writerside documentation" order="1"/>
<category id="related" name="Related" order="2"/>
<category id="repos" name="Repositories" order="3"/>
</categories>
4 changes: 4 additions & 0 deletions Writerside/redirection-rules.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,8 @@
<description>Created after removal of "Install on Open Data Hub" from TrustyAI</description>
<accepts>Install-on-Open-Data-Hub.html</accepts>
</rule>
<rule id="43c37bd3">
<description><![CDATA[Created after removal of "<Install-on-Kubernetes.md>" from TrustyAI]]></description>
<accepts>Install-on-Kubernetes.html</accepts>
</rule>
</rules>
2 changes: 1 addition & 1 deletion Writerside/t.tree
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
<toc-element topic="TrustyAI-Python.md"/>
<toc-element topic="TrustyAI-core.md"/>
<toc-element topic="TrustyAI-operator.md">
<toc-element topic="Install-on-Kubernetes.md"/>
</toc-element>
<toc-element topic="TrustyAI-service.md">
<toc-element topic="Starter.md"/>
Expand All @@ -29,6 +28,7 @@
</toc-element>
<toc-element topic="How-to.md">
<toc-element topic="Install-on-Open-Data-Hub.md"/>
<toc-element topic="Installing-on-Kubernetes.md"/>
</toc-element>
<toc-element topic="Tutorial.md">
<toc-element topic="Bias-Monitoring-via-TrustyAI-in-ODH.md"/>
Expand Down
39 changes: 1 addition & 38 deletions Writerside/topics/How-to.md
Original file line number Diff line number Diff line change
@@ -1,40 +1,3 @@
# How to

A How-to article is an action-oriented type of document.
It explains how to perform a specific task or solve a problem, and usually contains a sequence of steps.
Start with a short introductory paragraph that explains what users will accomplish by following this procedure,
what they need to perform it for, or define the target audience of the doc.

> **Highlight important information**
>
> You can change the element to *tip* or *warning* by renaming the style attribute below.
>
{style="note"}

## Before you start

It is good practice to list the prerequisites that are required or recommended.

Make sure that:
- First prerequisite
- Second prerequisite

## How to perform a task

Some introductory information.

1. Step with a code block

```bash
run this --that
```

2. Step with an image
![](image.png)

<!-- The 'src' attribute should contain the name of an image from the '/images' folder in your project -->

3. Step with a list.
- List item
- List item
- List item
A list of how-to articles.
78 changes: 0 additions & 78 deletions Writerside/topics/Install-on-Kubernetes.md

This file was deleted.

146 changes: 146 additions & 0 deletions Writerside/topics/Installing-on-Kubernetes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
# Installing on Kubernetes

## Using pre-built operator image

This operator is available as an [image on Quay.io](https://quay.io/repository/trustyai/trustyai-service-operator?tab=history).
To deploy it on your cluster:

1. **Install the Custom Resource Definition (CRD):**

Apply the CRD to your cluster (replace the URL with the relevant one, if using another repository):

```bash
kubectl apply -f https://raw.githubusercontent.com/trustyai-explainability/trustyai-service-operator/main/config/crd/bases/trustyai.opendatahub.io.trustyai.opendatahub.io_trustyaiservices.yaml
```

2. **Deploy the Operator:**

Apply the following Kubernetes manifest to deploy the operator:

```yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: trustyai-operator
namespace: trustyai-operator-system
spec:
replicas: 1
selector:
matchLabels:
control-plane: trustyai-operator
template:
metadata:
labels:
control-plane: trustyai-operator
spec:
containers:
- name: trustyai-operator
image: quay.io/trustyai/trustyai-service-operator:latest
command:
- /manager
resources:
limits:
cpu: 100m
memory: 30Mi
requests:
cpu: 100m
memory: 20Mi
```

or run

```shell
kubectl apply -f https://raw.githubusercontent.com/trustyai-explainability/trustyai-service-operator/main/artifacts/examples/deploy-operator.yaml
```

## Usage

Once the operator is installed, you can create `TrustyAIService` resources, and the operator will create corresponding TrustyAI deployments, services, and (on OpenShift) routes.

Here's an example `TrustyAIService` manifest:
```yaml
apiVersion: trustyai.opendatahub.io.trusty.opendatahub.io/v1
kind: TrustyAIService
metadata:
name: trustyai-service-example
spec:
storage:
format: "PVC"
folder: "/inputs"
size: "1Gi"
data:
filename: "data.csv"
format: "CSV"
metrics:
schedule: "5s"
batchSize: 5000 # Optional, defaults to 5000
```
You can apply this manifest with
```shell
kubectl apply -f <file-name.yaml> -n $NAMESPACE
```
to create a service, where `$NAMESPACE` is the namespace where you want to deploy it.
Additionally, in that namespace:
* a `ServiceMonitor` will be created to allow Prometheus to scrape metrics from the service.
* (if on OpenShift) a `Route` will be created to allow external access to the service.
### Custom Image Configuration using ConfigMap
You can specify a custom TrustyAI-service image via adding parameters to the TrustyAI-Operator KFDef, for example:
```yaml
apiVersion: kfdef.apps.kubeflow.org/v1
kind: KfDef
metadata:
name: trustyai-service-operator
namespace: opendatahub
spec:
applications:
- kustomizeConfig:
repoRef:
name: manifests
path: config
parameters:
- name: trustyaiServiceImage
value: NEW_IMAGE_NAME
name: trustyai-service-operator
repos:
- name: manifests
uri: https://github.com/trustyai-explainability/trustyai-service-operator/tarball/main
version: v1.0.0
```
If these parameters are unspecified, the [default image and tag](config/base/params.env) will be used.
If you'd like to change the service image/tag after deploying the operator, simply change the parameters in the KFDef. Any
TrustyAI service deployed subsequently will use the new image and tag.

### `TrustyAIService` Status Updates

The `TrustyAIService` custom resource tracks the availability of `InferenceServices` and `PersistentVolumeClaims (PVCs)`
through its `status` field. Below are the status types and reasons that are available:

#### `InferenceService` Status

| Status Type | Status Reason | Description |
|-------------------------------|-----------------------------------|-----------------------------------|
| `InferenceServicesPresent` | `InferenceServicesNotFound` | InferenceServices were not found. |
| `InferenceServicesPresent` | `InferenceServicesFound` | InferenceServices were found. |

#### `PersistentVolumeClaim` (PVCs) Status

| Status Type | Status Reason | Description |
|------------------|-----------------|------------------------------------|
| `PVCAvailable` | `PVCNotFound` | `PersistentVolumeClaim` not found. |
| `PVCAvailable` | `PVCFound` | `PersistentVolumeClaim` found. |


#### Status Behavior

- If a PVC is not available, the `Ready` status of `TrustyAIService` will be set to `False`.
- 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.
24 changes: 23 additions & 1 deletion Writerside/topics/TrustyAI-operator.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
# TrustyAI operator

Start typing here...
The TrustyAI Kubernetes Operator aims at simplifying the deployment and management of the
[TrustyAI service](TrustyAI-service.md) on Kubernetes and OpenShift clusters by watching for custom resources of kind
`TrustyAIService` in the `trustyai.opendatahub.io` API group and manages deployments, services, and optionally, routes
and `ServiceMonitors` corresponding to these resources.

The operator ensures the service is properly configured, is discoverable by Prometheus for metrics scraping
(on both Kubernetes and OpenShift), and is accessible via a Route on OpenShift.

## Prerequisites

- Kubernetes cluster v1.19+ or OpenShift cluster v4.6+
- `kubectl` v1.19+ or `oc` client v4.6+

<seealso style="links">
<category ref="related">
<a href="Install-on-Open-Data-Hub.md">Installing on Open Data Hub</a>
<a href="Installing-on-Kubernetes.md">Installing on Kubernetes</a>
</category>
<category ref="repos">
<a href="https://github.com/trustyai-explainability/trustyai-service-operator">TrustyAI operator</a>
</category>
</seealso>

0 comments on commit 8109d44

Please sign in to comment.