kind - local Kubernetes cluster using Docker container nodes

My environment Pop!_OS $ uname -a Linux system76 5.11.0-7620-generic #21~1624379747~20.10~3abeff8-Ubuntu SMP Wed Jun 23 02:23:59 UTC x86_64 x86_64 x86_64 GNU/Linux Set up pre-requirements for kind Install latest Go cd /usr/local/src sudo curl -L -O https://golang.org/dl/go1.16.5.linux-amd64.tar.gz tar -C /usr/local -xzf go1.16.5.linux-amd64.tar.gz export PATH=$PATH:/usr/local/go/bin /etc/profile PATH=/usr/local/go/bin:$PATH Rootless Docker Refer to my post. Install kubectl https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/#install-using-native-package-management sudo apt install -y apt-transport-https ca-certificates curl sudo curl -fsSLo /usr/share/keyrings/kubernetes-archive-keyring.gpg https://packages.cloud.google.com/apt/doc/apt-key.gpg echo "deb [signed-by=/usr/share/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.

Rootless Docker

My environment Pop!_OS $ uname -a Linux system76 5.11.0-7620-generic #21~1624379747~20.10~3abeff8-Ubuntu SMP Wed Jun 23 02:23:59 UTC x86_64 x86_64 x86_64 GNU/Linux Configure rootless Docker https://docs.docker.com/engine/security/rootless/ $ dockerd-rootless-setuptool.sh install [ERROR] Missing system requirements. Run the following commands to [ERROR] install the requirements and run this tool again. ########## BEGIN ########## sudo sh -eux <<EOF # Install newuidmap & newgidmap binaries apt-get install -y uidmap EOF ########## END ########## OK… Run the command above and try again.

Basic sort algorithms in Rust

Disclamer The implementations in this post have a lot of room for improvement. As of Apr. 2021, they are more like code monkey’s code :( Reverse a string fn main() { let s1 = String::from("Please reverse me with spaces!日本語.한국어"); println!("Original string: {}",s1); let mut s2 = String::from(""); for c in s1.chars().rev() { s2.push(c); } println!("Reversed: {}",s2); } In Rust, both String and a string slice &str are UTF-8 encoded. chars() returns an iterator over chars of a string slice.

Sonarqube

I tried SonarQube locally. Overview There are two servers. SonarQube and SonaScanner In this example, run SonarScanner with by CLI. The scan data will send to SonarQube. Getting started SonarQube (Docker) Run SonarQube on Docker: docker run -d --name sonarqube -p 9000:9000 sonarqube:8.9-community After that, Browse http://localhost:9000 Log in with admin/admin, and update your password Add a project, and get token. Project key: mytest Display name: MyTest Name of token: myToken Token (in my case): df19e6fee8433d746e65e0043976043fe059aa57 SonarScanner (Docker) Note the network of the SonarQube Docker container:

Custom configuration, and inject JavaScript in posts

Motivation To enable TikZ in my note, I add a header in layout/partial/header.html at first. But this change injects the javascript lines into all my posts which don’t need to include the TikZ. So I want to inject JavaScript in case that I mark the post as “TikZ enabled”. How to Create a HTML template In layouts/partials/header.html. {{ if and .IsPage (eq (.Param "tikz") true) }} <link rel="stylesheet" type="text/css" href="https://tikzjax.com/v1/fonts.css"> <script src="https://tikzjax.

Use Decorator in Python

Let’s grasp the concept of decorator in Python PEP 318 with short snippets. Step 1: Function as a parameter def f1(): print("Called f1.") def f2(f): f() f2(f1) # Called f1 f2 takes a function (object) as a parameter. Step 2: Wapping function def f1(fun): def wrap(): print("Start wrap") fun() print("End wrap") return wrap def f(): print("In function f") f1(f)() ### python test.py #Start wrap #In function f #End wrap Step 3: Use decorator def f1(fun): def wrap(): print("Start wrap") fun() print("End wrap") return wrap @f1 def f(): print("In function f") f() ### python test.

Rust Serverless (2021)

CAUTION (2022) The first virsion of this post was created in Apri 2021, but as of 2022, AWS officially released their SDK. This post (note) should be updated. Still there is no native run environment for Rust on AWS Lambda as of Jan.18.2022, so we still need to create a bootstrap executable. Getting started I followed the link. In this page, the author wrote details and it’s very educational. To remind the procedure, I left memo.

Quick Ansible test

This is memo when I want to run simple tasks quickly. Directory. $ tree . ├── ansible.cfg ├── hosts └── test.yml In hosts. [servers] server1.mydomain.com server2.mydomain.com server3.mydomain.com test.yml. - name: test-playbook hosts: servers tasks: - cron: name: "Add a cron when rebooting" special_time: reboot job: "echo $PATH" user: atlex00 ansible.cfg [defaults] host_key_checking = False deprecation_warnings=False Exec: ansible-playbook ./test.yml -i hosts -bD -C

Mutex

How to think Data race: an issue when data are accessible by multi-thread. How to solve? -> Locks, Mutual exclusion locks (a.k.a., Mutex locks) Mutex Mutex = Mutual exclution lock = a thread locks exclusively other threads until done. (Binary) Semaphor and Mutex https://stackoverflow.com/a/86021/9923806 Mutual exclusion semaphores are used to protect shared resources (data structure, file, etc..). A Binary semaphore should be used for Synchronization. Critical section https://en.wikipedia.org/wiki/Critical_section In concurrent programming, concurrent accesses to shared resources can lead to unexpected or erroneous behavior, so parts of the program where the shared resource is accessed need to be protected in ways that avoid the concurrent access.

NVM

What’s nvm Node.js Version Manager. Like pyenv in Python. One difference from Pyenv is, you can’t label a name to the environment. package.json manage the libraries. Install Follow the official document. https://github.com/nvm-sh/nvm curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash ..... (simple results) Check. $ nvm --version 0.39.0 $ node Command 'node' not found, but can be installed with: sudo apt install nodejs Install Node.js and switch versions # Current available Node.js on the local machine nvm ls # List all available versions nvm ls-remote # Use latest version nvm install node # "node" is an alias for the latest version nvm use node # Use speccific version nvm install 14.