Deploy and expose a Function
Now that you've installed Kyma, let's deploy your first Function. We'll call it hello-world
.
Create a function
First, let's create the Function and apply it.
- Kyma Dashboard
- kubectl
- In Kyma Dashboard, go to the
default
Namespace.
- Go to Workloads > Functions.
- Click on Create Function.
Name the Function
hello-world
and click Create.
Verify the Function deployment
Now let's make sure that the Function has been deployed successfully.
- Kyma Dashboard
- kubectl
The operation was successful if the Function Status changed to RUNNING
.
NOTE: You might need to wait a few seconds for the status to change.
Expose the Function
After we've got our hello-world
Function deployed, we might want to expose it outside our cluster so that it's available for other external services.
First, let's create an APIRule for the Function.
- Kyma Dashboard
- kubectl
- Go to Discovery and Network > API Rules.
- Click on Create API Rule.
- Provide the Name (
hello-world
).
- From the Service Name dropdown, select
hello-world
.
Choose your host from the Host dropdown and replace the asterix (*) with the name of your subdomain (
hello-world
).
Verify the Function exposure
Now let's verify that the Function has been exposed successfully.
- Kyma Dashboard
- kubectl
In your Function's Configuration tab, click on the APIRule's Host. This opens the Function's external address as a new page.
NOTE: Alternatively, from the left navigation go to API Rules, and click on the Host URL there.
The operation was successful if the page says Hello World from the Kyma Function main running on nodejs14!
.