Skip to content

Commit

Permalink
add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
freeznet committed Jun 21, 2024
1 parent d5fc9f4 commit 1e232dd
Show file tree
Hide file tree
Showing 6 changed files with 474 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/chart-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ jobs:
diff config/crd/bases/resource.streamnative.io_pulsarnamespaces.yaml charts/pulsar-resources-operator/crds/resource.streamnative.io_pulsarnamespaces.yaml && \
diff config/crd/bases/resource.streamnative.io_pulsarpermissions.yaml charts/pulsar-resources-operator/crds/resource.streamnative.io_pulsarpermissions.yaml && \
diff config/crd/bases/resource.streamnative.io_pulsartenants.yaml charts/pulsar-resources-operator/crds/resource.streamnative.io_pulsartenants.yaml && \
diff config/crd/bases/resource.streamnative.io_pulsarfunctions.yaml charts/pulsar-resources-operator/crds/resource.streamnative.io_pulsarfunctions.yaml && \
diff config/crd/bases/resource.streamnative.io_pulsarsinks.yaml charts/pulsar-resources-operator/crds/resource.streamnative.io_pulsarsinks.yaml && \
diff config/crd/bases/resource.streamnative.io_pulsarsources.yaml charts/pulsar-resources-operator/crds/resource.streamnative.io_pulsarsources.yaml && \
diff config/crd/bases/resource.streamnative.io_pulsarpackages.yaml charts/pulsar-resources-operator/crds/resource.streamnative.io_pulsarpackages.yaml && \
diff config/crd/bases/resource.streamnative.io_pulsartopics.yaml charts/pulsar-resources-operator/crds/resource.streamnative.io_pulsartopics.yaml
- name: Set up Helm
Expand Down
171 changes: 171 additions & 0 deletions docs/pulsar_function.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
# PulsarFunction

## Create PulsarFunction

1. Define a function named `test-pulsar-function` by using the YAML file and save the YAML file `function.yaml`.

```yaml
apiVersion: resource.streamnative.io/v1alpha1
kind: PulsarFunction
metadata:
name: test-pulsar-function
namespace: default
spec:
autoAck: true
className: org.apache.pulsar.functions.api.examples.ExclamationFunction
cleanupSubscription: true
connectionRef:
name: "test-pulsar-connection"
customRuntimeOptions: {}
deadLetterTopic: dl-topic
exposePulsarAdminClientEnabled: false
forwardSourceMessageProperty: true
inputs:
- input
jar:
url: function://public/default/[email protected]
lifecyclePolicy: CleanUpAfterDeletion
logTopic: func-log
maxMessageRetries: 101
name: test-pulsar-function
namespace: default
output: output
parallelism: 1
processingGuarantees: ATLEAST_ONCE
retainKeyOrdering: true
retainOrdering: false
secrets:
SECRET1:
key: hello
name: sectest
skipToLatest: true
subName: test-sub
subscriptionPosition: Latest
tenant: public
timeoutMs: 6666
```
This table lists specifications available for the `PulsarFunction` resource.

| Option | Description | Required or not |
|----------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------|
| `autoAck` | Whether to automatically acknowledge messages. | Optional |
| `className` | The class name of the function. | Yes |
| `cleanupSubscription` | Whether to clean up the subscription when the function is deleted. | Optional |
| `connectionRef` | The reference to a PulsarConnection. | Yes |
| `customRuntimeOptions` | Custom runtime options. | Optional |
| `deadLetterTopic` | The dead letter topic. | Optional |
| `exposePulsarAdminClientEnabled` | Whether to expose the Pulsar admin client. | Optional |
| `forwardSourceMessageProperty` | Whether to forward the source message property. | Optional |
| `inputs` | The input topics. | Yes |
| `jar` | The JAR package URL, can be used by Java runtime. | Optional |
| `py` | The Python package URL, can be used by Java runtime. | Optional |
| `go` | The Go package URL, can be used by Java runtime. | Optional |
| `lifecyclePolicy` | The resource lifecycle policy. Available options are `CleanUpAfterDeletion` and `KeepAfterDeletion`. By default, it is set to `CleanUpAfterDeletion`. | Optional |
| `logTopic` | The log topic. | Optional |
| `maxMessageRetries` | The maximum number of message retries. | Optional |
| `name` | The function name. | Yes |
| `namespace` | The namespace. | Yes |
| `output` | The output topic. | Yes |
| `parallelism` | The parallelism. | Optional |
| `processingGuarantees` | The processing guarantees. | Optional |
| `retainKeyOrdering` | Whether to retain key ordering. | Optional |
| `retainOrdering` | Whether to retain ordering. | Optional |
| `secrets` | The secrets. | Optional |
| `skipToLatest` | Whether to skip to the latest. | Optional |
| `subName` | The subscription name. | Optional |
| `subscriptionPosition` | The subscription position. | Optional |
| `tenant` | The tenant. | Yes |
| `timeoutMs` | The timeout in milliseconds. | Optional |
| `topicsPattern` | The topics pattern. | Optional |
| `batchBuilder` | The batch builder. | Optional |
| `producerConfig` | The producer configuration. | Optional |
| `customSchemaOutputs` | The custom schema outputs. | Optional |
| `outputSerdeClassName` | The output serde class name. | Optional |
| `outputSchemaType` | The output schema type. | Optional |
| `outputTypeClassName` | The output type class name of the function. | Optional |
| `runtimeFlags` | The runtime flags. | Optional |
| `resources` | The resources. | Optional |
| `windowConfig` | The window configuration. | Optional |
| `userConfig` | The user configuration. | Optional |
| `customSerdeInputs` | The custom serde inputs. | Optional |
| `customSchemaInputs` | The custom schema inputs. | Optional |
| `inputSpecs` | The input specs. | Optional |
| `inputTypeClassName` | The input type class name of the function. | Optional |
| `maxPendingAsyncRequests` | The maximum number of pending async requests. | Optional |
| `exposePulsarAdminClientEnabled` | Whether to expose the Pulsar admin client. | Optional |
| `skipToLatest` | Whether to skip to the latest. | Optional |

