StreamNative Cloud enables you to manage Pulsar Functions by using a variety of tools, including snctl, pulsarctl, pulsar-admin, REST API, and Terraform.
If you want to update or delete functions using snctl, pulsarctl or pulsar-admin, make sure you have set up your client tool. For more information, see set up client tools.
To update the submitted function, you only need to update the Terraform file and then call the following command.
Copy
Ask AI
terraform apply
You should see something like following:
Copy
Ask AI
pulsar_function.function-1: Refreshing state... [id=public/default/function1]Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols: ~ update in-placeTerraform will perform the following actions: # pulsar_function.function-1 will be updated in-place ~ resource "pulsar_function" "function-1" { ~ custom_runtime_options = jsonencode( ~ { - clusterName = "oxia-test" - enableStateStore = false - inputTypeClassName = "java.lang.String" - logTopicAgent = "runtime" - managed = true - maxReplicas = 0 - outputTypeClassName = "java.lang.String" - runnerImage = "streamnative/pulsar-functions-sn-java-runner:3.1.0.4" - serviceAccountName = "oxia-test-function-pulsarcluster" # (1 unchanged attribute hidden) } ) ~ disk_mb = 10240 -> 128 id = "public/default/function1" name = "function1" ~ parallelism = 1 -> 2 ~ ram_mb = 140 -> 128 # (21 unchanged attributes hidden) }Plan: 0 to add, 1 to change, 0 to destroy.Do you want to perform these actions? Terraform will perform the actions described above. Only 'yes' will be accepted to approve. Enter a value:
If you want to verify whether the function has been deleted successfully, run the following command.
Copy
Ask AI
snctl pulsar admin functions get --tenant public --namespace default --name exclamation
You should see the following output:
Copy
Ask AI
[✖] code: 500 reason: failed to perform the request: responseCode: 404, responseMessage: functions.compute.functionmesh.io "exclamation-XXXXX" not found
To delete the function exclamation, use the following command.
If you want to verify whether the function has been deleted successfully, run the following command.
Copy
Ask AI
snctl pulsar admin functions get --tenant public --namespace default --name exclamation
You should see the following output:
Copy
Ask AI
[✖] code: 500 reason: failed to perform the request: responseCode: 404, responseMessage: functions.compute.functionmesh.io "exclamation-XXXXX" not found
To delete the function exclamation, use the following command.
Copy
Ask AI
pulsarctl functions delete --tenant public --namespace default --name exclamation
You should see the following output:
Copy
Ask AI
Deleted exclamation successfully
If you want to verify whether the function has been deleted successfully, run the following command.
Copy
Ask AI
pulsarctl functions get --tenant public --namespace default --name exclamation
You should see the following output:
Copy
Ask AI
[✖] code: 500 reason: failed to perform the request: responseCode: 404, responseMessage: functions.compute.functionmesh.io "exclamation-XXXXX" not found
To delete the function exclamation, run the following command.
Copy
Ask AI
./bin/pulsar-admin functions delete --tenant public --namespace default --name exclamation
You should see the following output:
Copy
Ask AI
Delete exclamation successfully
To verify the function has been deleted, run the following command.
Copy
Ask AI
./bin/pulsar-admin functions get --tenant public --namespace default --name exclamation
You should see the following output:
Copy
Ask AI
failed to perform the request: responseCode: 404, responseMessage: functions.compute.functionmesh.io "exclamation-XXXXX" not found
To delete the function exclamation with terraform, run the following command and type yes on the prompt.
Copy
Ask AI
terraform destroy
You should see the following output:
Copy
Ask AI
pulsar_function.function-1: Refreshing state... [id=public/default/function1]Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols: - destroyTerraform will perform the following actions: # pulsar_function.function-1 will be destroyed - resource "pulsar_function" "function-1" { - auto_ack = true -> null - classname = "org.apache.pulsar.functions.api.examples.ExclamationFunction" -> null - cleanup_subscription = true -> null - cpu = 0.5 -> null - custom_runtime_options = jsonencode( { - clusterName = "oxia-test" - enableStateStore = false - env = { - HELLO = "WORLD" } - inputTypeClassName = "java.lang.String" - logTopicAgent = "runtime" - managed = true - maxReplicas = 0 - outputTypeClassName = "java.lang.String" - runnerImage = "streamnative/pulsar-functions-sn-java-runner:3.1.0.4" - serviceAccountName = "oxia-test-function-pulsarcluster" } ) -> null - dead_letter_topic = "public/default/dlt" -> null - disk_mb = 10240 -> null - forward_source_message_property = true -> null - id = "public/default/function1" -> null - inputs = [ - "persistent://public/default/test-java-input", ] -> null - jar = "function://public/default/exclamation@v0.1" -> null - log_topic = "public/default/lt" -> null - max_message_retries = 100 -> null - name = "function1" -> null - namespace = "default" -> null - output = "persistent://public/default/test-java-output" -> null - parallelism = 2 -> null - processing_guarantees = "ATLEAST_ONCE" -> null - ram_mb = 140 -> null - retain_key_ordering = true -> null - retain_ordering = false -> null - secrets = jsonencode( { - SECRET1 = { - key = "hello" - path = "sectest" } } ) -> null - skip_to_latest = true -> null - subscription_name = "test-sub" -> null - subscription_position = "Latest" -> null - tenant = "public" -> null - timeout_ms = 6666 -> null }Plan: 0 to add, 0 to change, 1 to destroy.Do you really want to destroy all resources? Terraform will destroy all your managed infrastructure, as shown above. There is no undo. Only 'yes' will be accepted to confirm. Enter a value: