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
- Prepare Minikube
- Install Nuclio
- Deploy a function with the Nuclio dashboard
- Deploy a function with the Nuclio CLI (nuctl)
- What's next
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
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:
Note: You are encouraged to look at the kubedns-rbac file that's used in the following command, and the RBAC configuration files used in the Nuclio installation section, before applying the files, 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).
If you don't want to elevate your Kubernetes services, run Minikube with RBAC disabled (omit--extra-config
fromminikube 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:
Note: You can skip this step if you're a more advanced user and would like to use another type of registry, such as Docker Hub, Azure Container Registry (ACR), or Google Container Registry (GCR). See Getting started with Kubernetes for instructions.
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.
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:
Note: All Nuclio resources go into the "nuclio" namespace, and role-based access control (RBAC) is configured accordingly.
kubectl create namespace nuclio
Create the RBAC roles that are required for using Nuclio (provided you didn't disable RBAC when preparing Minikube):
Note: As indicated in the Minikube preparation instructions, you are encouraged to look at the nuclio-rbac.yaml file that's used in the following command before applying it.
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
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.
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
Note: The difference between the two registries specified in this command and the reason for their addresses being different is as follows:
- 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
See the following resources to make the best of your new Nuclio environment: