Skip to content

Commit

Permalink
Merge pull request #130 from canonical/main
Browse files Browse the repository at this point in the history
Merge `main` into `track/0.10`
  • Loading branch information
DnPlas authored Jun 7, 2023
2 parents de140b0 + b1084ad commit fa5dbb0
Show file tree
Hide file tree
Showing 36 changed files with 1,678 additions and 433 deletions.
44 changes: 25 additions & 19 deletions .github/workflows/integrate.yaml
Original file line number Diff line number Diff line change
@@ -1,31 +1,28 @@
# reusable workflow triggered by other actions
name: Continuous Integration
name: CI

on:
workflow_call:
secrets:
charmcraft-credentials:
CHARMCRAFT_CREDENTIALS:
required: true

jobs:

lib-check:
name: Check libraries
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Check libs
uses: canonical/charming-actions/[email protected]
with:
credentials: "${{ secrets.charmcraft-credentials }}"
github-token: "${{ secrets.GITHUB_TOKEN }}"

strategy:
matrix:
charm:
- kserve-controller
- kserve-web-app
uses: canonical/charmed-kubeflow-workflows/.github/workflows/_quality-checks.yaml@main
secrets: inherit
with:
charm-path: ./charms/${{ matrix.charm }}

lint:
name: Lint Code
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
strategy:
matrix:
# TODO: add web-app once changes in canonical/kserve-operators#2 and #3
Expand All @@ -38,7 +35,7 @@ jobs:

unit:
name: Unit Test
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
strategy:
matrix:
# TODO: add web-app once changes in canonical/kserve-operators#2 and #3
Expand All @@ -51,7 +48,7 @@ jobs:

charm-integration:
name: Individual Integration Tests
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
strategy:
matrix:
# TODO: add web-app once changes in canonical/kserve-operators#2 and #3
Expand All @@ -66,9 +63,10 @@ jobs:
uses: charmed-kubernetes/actions-operator@main
with:
provider: microk8s
channel: 1.25/stable
channel: 1.24/stable
# Pinned until this bug is resolved: https://bugs.launchpad.net/juju/+bug/1992833
bootstrap-options: "--agent-version=2.9.34"
microk8s-addons: "dns storage rbac metallb:10.64.140.43-10.64.140.49"
charmcraft-channel: latest/candidate
- run: tox -e ${{ matrix.charm }}-integration

Expand All @@ -77,6 +75,14 @@ jobs:
run: kubectl get all -A
if: failure()

- name: Get inference servers
run: kubectl get inferenceservices -A
if: failure()

- name: Get events
run: kubectl get events -A
if: failure()

- name: Describe deployments
run: kubectl describe deployments -A
if: failure()
Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/on_pull_request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@ jobs:
tests:
name: Run Tests
uses: ./.github/workflows/integrate.yaml
secrets:
charmcraft-credentials: ${{ secrets.CHARMCRAFT_CREDENTIALS }}
secrets: inherit

# publish runs in parallel with tests, as we always publish in this situation
publish-charm:
name: Publish Charm
uses: ./.github/workflows/publish.yaml
secrets:
CHARMCRAFT_CREDENTIALS: ${{ secrets.CHARMCRAFT_CREDENTIALS }}
secrets: inherit

15 changes: 6 additions & 9 deletions .github/workflows/on_push.yaml
Original file line number Diff line number Diff line change
@@ -1,31 +1,28 @@
name: Publish to edge if tests passed
name: On Push

# On push to a "special" branch, we:
# * always publish to charmhub at latest/edge/branchname
# * always run tests
# where a "special" branch is one of main/master or track/**, as
# where a "special" branch is one of main or track/**, as
# by convention these branches are the source for a corresponding
# charmhub edge channel.

