Skip to content

Commit

Permalink
Docs: nuctl introduction made simple (+nuclio on docker) (#1708)
Browse files Browse the repository at this point in the history
  • Loading branch information
liranbg committed Jun 23, 2020
1 parent 8eed51f commit b8f0605
Show file tree
Hide file tree
Showing 5 changed files with 148 additions and 6 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ More examples can be found in the **[hack/examples](hack/examples/README.md)** N
## Further reading

- Setup
- [Getting Started with Nuclio on Docker](/docs/setup/docker/getting-started-docker.md)
- [Getting Started with Nuclio on Minikube](/docs/setup/minikube/getting-started-minikube.md)
- [Getting Started with Nuclio on Kubernetes](/docs/setup/k8s/getting-started-k8s.md)
- [Getting Started with Nuclio on Azure Kubernetes Service (AKS)](/docs/setup/aks/getting-started-aks.md)
Expand All @@ -173,6 +174,7 @@ More examples can be found in the **[hack/examples](hack/examples/README.md)** N
- Kubernetes
- [Invoking Functions by Name with a Kubernetes Ingress](/docs/concepts/k8s/function-ingress.md)
- References
- [Nuctl](/docs/reference/nuctl/nuctl.md)
- [Function-Configuration Reference](/docs/reference/function-configuration/function-configuration-reference.md)
- [Triggers](/docs/reference/triggers)
- [Runtime - .NET Core 3.1](/docs/reference/runtimes/dotnetcore/writing-a-dotnetcore-function.md)
Expand Down
3 changes: 1 addition & 2 deletions docs/concepts/best-practices-and-common-pitfalls.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ This guide aims to provide you with best practices for working with Nuclio and h

#### In this document

- [Use `init_context` instead of global variable declarations or function calls
](#init_context-instead-of-global-context)
- [Use `init_context` instead of global variable declarations or function calls](#init_context-instead-of-global-context)
- [Use HTTP clients over browsers for HTTP(s) tests](#http-clients-for-testing)
- [Tweak worker configurations to resolve unavailable-server errors](#tweak-worker-cfg-to-resolve-http-503-errors)
- [Install CA certificates for alpine with HTTPS](#ca-certificates-for-alpine-w-https)
Expand Down
48 changes: 48 additions & 0 deletions docs/reference/nuctl/nuctl.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Nuctl

#### In this document

- [About](#about)
- [Download](#download)
- [Usage](#usage)
- [Running platform](#running-platform)
- [Docker](#docker)
- [Kubernetes](#kubernetes)

## About

Nuctl is Nuclio's command-line interface that provides you with all the nuclio features, accessible from your terminal

## Download

To install Nuctl all you need to do, is simply visit Nuclio [releases page](https://github.com/nuclio/nuclio/releases)
and download the binary appropriate to your platform (e.g.: `darwin` if you have `macOS`)

You can use the following bash snippet to download the latest nuctl release
```bash
curl -s https://api.github.com/repos/nuclio/nuclio/releases/latest \
| grep -i "browser_download_url.*nuctl.*$(uname)" \
| cut -d : -f 2,3 \
| tr -d \" \
| wget -O nuctl -qi - && chmod +x nuctl
```

## Usage

Once downloaded, an informative help section is available using `nuctl --help`

## Running platform

Nuctl will automatically identify its running platform, whether it is Docker or Kubernetes.

To ensure you run Nuctl against a specific platform, use `--platform kube` for Kubernetes or `--platform local` for docker

### Docker

An example of function deployment using Nuctl against Docker can be found [here](/docs/setup/docker/getting-started-docker.md)

### Kubernetes

When running in Kubernetes, Nuctl would require you running a registry on your Kubernetes cluster and access to a `kubeconfig`

An example of function deployment using Nuctl against a Kubernetes cluster can be found [here](/docs/setup/k8s/getting-started-k8s.md#deploy-a-function-with-the-nuclio-cli-nuctl)
95 changes: 95 additions & 0 deletions docs/setup/docker/getting-started-docker.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# Getting Started with Nuclio on Docker

Follow this step-by-step guide to set up a Nuclio development environment that uses Docker

#### In this document

- [Prerequisites](#prerequisites)
- [Run Nuclio](#run-nuclio)
- [Deploy a function with the Nuclio dashboard](#deploy-a-function-with-the-nuclio-dashboard)
- [Deploy a function with the Nuclio CLI (nuctl)](#deploy-a-function-with-the-nuclio-cli-nuctl)
- [What's next](#whats-next)

## Prerequisites

Before beginning with the installation, ensure that you have a [Docker](https://docker.com) daemon running.

To ensure your Docker daemon is running properly, run `docker version` with the same user that will execute Nuctl commands

## Run Nuclio

To run nuclio on Docker, simply run the following command:

```bash
docker run \
--rm \
--detach \
--publish 8070:8070 \
--volume /var/run/docker.sock:/var/run/docker.sock \
--volume /tmp:/tmp \
--name nuclio-dashboard \
quay.io/nuclio/dashboard:stable-amd64
```

> NOTE: _stable_ tag refers to the latest version released by nuclio from `master` branch (unlike versioned branches, e.g.: 1.3.x)
Browse to `http://localhost:8070` to explore Nuclio

## Deploy a function with the Nuclio dashboard

Browse to `http://localhost:8070/projects/default/create-function`.
You should see the [Nuclio dashboard](/README.md#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)

Deploy an _HelloWorld_ example function by executing the following command:

```bash
nuctl deploy helloworld \
--path https://raw.githubusercontent.com/nuclio/nuclio/master/hack/examples/golang/helloworld/helloworld.go
```

Once function deployment is completed, You can get the function information by running:

```bash
nuctl get function helloworld
```

An example output:
```bash
NAMESPACE | NAME | PROJECT | STATE | NODE PORT | REPLICAS
nuclio | helloworld | default | ready | 42089 | 1/1
```

You can see from the example output that the deployed function `helloworld` is _running_ and using port `42089`.

To invoke the function, run

```bash
nuctl invoke helloworld --method POST --body '{"hello":"world"}' --content-type "application/json"
```

An example output:

```bash
> Response headers:
Server = nuclio
Date = Thu, 18 Jun 2020 06:56:27 GMT
Content-Type = application/text
Content-Length = 21

> Response body:
Hello, from Nuclio :]
```

## What's next?

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

- [Best Practices and Common Pitfalls](/docs/concepts/best-practices-and-common-pitfalls.md)
- [Deploying functions](/docs/tasks/deploying-functions.md)
- [More function examples](/hack/examples/README.md)
- [References](/docs/reference)
6 changes: 2 additions & 4 deletions docs/setup/k8s/getting-started-k8s.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ Browse to `http://localhost:8070` (after having forwarded this port as part of t

## Deploy a function with the Nuclio CLI (nuctl)

Start by [downloading](https://github.com/nuclio/nuclio/releases) 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:
> **Note:** If you are using Docker Hub, the URL here includes your username - `docker.io/<username>`.
Start by [downloading](/docs/reference/nuctl/nuctl.md#download) 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:

```sh
nuctl deploy helloworld -n nuclio -p https://raw.githubusercontent.com/nuclio/nuclio/master/hack/examples/golang/helloworld/helloworld.go --registry <URL>
Expand All @@ -90,5 +89,4 @@ See the following resources to make the best of your new Nuclio environment:
- [Invoking functions by name with an ingress](/docs/concepts/k8s/function-ingress.md)
- [More function examples](/hack/examples/README.md)
- [Running Nuclio in a production environment over Kubernetes](/docs/setup/k8s/running-in-production-k8s.md)
- [References](/docs/reference/)

- [References](/docs/reference)

0 comments on commit b8f0605

Please sign in to comment.