2. Apply the YAML file to create the function.

```shell
kubectl apply -f function.yaml
```

3. Check the resource status. When column Ready is true, it indicates the resource is created successfully in the pulsar cluster

```shell
kubectl get pulsarfunction
```

```
NAME RESOURCE_NAME GENERATION OBSERVED_GENERATION READY
test-pulsar-function test-pulsar-function 1 1 True
```
## Update PulsarFunction
You can update the function by editing the function.yaml, then apply it again.
For example, if you want to update the parallelism of the function, you can edit the function.yaml as follows:
```yaml
apiVersion: resource.streamnative.io/v1alpha1
kind: PulsarFunction
metadata:
name: test-pulsar-function
namespace: default
spec:
autoAck: true
className: org.apache.pulsar.functions.api.examples.ExclamationFunction
cleanupSubscription: true
connectionRef:
name: "test-pulsar-connection"
customRuntimeOptions: {}
deadLetterTopic: dl-topic
exposePulsarAdminClientEnabled: false
forwardSourceMessageProperty: true
inputs:
- input
jar:
url: function://public/default/[email protected]
lifecyclePolicy: CleanUpAfterDeletion
logTopic: func-log
maxMessageRetries: 101
name: test-pulsar-function
namespace: default
output: output
parallelism: 2
processingGuarantees: ATLEAST_ONCE
retainKeyOrdering: true
retainOrdering: false
secrets:
SECRET1:
key: hello
name: sectest
skipToLatest: true
subName: test-sub
subscriptionPosition: Latest
tenant: public
timeoutMs: 6666
```

```shell
kubectl apply -f function.yaml
```

## Delete PulsarFunction

```shell
kubectl delete pulsarfunction test-pulsar-function
```
46 changes: 45 additions & 1 deletion docs/pulsar_package.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,51 @@ This table lists specifications available for the `PulsarPackage` resource.
| `properties` | A user-defined key/value map to store other information. | Optional |
| `lifecyclePolicy` | The resource lifecycle policy. Available options are `CleanUpAfterDeletion` and `KeepAfterDeletion`. By default, it is set to `CleanUpAfterDeletion`. | Optional |

1. Apply the YAML file to create the package.
2. Apply the YAML file to create the package.

```shell
kubectl apply -f package.yaml
```

3. Check the resource status. When column Ready is true, it indicates the resource is created successfully in the pulsar cluster

```shell
kubectl get pulsarpackage
```

```
NAME RESOURCE_NAME GENERATION OBSERVED_GENERATION READY
test-pulsar-package 1 1 True
```
## Update PulsarPackage
You can update the package by editing the package.yaml, then apply it again. For example, if you want to update the contact of the package, you can edit the package.yaml as follows:
```yaml
apiVersion: resource.streamnative.io/v1alpha1
kind: PulsarPackage
metadata:
name: test-pulsar-package
namespace: default
spec:
packageURL: function://public/default/[email protected]
fileURL: https://github.com/freeznet/pulsar-functions-api-examples/raw/main/api-examples.jar
connectionRef:
name: "test-pulsar-connection"
description: api-examples.jar
contact: streamnative
lifecyclePolicy: CleanUpAfterDeletion
```

Please be noted that update will not overwrite the package content even if `fileURL` is changed. To change the package content, you need to create a new package.

## Delete PulsarPackage

You can delete the package by using the following command:

```shell
kubectl delete pulsarpackage test-pulsar-package
```

Please be noticed, when you delete the package, the real package will still exist if the `lifecyclePolicy` is `KeepAfterDeletion`.
Loading

0 comments on commit 1e232dd

Please sign in to comment.