Friday, July 24, 2020

Get Fun with Google Assistant

I first time read about it from Inquirer post of a Mod of Intercom device. And here is the Youtube clip: l
So I started to read about Google Assistant SDK. So basically there are two choices, based on what hardware platform you have: 1) with a Python-based library; 2) use gRPC API.
The Python lib option is a turnkey solution for anyone who wants to quickly integrate the Assistant into a prototype device. It supports linux-armv7l(include Raspberry Pi3) and linux-x86_64. gRPC is a modern open source high performance RPC framework that can run in any environment. It was initially created by Google, and was turned to open source in 2015.

For the Python solution, refer instruction here. If run into problem with 'python3 -m venv env', make sure the 'env' folder does not exist, also, refer to this stackoverflow post. If you already had done this step before, and want to upgrade, rename the old folder in case you have config/json file or code there, run the venv command, then copy over config file and your code after that.

Wednesday, July 22, 2020

学习舵轮(kubernetes)和埠(docker) - kind

Minikube and Kind are the two recommended by the official Kubernetes website.
Refer this for the comparison between minikube, kind and k3s. Here is a brief description of Kind:
Kind is another Kubernetes SIGs project but is quite different compared to minikube. As the name suggests it moves the cluster into Docker containers. This leads to a significantly faster startup speed compared to spawning VM.

For install, refer to https://kubernetes.io/docs/setup/learning-environment/kind/
On Linux, the simple way is to run below to download the single executable:
curl -Lo ./kind https://github.com/kubernetes-sigs/kind/releases/download/v0.7.0/kind-$(uname)-amd64
Change it to be executable and add it to path, all done. If like to learn about the hot 'Go', you can use Go to get it, and even build from source.
It has dependency of docker. To install docker: refer to this old post.
Or on Ubuntu, run: sudo apt install docker.io

To play with kind, need to install kubectl:
curl -LO https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/linux/amd64/kubectl
As kind Quick Start mentioned, after kind and kubectl installed, things can be tried are:
  • Creating a Kubernetes cluster is as simple as kind create cluster
  • List your kind clusters: kind get clusters
  • Interact with the created default cluster: kubectl cluster-info --context kind-kind
  • Delete cluster: kind delete cluster 
  • Load image to kind-2 cluster: kind load docker-image my-custom-image --name kind-2

When I  try to use my docker image (by running 'docker pull quyq/ifun:v0.3') to create cluster, I got error:

ERROR: failed to create cluster: failed to generate kubeadm config content: failed to get kubernetes version from node: failed to get file: command "docker exec --privileged kind-control-plane cat /kind/version" failed with error: exit status 1

This sounds like the same issue as kind issue 1288.  Run kind create cluster --image d7fe9f82ee94 -v 1 
shows: cat: can't open '/kind/version': No such file or directory
Per BenTheElder's comment, snap is in the known-issue document, the snap docker package
has a number of issues, e.g. no access to temp directories. I don't recommend snap for docker
and we don't really support this. Resolution was to install docker via apt-get detailed on their
page here. But for me I was usng the curl command installed kind, and even upgrade to version
0.8.1 doesn't help. I have no issue to create the cluster with default kindest/node image.  By
 checking this, turns out I need a customized docker image for kind.