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
  1. In Kyma Dashboard, go to the default Namespace.
  1. Go to Workloads > Functions.
  1. Click on Create Function.
  1. 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.

CAUTION: Exposing a workload to the outside world is always a potential security vulnerability, so tread carefully. In a production environment, always secure the workload you expose with OAuth2 or JWT.

First, let's create an APIRule for the Function.

  • Kyma Dashboard
  • kubectl
  1. Go to Discovery and Network > API Rules.
  1. Click on Create API Rule.
  1. Provide the Name (hello-world).
  1. From the Service Name dropdown, select hello-world.
  1. 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!.