Getting Started with Nuclio on Minikube
Follow this step-by-step guide to set up Nuclio on Minikube, which is a single-node Kubernetes cluster that runs in a virtual machine (VM) on a local computer.
Prerequisites
Ensure that the following components are installed on your installation machine:
It’s recommended that you use these drivers:
- For Mac OS — hyperkit driver
- For Linux — virtualbox
Prepare Minikube
Start Minikube as you normally would. Note that the following command also enables role-based access control (RBAC) (which is disabled by default on Minikube version 0.24.1 and later) so that you can get more comfortable working with an RBAC-enabled Kubernetes cluster:
Mac OS
minikube start --vm-driver=hyperkit --extra-config=apiserver.authorization-mode=RBAC
Linux
minikube start --vm-driver=virtualbox --extra-config=apiserver.authorization-mode=RBAC
Set admin permissions: bypass Minikube configuration issues by giving cluster-admin permissions to the Kubernetes services, so that services such as kube-dns
can work in Minikube:
If you don’t want to elevate your Kubernetes services, run Minikube with RBAC disabled (omit
--extra-config
from minikube start
) and skip the RBAC related commands in the Nuclio installation instructions.kubectl apply -f https://raw.githubusercontent.com/nuclio/nuclio/master/hack/minikube/resources/kubedns-rbac.yaml
Bring up a Docker registry inside Minikube. You’ll later push your functions to this registry:
minikube ssh -- docker run -d -p 5000:5000 registry:2
Before container images can be pushed to your built-in registry, you need to add its address ($(minikube ip):5000
) to the list of insecure registries:
- Docker for Mac OS — you can add it under Preferences | Daemon.
- Linux: —follow the instructions in the Docker documentation.
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).
Create a Nuclio namespace by running the following command:
kubectl create namespace nuclio
Create the RBAC roles that are required for using Nuclio (provided you didn’t disable RBAC when preparing Minikube):
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 dashboard, among other resources:
kubectl apply -f https://raw.githubusercontent.com/nuclio/nuclio/master/hack/k8s/resources/nuclio.yaml
Use the command kubectl get pods --namespace nuclio
to verify both the controller and dashboard are running.
Forward the Nuclio dashboard port: the Nuclio dashboard publishes a service at port 8070. To use the dashboard, 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=dashboard -o jsonpath='{.items[0].metadata.name}') 8070:8070
Deploy a function with the Nuclio dashboard
Browse to http://localhost:8070
(after having forwarded this port as part of the Nuclio installation). You should see the Nuclio dashboard 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 Nuclio CLI (nuctl
) 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:
nuctl deploy helloworld -n nuclio -p https://raw.githubusercontent.com/nuclio/nuclio/master/hack/examples/golang/helloworld/helloworld.go --registry $(minikube ip):5000 --run-registry localhost:5000
- The
--registry
option defines the Docker registry onto which the function images that you build will be pushed. This is the registry that you previously brought up on your Minikube VM. - The
--registry-run
option defines the registry from which thekubelet
Kubernetes “node agent” will pull the function images. Because this operation occurs in the Minikube VM, the command specifieslocalhost
instead of the VM’s IP address.
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: