Skip to content

Commit

Permalink
docs: completed documentations about cli
Browse files Browse the repository at this point in the history
Signed-off-by: Neko Ayaka <[email protected]>
  • Loading branch information
nekomeowww committed Apr 21, 2024
1 parent e6a06f1 commit 9ba6174
Show file tree
Hide file tree
Showing 25 changed files with 827 additions and 96 deletions.
60 changes: 54 additions & 6 deletions docs/.vitepress/config.mts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { text } from 'stream/consumers'
import { defineConfig } from 'vitepress'
import { tabsMarkdownPlugin } from 'vitepress-plugin-tabs'

// https://vitepress.dev/reference/site-config
// https://vitepress.dev/references/site-config
export default defineConfig({
markdown: {
config(md) {
Expand All @@ -13,7 +14,7 @@ export default defineConfig({
lastUpdated: true,
ignoreDeadLinks: [
// Site Config | VitePress
// https://vitepress.dev/reference/site-config#ignoredeadlinks
// https://vitepress.dev/references/site-config#ignoredeadlinks
//
// ignore all localhost links
/^https?:\/\/localhost/,
Expand Down Expand Up @@ -82,7 +83,8 @@ export default defineConfig({
{
text: 'Reference',
items: [
{ text: 'CRD definition', link: '/pages/en/references/crd' },
{ text: 'CLI Reference', link: '/pages/en/references/cli/' },
{ text: 'CRD Reference', link: '/pages/en/references/crd/' },
{ text: 'Architectural Design', link: '/pages/en/references/architectural-design' },
]
},
Expand Down Expand Up @@ -110,7 +112,27 @@ export default defineConfig({
{
text: 'Reference',
items: [
{ text: 'CRD definition', link: '/pages/en/references/crd' },
{
text: 'CLI Reference',
items: [
{ text: 'Commands list', link: '/pages/en/references/cli/' },
{
text: 'Commands',
items: [
{ text: 'kollama deploy', link: '/pages/en/references/cli/commands/deploy' },
{ text: 'kollama undeploy', link: '/pages/en/references/cli/commands/undeploy' },
{ text: 'kollama expose', link: '/pages/en/references/cli/commands/undeploy' }
]
}
]
},
{
text: 'CRD Reference',
items: [
{ text: 'CRD list', link: '/pages/en/references/crd/' },
{ text: 'Model', link: '/pages/en/references/crd/model' }
]
},
{ text: 'Architectural Design', link: '/pages/en/references/architectural-design' },
]
},
Expand Down Expand Up @@ -147,7 +169,13 @@ export default defineConfig({
{
text: '参考',
items: [
{ text: 'CRD 定义', link: '/pages/zh-CN/references/crd' },
{
text: 'CLI 参考',
items: [
{ text: '命令列表', link: '/pages/zh-CN/references/cli/' },
]
},
{ text: 'CRD 参考', link: '/pages/zh-CN/references/crd/' },
{ text: '架构设计', link: '/pages/zh-CN/references/architectural-design' },
]
},
Expand Down Expand Up @@ -175,7 +203,27 @@ export default defineConfig({
{
text: '参考',
items: [
{ text: 'CRD 定义', link: '/pages/zh-CN/references/crd' },
{
text: 'CLI 参考',
items: [
{ text: '命令列表', link: '/pages/zh-CN/references/cli/' },
{
text: '子命令',
items: [
{ text: 'kollama deploy', link: '/pages/zh-CN/references/cli/commands/deploy' },
{ text: 'kollama undeploy', link: '/pages/zh-CN/references/cli/commands/undeploy' },
{ text: 'kollama expose', link: '/pages/zh-CN/references/cli/commands/undeploy' }
]
}
]
},
{
text: 'CRD 参考',
items: [
{ text: 'CRD 列表', link: '/pages/zh-CN/references/crd/' },
{ text: 'Model 模型资源', link: '/pages/zh-CN/references/crd/model' }
]
},
{ text: '架构设计', link: '/pages/zh-CN/references/architectural-design' },
]
},
Expand Down
4 changes: 2 additions & 2 deletions docs/.vitepress/theme/components/GettingStartedBlocksEn.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<TitleBlockContainerGroup>
<TitleBlockContainer
href="/pages/en/guide/getting-started/cli"
href="/pages/en/guide/getting-started/cli/"
bg="zinc-50 dark:zinc-800"
border="transparent solid 2 hover:zinc-200 dark:hover:zinc-800"
class="[&_.title-block-container]:bg-zinc-200 [&_.title-block-container]:dark:bg-zinc-600 [&_.title-block-container]:text-zinc-900 [&_.title-block-container]:dark:text-zinc-100"
Expand Down Expand Up @@ -32,7 +32,7 @@
</div>
</TitleBlockContainer>
<TitleBlockContainer
href="/pages/en/guide/getting-started/crd"
href="/pages/en/guide/getting-started/crd/"
bg="zinc-50 dark:zinc-800"
border="transparent solid 2 hover:zinc-200 dark:hover:zinc-800"
class="[&_.title-block-container]:bg-zinc-200 [&_.title-block-container]:dark:bg-zinc-600 [&_.title-block-container]:text-zinc-900 [&_.title-block-container]:dark:text-zinc-100"
Expand Down
4 changes: 2 additions & 2 deletions docs/.vitepress/theme/components/GettingStartedBlocksZhCn.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<TitleBlockContainerGroup>
<TitleBlockContainer
href="/pages/zh-CN/guide/getting-started/cli"
href="/pages/zh-CN/guide/getting-started/cli/"
bg="zinc-50 dark:zinc-800"
border="transparent solid 2 hover:zinc-200 dark:hover:zinc-800"
class="[&_.title-block-container]:bg-zinc-200 [&_.title-block-container]:dark:bg-zinc-600 [&_.title-block-container]:text-zinc-900 [&_.title-block-container]:dark:text-zinc-100"
Expand Down Expand Up @@ -32,7 +32,7 @@
</div>
</TitleBlockContainer>
<TitleBlockContainer
href="/pages/zh-CN/guide/getting-started/crd"
href="/pages/zh-CN/guide/getting-started/crd/"
bg="zinc-50 dark:zinc-800"
border="transparent solid 2 hover:zinc-200 dark:hover:zinc-800"
class="[&_.title-block-container]:bg-zinc-200 [&_.title-block-container]:dark:bg-zinc-600 [&_.title-block-container]:text-zinc-900 [&_.title-block-container]:dark:text-zinc-100"
Expand Down
4 changes: 4 additions & 0 deletions docs/pages/en/guide/getting-started/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,16 @@ We have a CLI called `kollama` here to simplify the deployment process. It is a
go install github.com/nekomeowww/ollama-operator/cmd/kollama@latest
```

> To learn about the supported commands, please refer to [`kollama`](/pages/en/references/cli/).
2. Deploy a model:

```shell
kollama deploy phi --expose --node-port 30001
```

> For more information about the `deploy` command, please refer to [`kollama deploy`](/pages/en/references/cli/commands/deploy).
That's it.

3. Interact with the model:
Expand Down
8 changes: 4 additions & 4 deletions docs/pages/en/guide/getting-started/crd.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Deploy the model

1. Create one `Model` CRD to rule them all.
1. Create one [`Model` CRD](/pages/en/references/crd/model) to rule them all.

::: tip What is CRD?

Expand Down Expand Up @@ -40,7 +40,7 @@ spec:

:::

Copy the following command to create a phi model CRD:
Copy the following command to create a phi [`Model` CRD](/pages/en/references/crd/model):

```shell
cat <<EOF >> ollama-model-phi.yaml
Expand Down Expand Up @@ -70,13 +70,13 @@ spec: # [!code ++]

:::

2. Apply the `Model` CRD to your Kubernetes cluster:
2. Apply the [`Model` CRD](/pages/en/references/crd/model) to your Kubernetes cluster:

```shell
kubectl apply -f ollama-model-phi.yaml
```

3. Wait for the model to be ready:
1. Wait for the [`Model`](/pages/en/references/crd/model) to be ready:

```shell
kubectl wait --for=jsonpath='{.status.readyReplicas}'=1 deployment/ollama-model-phi
Expand Down
163 changes: 163 additions & 0 deletions docs/pages/en/references/cli/commands/deploy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
# `kollama deploy`

`kollama deploy` command is used to deploy a [`Model`](/pages/en/references/crd/model) to the Kubernetes cluster. It's basic a wrapper and utility CLI to interact with the Ollama Operator by manipulating CRD resources.

[[toc]]

## Use cases

### Deploy model that lives on [registry.ollama.ai](https://registry.ollama.ai)

```shell
kollama deploy phi
```

### Deploy to a specific namespace

```shell
kollama deploy phi --namespace=production
```

### Deploy [`Model`](/pages/en/references/crd/model) that lives on a custom registry

```shell
kollama deploy phi --image=registry.example.com/library/phi:latest
```

### Deploy [`Model`](/pages/en/references/crd/model) with exposed NodePort service for external access

```shell
kollama deploy phi --expose
```

### Deploy [`Model`](/pages/en/references/crd/model) with exposed LoadBalancer service for external access

```shell
kollama deploy phi --expose --service-type=LoadBalancer
```

## Flags

### `--namespace`

If present, the namespace scope for this CLI request.

### `--image`

Default: `registry.ollama.ai/library/<model name>:latest`

```shell
kollama deploy phi --image=registry.ollama.ai/library/phi:latest
```

Model image to deploy.

- If not specified, the [`Model`](/pages/en/references/crd/model) name will be used as the image name (will be pulled from `registry.ollama.ai/library/<model name>` by default if no registry is specified). For example, if the [`Model`](/pages/en/references/crd/model) name is `phi`, the image name will be `registry.ollama.ai/library/phi:latest`.
- If not specified, the tag will be latest.

### `--storage-class`

```shell
kollama deploy phi --storage-class=standard
```

[`StorageClass`](https://kubernetes.io/docs/concepts/storage/storage-classes/#storageclass-objects) to use for the [`Model`](/pages/en/references/crd/model)'s associated [`PersistentVolumeClaim`](https://kubernetes.io/docs/concepts/storage/persistent-volumes/#persistentvolumeclaims).

If not specified, the [default `StorageClass`](https://kubernetes.io/docs/concepts/storage/storage-classes/#default-storageclass) will be used.

### `--pv-access-mode`

```shell
kollama deploy phi --pv-access-mode=ReadWriteMany
```

[Access mode](https://kubernetes.io/docs/concepts/storage/persistent-volumes/#access-modes) for Ollama Operator created image store (to cache pulled images)'s [`StatefulSet`](https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/) resource associated [`PersistentVolume`](https://kubernetes.io/docs/concepts/storage/persistent-volumes/#introduction).

If not specified, the access mode will be [`ReadWriteOnce`](https://kubernetes.io/docs/concepts/storage/persistent-volumes/#access-modes).

If you are deploying [`Model`](/pages/en/references/crd/model)s into default deployed [kind](https://kind.sigs.k8s.io/) and [k3s](https://k3s.io/) clusters, you should keep it as [`ReadWriteOnce`](https://kubernetes.io/docs/concepts/storage/persistent-volumes/#access-modes). If you are deploying [`Model`](/pages/en/references/crd/model)s into a custom cluster, you can set it to [`ReadWriteMany`](https://kubernetes.io/docs/concepts/storage/persistent-volumes/#access-modes) if [`StorageClass`](https://kubernetes.io/docs/concepts/storage/storage-classes/#storageclass-objects) supports it.

### `--expose`

Default: `false`

```shell
kollama deploy phi --expose
```

Whether to expose the [`Model`](/pages/en/references/crd/model) through a Service for external access and makes it easy to interact with the [`Model`](/pages/en/references/crd/model).

::: info Actually, when creating a Model resource, a `ClusterIP` type service will be created

At the case where users didn't supply either `--expose` flag, Ollama Operator will create a associated service for the [`Model`](/pages/en/references/crd/model) with the type of `ClusterIP` with the same name as the corresponding Deployment by default, and the service will be used for internal communication between the [`Model`](/pages/en/references/crd/model) and other services in the cluster.

:::

By default, [`--expose`](#expose) will create a [`NodePort`](https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport) service.

Use `--expose=LoadBalancer` to create a [`LoadBalancer`](https://kubernetes.io/docs/concepts/services-networking/service/#loadbalancer) service.

### `--service-type`

```shell
kollama deploy phi --expose --service-type=NodePort
```

Default: `NodePort`

Type of the [`Service`](https://kubernetes.io/docs/concepts/services-networking/service/) to expose the [`Model`](/pages/en/references/crd/model). **Only valid when [`--expose`](#expose) is specified.**

If not specified, the service will be exposed as [`NodePort`](https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport).

::: tip To understand how many Services are associated to [`Model`](/pages/en/references/crd/model)...

```shell
kubectl get svc --selector model.ollama.ayaka.io
```

:::

Use [`LoadBalancer`](https://kubernetes.io/docs/concepts/services-networking/service/#loadbalancer) to expose the service as [`LoadBalancer`](https://kubernetes.io/docs/concepts/services-networking/service/#loadbalancer).

### `--service-name`

```shell
kollama deploy phi --expose --service-name=phi-svc-nodeport
```

Default: `ollama-model-<model name>-<service type>`

Name of the [`Service`](https://kubernetes.io/docs/concepts/services-networking/service/) to expose the [`Model`](/pages/en/references/crd/model).

If not specified, the [`Model`](/pages/en/references/crd/model) name will be used as the service name with `-nodeport` as the suffix for [`NodePort`](https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport).

### `--node-port`

```shell
kollama deploy phi --expose --service-type=NodePort --node-port=30000
```

Default: Random port

::: tip To understand what NodePort is used for the [`Model`](/pages/en/references/crd/model)...

```shell
kubectl get svc --selector model.ollama.ayaka.io/name=<model name> -o json | jq ".spec.ports[0].nodePort"
```

:::

::: warning You can't simply specify a port number!

There are several restrictions:

1. By default, `30000-32767` is the `NodePort` port range in the Kubernetes cluster. If you want to use ports outside this range, you need to configure the `--service-node-port-range` parameter for the cluster.
2. You can't use the port number already occupied by other services.

For more information about choosing your own port number, please refer to [Chapter of Kubernetes Official Document about `nodePort`](https://kubernetes.io/docs/concepts/services-networking/service/#nodeport-custom-port).

:::

[`nodePort`](https://kubernetes.io/docs/concepts/services-networking/service/#nodeport-custom-port) to expose the [`Model`](/pages/en/references/crd/model).

If not specified, a random port will be assigned. Only valid when [`--expose`](#expose) is specified, and [`--service-type`](#service-type) is set to NodePort.
Loading

0 comments on commit 9ba6174

Please sign in to comment.