From 1f7565b05237ee902d11e585ccdf25a82591ae55 Mon Sep 17 00:00:00 2001 From: Vivek Singh Date: Mon, 17 Aug 2020 00:21:59 +0530 Subject: [PATCH] Address PR review comments Signed-off-by: Vivek Singh --- ...driven-functions-with-openfaas-and-nats.md | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/_posts/2020-07-08-event-driven-functions-with-openfaas-and-nats.md b/_posts/2020-07-08-event-driven-functions-with-openfaas-and-nats.md index 24a586d5..f74ecd7c 100644 --- a/_posts/2020-07-08-event-driven-functions-with-openfaas-and-nats.md +++ b/_posts/2020-07-08-event-driven-functions-with-openfaas-and-nats.md @@ -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` @@ -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 @@ -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) .