on:
push:
branches:
- master
- main
- track/**
- main
- track/**

jobs:

tests:
name: Run Tests
uses: ./.github/workflows/integrate.yaml
secrets:
charmcraft-credentials: "${{ secrets.CHARMCRAFT_CREDENTIALS }}"
secrets: inherit

# publish runs in series with tests, and only publishes if tests passes
publish-charm:
name: Publish Charm
needs: tests
uses: ./.github/workflows/publish.yaml
secrets:
charmcraft-credentials: "${{ secrets.CHARMCRAFT_CREDENTIALS }}"
secrets: inherit
4 changes: 2 additions & 2 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
ref: ${{ inputs.source_branch }}

- name: Select charmhub channel
uses: canonical/charming-actions/channel@2.2.3
uses: canonical/charming-actions/channel@2.3.0
id: select-channel
if: ${{ inputs.destination_channel == '' }}

Expand All @@ -84,7 +84,7 @@ jobs:
echo "::set-output name=tag_prefix::$tag_prefix"
- name: Upload charm to charmhub
uses: canonical/charming-actions/upload-charm@2.2.3
uses: canonical/charming-actions/upload-charm@2.3.0
with:
credentials: ${{ secrets.CHARMCRAFT_CREDENTIALS }}
github-token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Release charm to channel
uses: canonical/charming-actions/release-charm@2.2.3
uses: canonical/charming-actions/release-charm@2.3.0
with:
credentials: ${{ secrets.CHARMCRAFT_CREDENTIALS }}
github-token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
80 changes: 62 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,18 @@ Upstream documentation can be found at https://kserve.github.io/website/0.8/

## Usage

### Supported versions

* Kubernetes 1.24
* istio-operators 1.16/stable
* knative-operators 1.8/stable

### Pre-requisites

* Microk8s <supported-version>/stable, supported-version=1.22, 1.23, 1.24
>NOTE: These instructions assume you have run `microk8s enable dns storage rbac metallb:"10.64.140.43-10.64.140.49,192.168.0.105-192.168.0.111"`
* Kubernetes cluster
>NOTE: If you are using Microk8s, it is assumed you have run `microk8s enable dns storage rbac metallb:"10.64.140.43-10.64.140.49,192.168.0.105-192.168.0.111"`.
* `istio-pilot` and `istio-ingressgateway` charms deployed. See "Deploy dependencies" for deploy instructions.
* `istio-pilot` and `istio-ingressgateway`. See "Deploy dependencies" for deploy instructions.

### Add a model and set variables

Expand All @@ -24,49 +30,87 @@ juju add-model ${MODEL_NAME}

### Deploy dependencies

KServe requires istio to be deployed in the cluster. To correctly configure them, you can:
kserve-operators require istio-operators to be deployed in the cluster. To correctly configure them, you can:

```
ISTIO_CHANNEL=1.11/stable
ISTIO_CHANNEL=1.16/stable
juju deploy istio-pilot --config default-gateway=${DEFAULT_GATEWAY} --channel ${ISTIO_CHANNEL} --trust
juju deploy istio-gateway istio-ingressgateway --config kind="ingress" --channel ${ISTIO_CHANNEL} --trust
juju relate istio-pilot istio-ingressgateway
```

#### Only for Serverless mode

For serverless operations kserve-operators depends on knative-serving. To correctly configure it, you can:

> NOTE: these instructions assume you have deployed Microk8s and MetalLB is enabled. If your cloud configuration is different than this, please refer to [knative-operators](https://github.com/canonical/knative-operators#usage) documentation.
```
KNATIVE_CHANNEL=1.8/stable
juju deploy knative-operator --channel ${KNATIVE_CHANNEL} --trust
juju deploy knative-serving --config namespace="knative-serving" --config istio.gateway.namespace=${MODEL_NAME} --config istio.gateway.name=${DEFAULT_GATEWAY} --channel ${KNATIVE_CHANNEL} --trust
```

### Deploy in `RawDeployment` mode

KServe supports `RawDeployment` mode to enable `InferenceService`, which removes the KNative dependency and unlocks some of its limitations, like mounting multiple volumes. Please note this mode is not loaded with serverless capabilities, for that you'd need to deploy in `Serverless` mode.
kserve-operators support `RawDeployment` mode to manage `InferenceService`, which removes the KNative dependency and unlocks some of its limitations, like mounting multiple volumes. Please note this mode is not loaded with serverless capabilities, for that you'd need to deploy in `Serverless` mode.

1. Deploy `kserver-controller`

```
juju deploy kserve-controller --channel <channel> --trust
```

2. Relate `kserve-controller` and `istio-pilot`

```
juju relate istio-pilot:gateway-info kserve-controller:ingress-gateway
```

> `channel` is the available channels of the Charmed KServe:
* latest/stable
* 0.8/stable
* latest/edge
* 0.10/stable

### Deploy in `Serverless` mode

TODO
kserve-operatos support `Serveless` mode to manage event driven `InferenceService`s, which enables autoscaling on demand, and supports scaling down to zero.

1. Deploy `kserver-controller`

```
juju deploy kserve-controller --channel <channel> --config deployment-mode="serverless" --trust
```

2. Relate `kserve-controller` and `istio-pilot`

```
juju relate istio-pilot:gateway-info kserve-controller:ingress-gateway
```

3. Relate `kserve-controller` and `knative-serving`

```
juju relate kserve-controller:local-gateway knative-serving:local-gateway
```

## Deploy a simple `InferenceService`

To deploy a simple example of an `InferenceServer`, you can use the one provided in `examples/`

> NOTE: this example is based on [First InferenceService](https://kserve.github.io/website/0.9/get_started/first_isvc/#2-create-an-inferenceservice)
1. Create an `InferenceService`
1. Create an `InferenceService` in a testing namespace

```
kubectl apply -f sklearn-iris.yaml
USER_NS="kserve-testing"
kubectl create ns ${USER_NS}
kubectl apply -f sklearn-iris.yaml -n${USER_NS}
```

2. Check the `InferenceService` status

```
kubectl get inferenceservices sklearn-iris
kubectl get inferenceservices sklearn-iris -n${USER_NS}
```

3. Determine the URL for performing inference
Expand All @@ -76,17 +120,16 @@ kubectl get inferenceservices sklearn-iris
> NOTE: this method can only be used for performing inference within the cluster.
```
SERVICE_IP=$(kubectl get svc sklearn-iris-predictor-default -ojsonpath='{.spec.clusterIP}')
SERVICE_IP=$(kubectl get svc sklearn-iris-predictor-default -n${USER_NS} -ojsonpath='{.spec.clusterIP}')
INFERENCE_URL="${SERVICE_IP}/v1/models/sklearn-iris:predict"
```

* Using Istio Ingress and LoadBalancer

> NOTE: This step assumes you enabled MetalLB addon in Microk8s at the beginning of this tutorial.
* Using the `InferenceService` URL

```
LOADBALANCER_IP=$(kubectl get svc istio-ingressgateway-workload -n${MODEL_NAME} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
INFERENCE_URL="{LOADBALANCER_IP}/v1/models/sklearn-iris:predict"
kubectl get inferenceservice sklearn-iris -n${USER_NS}
# From the output, take the URL
INFERENCE_URL="${URL}/v1/models/sklearn-iris:predict"
```

4. Perform inference
Expand All @@ -102,6 +145,7 @@ cat <<EOF > "./iris-input.json"
]
}
EOF
```

Now call the `InferenceService`:

Expand Down
8 changes: 8 additions & 0 deletions charms/kserve-controller/config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
# Copyright 2022 Canonical Ltd.
# See LICENSE file for licensing details.
options:
deployment-mode:
default: "RawDeployment"
description: Deployment mode for kserve. It can only be RawDeployment or Serverless, and the latter requires knative-serving to be present in the model, and the local-gateway relation to be established.
type: string
domain-name:
default: "example.com"
description: The domain name used for all fully-qualified route names shown. In serverless mode, it has to be the same as knative-serving's domain name; otherwise, it can be changed to match the cluster ingress configuration.
type: string
port:
type: int
default: 9443
Expand Down
Loading

0 comments on commit fa5dbb0

Please sign in to comment.