Photo by Filip Baotić on Unsplash
Today I decided to first take a small detour by learning about using Notion. Why? So that I can take better notes and share it with other people. I am really glad I did! Notion is the tool I have wanted all this time. Seriously give it a go.
In fact Notion is so good, that I am convinced it has just become my default note taking app as well as where I write my initial blog posts on.
Here is my Log book
Notion
Quick summary of what I discovered
- Block based editor
- Type / and then you can choose a block type (e.g. Heading 2, bullet list)
- Pages can have sub pages (infinitely)
- Highlight text to get a styling menu
- Blocks can be reordered by dragging the :: (well actually 6 dots)
- You can build templates to make it easier to add new pages
- Can do Kanban boards with the Task List template
- Has the concept of a Database view. Spreadsheets++
- Can import markdown, html, csv etc.
- Powerful Sharing and permissions are available
- Can Export to markdown, PDF etc. <— LOVE THIS!
Installing faas-cli on my Mac
First need to spin up the Ubuntu instance I created yesterday
$ multipass list
Name State IPv4 Image
faasd Stopped -- Ubuntu 20.04 LTS
[20:22:44]
$ multipass start faasd
Check the faas-cli documentation on various ways to install it. I prefer to use brew on my Mac so will be using brew
$ brew install faas-cli
Verify
$ faas-cli version
___ _____ ____
/ _ \ _ __ ___ _ __ | ___|_ _ __ _/ ___|
| | | | '_ \ / _ \ '_ \| |_ / _` |/ _` \___ \
| |_| | |_) | __/ | | | _| (_| | (_| |___) |
\___/| .__/ \___|_| |_|_| \__,_|\__,_|____/
|_|
CLI:
commit: 6b5e7a14a598527063c7c05fb4187739b6eb6d38
version: 0.13.6
The nice thing about multipass is that the instance will be restarted and still use the same IP address.
$ multipass list
Name State IPv4 Image
faasd Running 192.168.64.4 Ubuntu 20.04 LTS
10.62.0.1
You will need the password for the admin user to use with faas-cli
Following on from yesterday’s configuration I will be using SSH to connect to the instance.
$ ssh -i ~/.ssh/id_rsa -o PreferredAuthentications=publickey ubuntu@192.168.64.4
Cat out the password and save it somewhere locally on your computer. I am saving mine to "~/Learning/faasd/password.txt"
ubuntu@faasd:~$ sudo cat /var/lib/faasd/secrets/basic-auth-password ;echo
zI24jRLe45DhUPa21S6BoNy5q1DpYUb0FuDwlLfUoBNo6yaDBMZEPTO2W3K
Set the environment variable OPENFAAS_URL
so that faas-cli
knows where the faasd services is located. For now I will just enter this into the current terminal session but will add it to my zsh setup later.
export OPENFAAS_URL=http://192.168.64.4:8080
Setup faas-cli
to use the password.
cat password.txt | faas-cli login --username admin --password-stdin
Calling the OpenFaaS server to validate the credentials...
WARNING! You are not using an encrypted connection to the gateway, consider using HTTPS.
credentials saved for admin http://192.168.64.4:8080
Calling your FaaS
Yesterday I deployed the ASCII Cows function. So lets see if it is still available and if we can invoke it locally using faas-cli
First I consult the help to see if there is an easy way to list the available functions. Running faas-cli help
revealed that indeed it is as simple as just using the following.
$ faas-cli list
Function Invocations Replicas
cows 0 0
To get more information about the function
$ faas-cli describe cows
Name: cows
Status: Not Ready
Replicas: 0
Available replicas: 0
Invocations: 0
Image:
Function process: node show_cow.js
URL: http://192.168.64.4:8080/function/cows
Async URL: http://192.168.64.4:8080/async-function/cows
Labels:Annotations:%
Lets invoke it!
$ echo verbose | faas-cli invoke cows
(__)
(oo)
/-------\/
/ / \
* //------\\
^ ^
Cow jogging