Oct 20, 2022

Start MicroK8s with Multipass

This post is for me to learn how to create a highly available Kubernetes cluster using the MicroK8s and multipass.

Kubernetes clusters host containerised applications in a reliable and scalable way. Having DevOps in mind, Kubernetes makes maintenance tasks such as upgrades and security patching simple.

MicroK8s is a zero-ops, CNCF certified lightweight Kubernetes distribution for workstations, clusters, edge and IoT devices.

Again, the prerequisite is  there must be a working copy multipass, and I'm using WSL. 😎

Here are the setup configuration:

$ multipass launch --name kmaster -m 4G

$ multipass shell kmaster

ubuntu@kmaster:~$ sudo snap install microk8s --classic

ubuntu@kmaster:~$ sudo usermod -a -G microk8s ubuntu
ubuntu@kmaster:~$ sudo chown -f -R ubuntu ~/.kube

ubuntu@kmaster:~$ exit

$ multipass shell kmaster  

ubuntu@kmaster:~$ microk8s status --wait-ready

Next, let setup a second node:

$ multipass launch --name kworker1 -m 4G

$ multipass shell kworker1

ubuntu@kworker1:~$ sudo snap install microk8s --classic

ubuntu@kworker1:~$ sudo usermod -a -G microk8s ubuntu
ubuntu@kworker1:~$ sudo chown -f -R ubuntu ~/.kube

ubuntu@kworker1:~$ exit

$ multipass shell kworker1

ubuntu@kworker1:~$ microk8s status --wait-ready

 Both nodes are ready, let's join them:

$ multipass exec kmaster -- microk8s add-node

From the node you wish to join to this cluster, run the following:
microk8s join 172.22.71.179:25000/daaad28e6febfbdaa5e228479e5f3f7c/8ee2423760f2

Use the '--worker' flag to join a node as a worker not running the control plane, eg:
microk8s join 172.22.71.179:25000/daaad28e6febfbdaa5e228479e5f3f7c/8ee2423760f2 --worker

If the node you are adding is not reachable through the default interface you can use one of the following:
microk8s join 172.22.71.179:25000/daaad28e6febfbdaa5e228479e5f3f7c/8ee2423760f2

Copy the line (in bold) and paste to the second node (kworker), and wait for a few minutes.

Oct 19, 2022

Operation Hates Agile

Operation hates Agile. Why?

Simply because Agile is supposed to be moving fast and keep breaking things (for improvement).  With the fast pace of changing (in DevOps), it is impossible to get a stable and predictable metrics for operation teams.

Audit is another entity that similar to operation which hates Agile. 😜 Because by the time audit team finish the report, DevOps is already making 38 changes. 😅 

Conclusion, Agile is supposed to replace traditional operation, change management, and even audit.  

Question is, does the top management has the courage to replace the traditional operations (change management, audit) with Agile?

So if you want a successful Agile in your company:

Oct 18, 2022

Load-Balance with Nginx

Get inspired from the article How to Setup Nginx Reverse Proxy, I would like to challenge these with multipass + cloud-init to load balance for 3 backend servers.

In summary, we will create 4 instances of servers where 1 being the reverse-proxy and load-balancer role, and 3 being the backend web servers.

PS> multipass launch -n backend1 --cloud-init ci_backend1.yaml

PS> multipass launch -n backend2 --cloud-init ci_backend2.yaml

PS> multipass launch -n backend3 --cloud-init ci_backend3.yaml

PS> multipass launch -n lbr --cloud-init ci_lbr.yaml

Then point your browser (at host) to http://lbr.mshome.net/ and keep refresh. 😊

I took less than 8 minutes to start all the 4 instances of servers. All the necessary (4) files are stored at GitHub link below. Below are the screenshots.

16 Basic PowerShell Cmdlets

Get to know Windows PowerShell better with these 16 Best PowerShell Commands (Cmdlets) You Must Know.

Oct 16, 2022

Manually Install and configure Nginx with Multipass

Found a great tutorial site at Ubuntu.

Let me follow the tutorial to setup a Nginx web server with multipass.

$ multipass launch --name nginxweb -c 2 -m 2G

$ multipass shell nginxweb

ubuntu@nginxweb:~$ sudo apt update
ubuntu@nginxweb:~$ sudo apt install nginx 

ubuntu@nginxweb:~$ cd /var/www
ubuntu@nginxweb:~$ sudo mkdir tutorial
ubuntu@nginxweb:~$ cd tutorial
ubuntu@nginxweb:~$ sudo "${EDITOR:-vi}" index.html

Insert the following content and save index.html:

<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>Hello, Nginx!</title>
</head>
<body>
    <h1>Hello, Nginx!</h1>
    <p>We have just configured our Nginx web server on Ubuntu Server!</p>
</body>
</html>

Next, configure Nginx web to start a new web instance at port 81.

ubuntu@nginxweb:~$ cd /etc/nginx/sites-enabled
ubuntu@nginxweb:~$ sudo "${EDITOR:-vi}" tutorial

Again, insert the following content and save the tutorial file:

server {
       listen 81;
       listen [::]:81;

       server_name example.ubuntu.com;

       root /var/www/tutorial;
       index index.html;

       location / {
               try_files $uri $uri/ =404;
       }
}

Last, restart Nginx, and capture the IP address and make sure everything is working.

ubuntu@nginxweb:~$ sudo service nginx restart

ubuntu@nginxweb:~$ ip a 

Open the browser (at host) and point to http://<ip>:81/ and http://<ip>/

(All the works complete within 4 min at my laptop)


Link: