Skip to content

Latest commit

 

History

History
92 lines (61 loc) · 5.03 KB

getting-started-k8s.md

File metadata and controls

92 lines (61 loc) · 5.03 KB

Getting Started with nuclio on Kubernetes

Follow this step-by-step guide to set up a nuclio development environment that uses a Kubernetes cluster.

In this document

Prerequisites

Before beginning with the installation, ensure that you have a Kubernetes v1.7 or later cluster and the credentials of a Docker registry, such as Docker Hub, Azure Container Registry (ACR), or Google Container Registry (GCR).

Install nuclio

At this stage you should have a functioning Kubernetes cluster, a Docker registry, and a working Kubernetes CLI (kubectl), and you can proceed to install the nuclio services on the cluster (i.e., deploy nuclio). For more information about kubectl, see the Kubernetes documentation.

Create a nuclio namespace by running the following command:

Note: All nuclio resources go into the "nuclio" namespace, and role-based access control (RBAC) is configured accordingly.

kubectl create namespace nuclio

Create a registry secret: because nuclio functions are images that need to be pushed and pulled to/from the registry, you need to create a secret that stores your registry credentials. Replace the <...> placeholders in the following commands with your username, password, and URL:

Note: If you want to use Docker Hub, the URL is registry.hub.docker.com.

read -s mypassword
<enter your password>

kubectl create secret docker-registry registry-credentials --namespace nuclio \
    --docker-username <username> \
    --docker-password $mypassword \
    --docker-server <URL> \
    --docker-email [email protected]

unset mypassword

Create the RBAC roles that are required for using nuclio:

Note: You are encouraged to look at the nuclio-rbac.yaml file that's used in the following command before applying it, so that you don't get into the habit of blindly running things on your cluster (akin to running scripts off the internet as root).

kubectl apply -f https://raw.githubusercontent.com/nuclio/nuclio/master/hack/k8s/resources/nuclio-rbac.yaml

Deploy nuclio to the cluster: the following command deploys the nuclio controller and playground, among other resources:

kubectl apply -f https://raw.githubusercontent.com/nuclio/nuclio/master/hack/k8s/resources/nuclio.yaml

Note: In this example, the nuclio playground service has full access to the local machine's Docker daemon. If you're concerned about the security implications, isolate the playground in its own node. The nuclio team is working with the community to establish a secure and robust on-cluster build mechanism.

Use the command kubectl get pods --namespace nuclio to verify both the controller and playground are running.

Forward the nuclio playground port: the nuclio playground publishes a service at port 8070. To use the playground, you first need to forward this port to your local IP address:

kubectl port-forward -n nuclio $(kubectl get pods -n nuclio -l nuclio.io/app=playground -o jsonpath='{.items[0].metadata.name}') 8070:8070

Deploy a function with the nuclio playground

Browse to http://localhost:8070 (after having forwarded this port as part of the nuclio installation). You should see the nuclio playground UI. Choose one of the built-in examples and click Deploy. The first build will populate the local Docker cache with base images and other files, so it might take a while, depending on your network. When the function deployment is completed, you can click Invoke to invoke the function with a body.

Deploy a function with the nuclio CLI (nuctl)

Start by downloading the latest version of the nuctl nuclio CLI for your platform, and then deploy the helloworld Go sample function. You can add the --verbose flag if you want to peek under the hood:

Note: If you are using Docker Hub, the URL here includes your username - registry.hub.docker.com/<username>.

nuctl deploy helloworld -n nuclio -p https://raw.githubusercontent.com/nuclio/nuclio/master/hack/examples/golang/helloworld/helloworld.go --registry <URL>

Then, invoke the function:

nuctl invoke -n nuclio helloworld

What's next?

See the following resources to make the best of your new nuclio environment: