-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Dockerfile for installing kit as a KServe ClusterStorageContainer
Add a Dockerfile that builds an image suitable to using `kit` as a ClusterStorageContainer for KServe installs. Included is a short README.md that gives a general overview of how to use this container. To come: automating multi-platform builds of this image to allow it to be more easily used.
- Loading branch information
Showing
3 changed files
with
113 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# Kitops ClusterStorageContainer image for KServe | ||
|
||
The Dockerfile in this directory is used to build an image that can run as a ClusterStorageContainer for [KServe](https://kserve.github.io/website/master/). | ||
|
||
## Building | ||
To build the image, `docker` is required. From the root of this repository, set the `$KIT_KSERVE_IMAGE` to the image tag you want to build and run | ||
```bash | ||
docker build . \ | ||
-f build/dockerfiles/KServe/kserve.Dockerfile \ | ||
-t $KIT_KSERVE_IMAGE \ | ||
--build-arg version="next" \ | ||
--build-arg gitCommit=$(git rev-parse HEAD) | ||
``` | ||
|
||
## Installing | ||
The following process will create a new ClusterStorageContainer that uses `kit` to support KServe InferenceServices with storage URIs that have the `kit://` prefix. | ||
|
||
Create the following ClusterStorageContainer custom resource in a Kubernetes cluster with KServe installed | ||
```yaml | ||
apiVersion: "serving.kserve.io/v1alpha1" | ||
kind: ClusterStorageContainer | ||
metadata: | ||
name: kitops | ||
spec: | ||
container: | ||
name: kit-storage-initializer | ||
image: $KIT_KSERVE_IMAGE | ||
imagePullPolicy: Always | ||
env: | ||
- name: KIT_UNPACK_FLAGS | ||
value: "" # Add extra flags for the `kit unpack` command | ||
resources: | ||
requests: | ||
memory: 100Mi | ||
cpu: 100m | ||
limits: | ||
memory: 1Gi | ||
supportedUriFormats: | ||
- prefix: kit:// | ||
``` | ||
Once this CR is installed, modelkits can be used in InferenceServices by specifying with the `kit://` URI: | ||
```yaml | ||
storageUri: kit://<modelkit-reference> | ||
``` | ||
|
||
## Configuration | ||
The Kit KServe container supports specifying additional flags as supported by the `kit unpack` command. Additional flags are read from the `KIT_UNPACK_FLAGS` environment variable in the ClusterStorageContainer. For example, the following adds `-v` and `--plain-http` for all unpack commands: | ||
```yaml | ||
env: | ||
- name: KIT_UNPACK_FLAGS | ||
value: "-v --plain-http" | ||
``` | ||
|
||
## Additional links | ||
* [KServe ClusterStorageContainer documentation](https://kserve.github.io/website/master/modelserving/storage/storagecontainers/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
echo "Binary version info:" | ||
kit version | ||
|
||
read -r -a UNPACK_FLAGS <<< "$KIT_UNPACK_FLAGS" | ||
|
||
if [ $# != 2 ]; then | ||
echo "Usage: entrypoint.sh <src-uri> <dest-path>" | ||
exit 1 | ||
fi | ||
|
||
REPO_NAME="${1#kit://}" | ||
OUTPUT_DIR="$2" | ||
|
||
echo "Unpacking $REPO_NAME to $OUTPUT_DIR" | ||
echo "Unpack options: ${KIT_UNPACK_FLAGS}" | ||
kit unpack "$REPO_NAME" -d "$OUTPUT_DIR" "${UNPACK_FLAGS[@]}" | ||
|
||
echo "Unpacked modelkit:" | ||
cat "$OUTPUT_DIR/Kitfile" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
FROM docker.io/library/golang:alpine AS builder | ||
|
||
RUN apk --no-cache upgrade && apk add --no-cache git | ||
ARG version=next | ||
ARG gitCommit=<unknown> | ||
|
||
WORKDIR /build | ||
|
||
# Cache dependencies in separate layer | ||
COPY ["go.mod", "go.sum", "./"] | ||
RUN go mod download | ||
|
||
COPY . . | ||
RUN \ | ||
CGO_ENABLED=0 go build \ | ||
-o kit \ | ||
-ldflags="-s -w -X kitops/pkg/cmd/version.Version=${version} -X kitops/pkg/cmd/version.GitCommit=$gitCommit -X kitops/pkg/cmd/version.BuildTime=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" | ||
|
||
FROM docker.io/library/alpine | ||
ENV USER_ID=1001 \ | ||
USER_NAME=kit \ | ||
HOME=/home/user/ | ||
|
||
RUN apk --no-cache upgrade && \ | ||
apk add --no-cache bash && \ | ||
mkdir -p /home/user/ && \ | ||
adduser -D $USER_NAME -h $HOME -u $USER_ID | ||
|
||
USER ${USER_ID} | ||
|
||
COPY --from=builder /build/kit /usr/local/bin/kit | ||
COPY build/dockerfiles/KServe/entrypoint.sh /usr/local/bin/entrypoint.sh | ||
|
||
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] |