A local registry can save on bandwidth costs and means your OpenFaaS functions don't leave your local computer when running faas-cli up
Not only is it much quicker, but it's also simple to configure if you're using KinD.
Speech recognition is the process of converting audio into text. This is commonly used in voice assistants like Alexa, Siri, etc. Python provides an API called SpeechRecognition to allow us to convert audio into text for further processing.
- Py-dictionary returns meaning, synonyms, antonyms for a word (scraping dictionary.com) limit the no of results also get meaning, synonyms and antonyms in different color This module uses requests, bs4 and string-color modules and scraps dictionary.com How to use it.
- PyDictionary is a Dictionary Module for Python 2/3 to get meanings, translations, synonyms and Antonyms of words. It uses WordNet for getting meanings, Google for translations, and synonym.com.
- I'm looking for a list of German words in a digital format that is simple and easy to parse by a computer. It should encompass almost all words, but it doesn't matter whether inflections are includ.
- A dictionary is a collection which is unordered, changeable and indexed. In Python dictionaries are written with curly brackets, and they have keys and values.
Prerequisite:¶
You need to have Docker installed on your machine.
Install arkade¶
We will use arkade to install and deploy apps and services to Kubernetes.
arkade commands:
- use
arkade get
to download CLI tools and applications. - use
arkade install
to install applications using helm charts or vanilla YAML files. - use
arkade info
to get back info about an app you've installed
Install kubectl¶
kubectl is a command line tool that talks to the Kubernetes API for performing actions on our cluster.
Create the KinD cluster with a local registry enabled¶
We will set up our local Kubernetes cluster using KinD (Kubernetes in Docker).
Install KinD¶
These instructions are adapted from the KinD documentation. Our goal is to keep everything locally including a local Docker registry.
The official KinD docs provides a shell script to create a Kubernetes cluster with local Docker registry enabled.
View the shell script in the KinD docs
Note:¶
You can find similar solutions for other local Kubernetes distributions:
- k3d - local registries
- minikube - registry add-on
- microk8s - built-in registry
Make the script executable:
Run it to create your local cluster with registry:
Make sure the kubectl
context is set to the newly created cluster:
If the result is not kind-kind
then execute:
Make sure the cluster is running:
Make sure Docker registry is running.
Deploy OpenFaaS¶
Deploy OpenFaaS and its CLI:
Then log in and port-forward OpenFaaS using the instructions given, or run arkade info openfaas
to get them a second time.
Create a Function¶
We will take an example of a simple function; a dictionary that returns the meaning of word you query. We will be using the PyDictionary module for this setup.
Pull python language template from store:
We will be using the python3-flask-debian template.
Setup your OPENFAAS_PREFIX
variable to configure the address of your registry:
Note: Docker for Mac users may need to change 'localhost' to the IP address of their LAN or WiFi adapter as shown on ifconfig
such as 192.168.0.14
Create a new function using the template:
This will create a directory for your function and a YAML config file with the function name you provided:
- pydict/
- pydict.yml
Pydictionary List Of Words
Add dependency to the pydict/requirements.txt
file:
Pydictionary List Of Words
Update handler.py
with the following code.
Our minimal function is complete.
Stack file¶
You will see that the OpenFaaS stack YAML file pydict.yml
has localhost:5000
in its image destination.
Build Push Deploy¶
With our setup ready; we can now build our image, push it to the registry, and deploy it to Kubernetes. And using faas-cli
it is possible with a single command!
Test the function¶
Dictionary Of Dictionary Python
We can invoke our function from CLI using faas-cli
or curl
.
Python English Dictionary Module
Wrapping Up¶
Python English Dictionary Api
Now that you have a local registry, you can speed up your local development of functions by keeping the container images within your local computer.
This tutorial is based upon the KinD docs and a post by Yankee Maharjan.