Skip to content

Commit

Permalink
Address PR review comments
Browse files Browse the repository at this point in the history
Signed-off-by: Vivek Singh <[email protected]>
  • Loading branch information
viveksyngh committed Aug 16, 2020
1 parent ed863d7 commit 1f7565b
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions _posts/2020-07-08-event-driven-functions-with-openfaas-and-nats.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,31 @@ There are several other connectors which allows you to trigger OpenFaaS function

![NATS Publish Subscribe](/images/2020-openfaas-nats/nats-publish-subscribe.png "https://docs.nats.io/nats-concepts/pubsub")

## Pre-requisite Installation
## Prerequisites

* [k3d](https://github.com/rancher/k3d) to create a [k3s](https://github.com/rancher/k3s) cluster. k3s is lightweight distribution of kubernetes from Rancher Labs.
* [arkade](https://github.com/alexellis/arkade) to install OpenFaaS, nats-connector, kubectl and faas-cl. `arkade` is simple CLI tool to install helm charts and apps to your cluster in one command.
Before we start we need a couple of tools to help us quickly set up our environment:

* [docker](https://docs.docker.com/get-docker/) - required to use KinD
* [kind](https://kind.sigs.k8s.io/docs/user/quick-start/) - a tool for running local Kubernetes clusters using Docker
* [arkade](https://github.com/alexellis/arkade) - official installer for OpenFaaS, that supports many other applications for Kubernetes

> Please make sure you have these tools installed before you proceed next.
## Install Components

#### Create a kubernetes cluster
#### Create cluster

`k3d` is a tool to run `k3s` in docker. Create a single node `k3s` cluster. You can also use other tools like [KinD](https://github.com/kubernetes-sigs/kind)
First thing we need is running Kubernetes cluster:

```
k3d create
```bash
kind create cluster
```

Follow instructions returned in the output of this command to configure KUBECONFIG to access the cluster using kubectl.
Wait for the installation to finish run this command to verify that the cluster is ready:

```bash
kubectl -n kube-system rollout status deployment/coredns
```

#### Install OpenFaaS
Install OpenFaaS using `arkade`
Expand Down Expand Up @@ -103,20 +110,13 @@ echo -n $PASSWORD | faas-cli login --username admin --password-stdin

`publish-message` function publishes message to nats-test topic.

Deploy `receive-message` function

```
faas-cli deploy --name receive-message --image openfaas/receive-message:latest \
--fprocess='./handler' --annotation topic="nats-test"
```
Deploy functions

Deploy `publish-message` function
```
faas-cli deploy --name publish-message --image openfaas/publish-message:latest \
--fprocess='./handler' --env nats_url=nats://nats.openfaas:4222
faas-cli deploy -f https://raw.githubusercontent.com/openfaas-incubator/nats-connector/master/contrib/test-functions/stack.yml --read-template=false
```

> Note: You can also build and deploy this function using the stack.yml and code present in nats-connector repository. But for simplicity, I am using pre built and published images of these functions.
> Note: You can also build and deploy this function using the stack.yml and code present in nats-connector repository. But for simplicity, I am using pre built and published images of these functions.
## Verify the installation
Invoke `publish-message` function to publish a test message
Expand All @@ -143,7 +143,7 @@ faas-cli logs receive-message
```

## What Next ?
* Do you have a cool "event driven" use case you want to share? Let us know and become a guest blogger!
* Do you have a cool "event-driven" use case you want to share? Let us know and become a guest blogger!

* If you are new to OpenFaaS, I would recommend you trying [OpenFaaS workshop](https://github.com/openfaas/workshop) .

Expand Down

0 comments on commit 1f7565b

Please sign in to comment.