#Kubeless - Deploying

The Serverless Framework was designed to provision your Kubeless Functions and Events. It does this via a couple of methods designed for different types of deployments.

#Deploy All

This is the main method for doing deployments with the Serverless Framework:

serverless deploy -v

Use this method when you have updated your Function, Event or Resource configuration in serverless.yml and you want to deploy that change (or multiple changes at the same time) to your Kubernetes cluster.

Note: You can specify a different configuration file name with the the --config option.

#How It Works

The Serverless Framework translates all syntax in serverless.yml to the Function object API calls to provision your Functions and Events.

For each function in your serverless.yml file, Kubeless will create an Kubernetes Function object and for each HTTP event, it will create a Kubernetes service.

For example, let's take the following example serverless.yml file:

service: new-project
  name: kubeless
  runtime: python2.7

  - serverless-kubeless

    handler: handler.hello

When deploying that file, the following objects will be created in your Kubernetes cluster:

$ kubectl get functions

hello     Function.v1.k8s.io
$ kubectl get all

NAME                       READY     STATUS    RESTARTS   AGE
po/hello-699783077-dk15r   1/1       Running   0          2m

svc/hello    <none>        8080/TCP   2m

deploy/hello   1         1         1            1           2m

NAME                 DESIRED   CURRENT   READY     AGE
rs/hello-699783077   1         1         1         2m

Kubeless will create a Kubernetes Deployment for your function and a Kubernetes service for each event.

Deployment will spin up a Pod) based on runtime you have defined in your serverless.yml. Runtime is a public docker image, providing only binaries for your code. Function code itself is injected into Pod by kubeless-controller-manager and stored in Kubernetes Function object definition.

Kubernetes Function definition has a size limit, since it is stored as yaml in cluster's etcd. So, you can't deploy function any larger than approximately 1.5MB.

In order to overcome this limitation, function code can be fetched from external url; in this case only link (and checksum) is stored in Kubernetes function definition. Starting from v0.8.0 of serverless-kubeless, you can change default deployment method to S3ZipContent and configure serverless-kubeless with S3 bucket, where the function code will be stored:

  name: kubeless
  runtime: python2.7
    strategy: S3ZipContent
      accessKeyId: minio
      secretAccessKey: minio123
      endpoint: http://minio.local
      bucket: workbench
      region: eu-central-1
      s3ForcePathStyle: true

#Deploy Function

This deployment method updates or deploys a single function. It performs the platform API call to deploy your package without the other resources. It is much faster than redeploying your whole service each time.

serverless deploy function --function myFunction


Check out the deploy command docs for all details and options.

Have questions?

Head over to the forums to search for your questions and issues or post a new one.