profile for Gajendra D Ambi on Stack Exchange, a network of free, community-driven Q&A sites

Tuesday, June 23, 2020

Add kubernetes cluster to gitlab


  1. Create a serviceaccount for namespace kube-system (let us say gitlab is the name of the serviceaccount)
  2. kubectl -n kube-system get sa gitlab -o yaml
  3. You will find the token from the step 2. Let us say the name of that token is gitlab-token-5g769 kubectl -n kube-system get secret gitlab-token-5g769 -o yaml
  4. Decode the base 64 ca.crt value and then convert it to ca.pem, you can use openssl command line or some online converter
  5. Decode the token too using base 64
  6. Now offer the ca and pem values to gitlab during adding of k8s.


Wednesday, May 20, 2020

Preparing your kubernetes nodes

I often create, destroy, rebuild k8s nodes and I have noticed a few things which are a must. I personally use RKE to build, rebuild, reconfigure, configure these clusters but irrespective of that the list should apply to you too.
note: replace username ambi with whatever you like. The following list if for ubuntu 18+
1. create a new user called ambi and add him to sudo group.
2. log in as this user, install docker-ce by following the docker's official documentation. Add above user to docker group.
3. Make sure /etc/docker/certs.d/<myprivateregistry.com>/<myprivateregistry.com>.crt is present on all nodes
4. sudo chown <newly created user from step 1> /etc/docker
5. If you have storageclasses then make sure to have a default one.
kubectl patch storageclass <mystorageclassname> -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'

Thursday, March 5, 2020

MetalLB load balancer for your Rancher 2 Kubernetes cluster

It is fairly simple to setup a kubernetes baremetal cluster with rancher 2 which comes with all the bells and whistles. I however had some touch time in figuring out why I couldnt get the metallb load balaner working.
First setup your rancher 2 baremetal cluster.
Then go to
After this deploy the metallb on your kubernetes cluster as per
https://metallb.universe.tf/installation/
then deploy a configmap with an ip pool.

kubectl run nginx --image nginx
kubectl expose deployment nginx --type=LoadBalancer --name=nginx-service

Now you will see an exteranl IP from the metallb ip pool. You delete the service and metallb will reclaim it.

Wednesday, January 29, 2020

Clustering RabbitMQ on ubuntu 18.x

I am exploring a highly available, multi site, multi network rabbitmq server for what it does best.
3 VMs
ub1
ub2 
ub3
on KVM+kimchi virtualization setup.


sudo vim /etc/hosts
and update it with the details of all 3 nodes

192.x.y.z ub1
192.x.y.z ub2
192.x.y.z ub3

Install and Setup RabbitMQ on all

Copy paste the following on all 3 nodes.

sudo apt update
sudo apt upgrade
sudo apt install rabbitmq-server -y


sudo systemctl start rabbitmq-server
sudo systemctl enable rabbitmq-server

Plugins

sudo rabbitmq-plugins enable rabbitmq_management
sudo systemctl restart rabbitmq-server

Firewall

sudo ufw allow ssh
sudo ufw enable
sudo ufw allow 5672,15672,4369,25672/tcp
sudo ufw status

Clustering

So the erlang cookie used by rabbitmq should be same on all hosts/nodes. We can copy it from node1 to others via scp but we need to change the permissions on other nodes for this cookie so that you don't get permission denied error. Run the below command on ub2 & ub3.

sudo chmod 777 /var/lib/rabbitmq/.erlang.cookie

Run the following on ub1

scp /var/lib/rabbitmq/.erlang.cookie root@ub2:/var/lib/rabbitmq/
scp /var/lib/rabbitmq/.erlang.cookie root@ub3:/var/lib/rabbitmq/

Change back the permission on the cookie to be accessible only by the owner. Run the following on ub2,ub3.


sudo chmod 600 /var/lib/rabbitmq/.erlang.cookie
Again on ub2,ub3


sudo systemctl restart rabbitmq-server
sudo rabbitmqctl stop_app
sudo rabbitmqctl join_cluster rabbit@ub1
sudo rabbitmqctl start_app

User Setup

Run the following on ub1. This will create an admin user and deletes the guest user.


sudo rabbitmqctl add_user admin admin
sudo rabbitmqctl set_user_tags admin administrator
sudo rabbitmqctl set_permissions -p / admin ".*" ".*" ".*"
sudo rabbitmqctl delete_user guest

Run the following on ub2,ub3 to confirm that the clustering is working.

sudo rabbitmqctl cluster_status
sudo rabbitmqctl list_users

HA[Queue Mirroring]


sudo rabbitmqctl set_policy ha-all "." '{"ha-mode":"all"}'

Monday, November 4, 2019

Smartphones: Psychology of product design

A picture speaks louder than 1000 words.
Above is a size comparison of iphone 5, iphone 11 pro, google pixel 4 xl. 
How did they become so big?
Why did they become so big?
When did they become so big?
Who made them so big?
It was a gradual, progressive change by the manufacturers which no user asked for. How are they
justifying it? That is the main question.
This is how they normalized big phones.
  1. Same phone size but bigger screen (by reducing the bezel) to make us get used to the big screen
  2. New phone with the previous screen but with some added bezel on top and bottom
Repeat the steps 1,2.


Most often they say that to accommodate bigger battery we need bigger phones but we only need
bigger battery if we have a bigger phone which eats a lot of battery. Now let us come to the icon
placement of applications and OS (android, iOS).
Most use their phones with one hand and mainly and only they use thumb. If that is all you use then
you probably hate using a bigger phone and want a smaller phone, so they forced users to use two
hands by placing action items of OS and application at top and bottom, mostly top because if you hold
your phone from the bottom and if the action items are on top then you use other hand to activate them (by touch)
On top you have OS items like notification, settings etc.,. At the bottom you have some other stuff.
In the middle you just have empty space. What if all of it was at the bottom? Then you can use it with
just one hand and a thumb and realize that you don’t need a huge long phone. Why aren’t app
developers placing their action items all at bottom too? Well most app developers use templates
given by OS (apple iOS , google android) makers and these templates force you to have such layout. 

Psychology of a big phone

  1. If a phone is small and you are using it with only one hand then your other hand has something else or doing something else. Then you have two choices; Phone at hand 1 and something else at hand 2 (may be TV remote or a book). The chances of you leaving your phone for something else are now 50%. When the phone is big and you have to use both hands to use it then you have only 1 choice forward in your hand. Your phone. So the chances of you not leaving your phone for something else are reduced by 50%. 
  2. A smaller phone fits into your pockets and thus it is out of your sight. A bigger phone does not fit into your pocket, especially when you are sitting down, it presses against your thighs and makes it very uncomfortable. So at work or at home when you are sitting you take it out of your pocket and keep it in your hand. So a bigger phone essentially makes you to always hold it in your hands and keep it in your sight which exponentially increases the chance of you using it now since you are always seeing, touching and holding it.
  3. Across cultures humans have always joined their palms to show submission. Whether it is the namaste of hindus, budhists, jains, sikhs, the open palm towards the sky of muslims, or joining hands with crossed fingers for christians or any other faith. A bigger smartphone requires you to join your hands in similar fashion resembling as sign of submission to a higher being.