Menu

Dipesh Majumdar

Blog and Paintings

Difference between awk and cut

$ docker images |grep simplev01
dipeshm77-ubuntu                                        simplev01                e5337522d045        About an hour ago   210MB
ubuntu                                                  simplev01                e5337522d045        About an hour ago   210MB
dipeshm77/ubuntu                                        simplev01                e5337522d045        About an hour ago   210MB

In the above query result if i want only the image-id of docker we can use awk

$ docker images |grep simplev01 |awk -F ' ' '{print $3}'
e5337522d045
e5337522d045
e5337522d045

"cut -d" can also be tried but it doesn't give the desired result - 

$ docker images |grep simplev01 |cut -d ' ' -f 3

<<<<no output here... which is because of unnecessary spaces that spoils the show>>>>>>

Get rid of unnecessary spaces:
$ docker images |grep simplev01 | tr -s ' '
dipeshm77/ubuntu simplev01 e5337522d045 About an hour ago 210MB
dipeshm77-ubuntu simplev01 e5337522d045 About an hour ago 210MB
ubuntu simplev01 e5337522d045 About an hour ago 210MB

Now "cut -d" gives the desired result

$ docker images |grep simplev01 | tr -s ' '  |cut -d ' ' -f 3
e5337522d045
e5337522d045
e5337522d045

 

 

Push the docker images correctly

$ docker push dipeshm77-ubuntu:simplev01
The push refers to repository [docker.io/library/dipeshm77-ubuntu]
b5988e5ff900: Preparing
dc1f6fc414d9: Preparing
b57c79f4a9f3: Preparing
d60e01b37e74: Preparing
e45cfbc98a50: Preparing
762d8e1a6054: Waiting
denied: requested access to the resource is denied

This is because you have to align the image with your repository name before tagging...and this is how you do it...

docker tag dipeshm77-ubuntu:simplev01 dipeshm77/ubuntu:simplev01

$ docker push dipeshm77/ubuntu:simplev01
The push refers to repository [docker.io/dipeshm77/ubuntu]
b5988e5ff900: Pushed
dc1f6fc414d9: Pushed
b57c79f4a9f3: Pushed
d60e01b37e74: Pushed
e45cfbc98a50: Pushed
762d8e1a6054: Pushed
simplev01: digest: sha256:7f2980b027a24646a965e76e13fcba02fc0329764e08048dd2a97c39db051128 size: 1574

 

escape single quote and forward slash in sed command

Requirement is pretty simple - 

In my .gitlab-ci.yml file i need  this line - 

kubectl -n data-import logs ${WHICH_POD} --tail 40 |grep -v admin |grep -A6 add |grep true |awk -F ':' '{print $2}' |awk -F '}' '{print $1}' >ci/switched_true_false.txt

to be replaced by 

kubectl -n data-import logs ${WHICH_POD} --tail 40 |grep -v admin |grep -A6 add |grep true |awk -F ':' '{print $2}' |awk -F '}' '{print $1}' |uniq >ci/switched_true_false.txt

------------------

Definitely this can be done in many ways... but i was using sed command... and was already having a nightmare. So thought about creating a note in the vast ocean of internet with the hope that many be it helps someone....

the command used was:

cat  /tmp/.gitlab-ci.yml |sed 's/'\''{print \$1}'\'' >ci\/switched_true_false.txt/'\''{print \$1}'\'' |uniq >ci\/switched_true_false.txt/g' >/tmp/.gitlab-ci-new.yml

 

 

run bash commands with spaces on pod

You wanna run bash commands with spaces in a pod without entering the pod with the '-it'  , then you need to know this - 

kubectl -n some_namespace exec mysql-passbolt-blah-blah-somemoreblah --  bash -c 'ls -ltra'

note - in the above command - double quotes can also be used.

 

you might ask -
what's the use of this ...
well the answer is - suppose you want to take a backup of a database - some_database from a mysql pod directly in your local laptop from command prompt (for ex. git bash) this is how to do it -

 kubectl -n some_namespace exec mysql-passbolt-7b976cb4cf-qmx62 --  bash -c \
'mysqldump -u root -proot_password some_database > pb.sql'

 

now how to download this file from pod to your local laptop? that's a tricky one and i spent a lot of time hunting for the exact syntax - so pay attention here... note the file name provided in the below command doesn't have any forward slash to it even though inside pod it's absolute path is /  - that's the trick - the file should be successfully downloaded now to your local machine. 

kubectl cp some_namespace/mysql-passbolt-7b976cb4cf-qmx62:pb.sql /c/Users/dipes/scripts/tmp

 

all database backup(date-wise): 

kubectl cp some_namespace/mysql-passbolt-7b976cb4cf-qmx62:pb-$(date +%Y-%m-%d).sql /c/Users/dipes/scripts/tmp

 

 

Error: configmaps is forbidden: User "system:serviceaccount:kube-system:default" cannot list configmaps in the namespace "kube-system": Unknown user "system:serviceaccount:kube-system:default"

confronted with this error while helming...

 

$ helm ls
Error: configmaps is forbidden: User "system:serviceaccount:kube-system:default" cannot list configmaps in the namespace "kube-system": Unknown user "system:serviceaccount:kube-system:default"

 

 

remedy is this: 

first create a servieaccount by name tiller - > kubectl create serviceaccount --namespace kube-system tiller
create cluster rolebinding  -> kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller
patch deployment in ns kube-system -> kubectl patch deploy --namespace kube-system tiller-deploy -p '{"spec":{"template":{"spec":{"serviceAccount":"tiller"}}}}'      
helm init --service-account tiller --upgrade

 

Reflecting on 'being adult' on Dashami...

At a time when Durga Puja has remained a distant childhood memory, the advent of the special occassion or the end of the festivity has ceased to churn emotions of joy and sadness...
however i miss the innocent happiness of childhood in just being able to be part of the festivity.

Friends and family together...flocking around Goddess Durga... going out to see the different pandels in kolkata and staying awake the whole night... these used to mean a lot...

Quote from Eugene Ionesco very nicely illustrates this - 
The end of childhood is when things cease to astonish us.  When the world seems familiar, when one has got used to existence, one has become an adult.

Happy Durga Puja to all!

Sony WH-1000X M3 Headphone Review

Install helm client on windows

Latest release can be downloaded from here - 
https://github.com/helm/helm/releases

or if you want any particular version you need to go to the tag tab on the top left. 
and then select the required version and download. 

for exxamplem - 
https://github.com/helm/helm/releases/tag/v2.8.2
for v2.8.2

now after downloading it - extract with 7zip (or anyother software) and copy the location
of helm.exe and keep in in Path of environment variables from here - 
Control Panel -> System and Security -> System -> Advanced system settings -> Environment Variables

An opportunity may arise out of nowhere

My opponent had a rating of 1270 and mine was a mere 1130... i was skeptical - not sure of winning... however i didn't want to go down without a fight! I opened up my pieces with caution. I thought and analysed hard before my moves... and my opponent was taking  a lot of time to make his moves. As the clock ticked by...  i thought of taking a quick break and then return to the game. As I got back... suddenly, out of nowhere I spotted a great opportunity for a double attack. 

Well my bishop sitting at b7 was aiming at his rook on h1 (though there was a pawn as a cover).  Because my queen was at g5  so in the event of an exchange he might lose more - so to prevent that situation he moved his rook to g1. This gave me a glorious opportunity to eat his pawn with my queen at e3. now in order to come out of check - he had to lose his rook - there was simply no other way - and out of remorse he RESIGNED!

I learnt 2 lessons from this game:

1. Let your opponent be strong - it really doesn't matter - you play your role with an unperturbed mind and focus on your work at hand. There is no control that you have on the external factors - in this case the higher rating of my opponent. I really can't do much about it. So if i start giving it too much of an importance I will lose my own confidence and my focus. Rather I should remind myself that on many occasions I have won against a higher rated player. You never know - an opportunity may arise out of nowhere! 

2. Assign tasks/responsibilities to your team members that might trigger benefit somewhere else that you might never think of. Don't make them sit idle and do nothing. In this case my team member bishop forced my opponent to move his rook thereby enabling the double attack by my queen - my queen might take  credit - but it was the bishop that had caused it. It's because my bishop was assigned to take care of the longest diagonal of the chess board, i.e,the longest (read largest) responsibility.

 

adding git origin over command line (& faced with - fatal: remote origin already exists.)

dipes@LAPTOP-FEA1CJ5Q MINGW64 ~/gitlab_mz_content/someproject (master)
$ git remote add origin git@gitlab-domain-name.com:TamTam/someproject.git
fatal: remote origin already exists.

 

for the above error you need to remove origin and then add it... 

 

dipes@LAPTOP-FEA1CJ5Q MINGW64 ~/gitlab_mz_content/someproject (master)
$ git remote rm origin

dipes@LAPTOP-FEA1CJ5Q MINGW64 ~/gitlab_mz_content/someproject (master)
$ git remote add origin git@gitlab-domain-name.com:somegroup/someproject.git

dipes@LAPTOP-FEA1CJ5Q MINGW64 ~/gitlab_mz_content/someproject (master)
$ git remote -v
origin  git@gitlab-domain-name.com:somegroup/someprojecct.git (fetch)
origin  git@gitlab-domain-name.com:somegroup/someproject.git (push)

dipes@LAPTOP-FEA1CJ5Q MINGW64 ~/gitlab_mz_content/someproject (master)
$

LENOVO ideapad 530S Review

The eye that never blinks

How to post notification on slack channel with bash script

In order to do this first go to your slack channel (home page) and scroll down... if you look towards left bottom part you will see a link: APP

Click on that and then click on "view app directory"

Then click on button "get essential apps"

You can see a search place with a magnifying glass

Search "Incoming WebHooks" and then click on incoming webhooks

you are in the "incoming webhooks" home page now - here you can add a new configuration on a slack channel... you can also see existing configurations for the slack channel... here get the incoming webhook url by editing on the required configuration. 

Grab the incoming webhook url and use it to the members of slack channel with the required messages...

For example with http response code - 404/500... you can put the response in a variable and post the variable in the slack channel as an alert in this way - 

curl -X POST -H 'Content-type: application/json' --data '{"text":"ALERT!!! http response for POST </some/api/call/url> :'"$HTTP_RESPONSE"'"}' https://hooks.slack.com/services/ABCDKNWRG/PQRSABCDE/blahBLAHblahBLAHblah

 

Untitled_Artwork_asfe1239

I have lost count of the abstract head paintings and now I generate a 8 character random string as unique identifier... I thought that will make it much simpler to name these paintings...

kubectl basic commands

kubectl get <resource_name>

All the resources offered by k8s api can be queried and known by the simple kubectl get  command

these are - 

all
certificatesigningrequests csr
clusterrolebindings
clusterroles
componentstatuses cs
configmaps cm
controllerrevisions
cronjobs
customresourcedefinition crd, crds
daemonsets ds
deployments deploy
endpoints ep
events ev
horizontalpodautoscalers hpa
ingresses ing
jobs
limitranges limits
namespaces ns
networkpolicies netpol
nodes no
persistentvolumeclaims pvc
persistentvolumes pv
poddisruptionbudgets pdb
podpreset
pods po
podsecuritypolicies psp
podtemplates
replicasets rs
replicationcontrollers rc
resourcequotas quota
rolebindings
roles
secrets
serviceaccount sa
services svc
statefulsets sts
storageclasses sc
 
kubectl get no
 

[dipesh.majumdar@some-instance ~]$ kubectl get no -o wide
NAME            STATUS    ROLES     AGE       VERSION                   INTERNAL-IP     EXTERNAL-IP     OS-IMAGE             KERNEL-VERSION      CONTAINER-RUNTIME
10.175.135.91   Ready     <none>    9d        v1.9.8-2+af27ab4b096122   10.175.135.31   10.175.135.91   Ubuntu 16.04.4 LTS   4.4.0-127-generic   docker://17.6.2
10.175.135.93   Ready     <none>    9d        v1.9.8-2+af27ab4b096122   10.175.135.33   10.175.135.93   Ubuntu 16.04.4 LTS   4.4.0-127-generic   docker://17.6.2
10.175.135.98   Ready     <none>    9d        v1.9.8-2+af27ab4b096122   10.175.135.58   10.175.135.98   Ubuntu 16.04.4 LTS   4.4.0-127-generic   docker://17.6.2

 
[dipesh.majumdar@some-instance ~]$ kubectl get pv
NAME                                       CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS    CLAIM                                      STORAGECLASS       REASON    AGE
pvc-0e7ae29e-8119-11e8-80c5-4a1xy09543ad   20Gi       RWO            Delete           Bound     default/gitlab-gitlab-config-storage       ibmc-file-bronze             3d
............
..................
 
NAME                               STATUS    VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS       AGE
gitlab-gitlab-config-storage       Bound     pvc-0e7ae29e-8119-11e8-80c5-4a1xy09543ad   20Gi       RWO            ibmc-file-bronze   3d
.............
................
 
[dipesh.majumdar@demo-instance ~]$ kubectl get po
NAME                                       READY     STATUS    RESTARTS   AGE
gitlab-ee-nkbsm                            1/1       Running   0          6d
................
................................
 
 

 

no persistent volumes available for this claim and no storage class is set

that error is because storage class is properly not set...

one way of solving that is get the pvc yaml files from api, then delete the pvc, again create the pvc with the same yaml file... this might solve and you might see that error vanished if you do a kubectl describe pvc <pvc_name>

try your luck :-) for me it had solved... 

peaq laptop review

This laptop:  PEAQ PNB S2415-I5N1 is available in mediamarkt  Netherlands... 

One day while i was taking a casual look at all the laptops displayed in a mediamarkt store - i happened to see this big 15.6 inch laptop - immediately i started typing on it and found the kyeboard was actually very good to type on - and i found the display of the screen good too.... what more i came back - did some more research and decided to place an order online through the mediamarkt online store - 

The price is around 450 euro - I got some 50 euro discount without which it would have been 499 Euro I guess...

I bought it online from mediamarkt site on 27.may.2018 and got it on 28.may.2018 - fully sealed....

....Unboxed on 28.may.2018 and have been using ever since.  At 500 euro the specs are awesome and you can't get such quality at such a low price. the specs are give below - 

Operating System Windows 10 Home Resolution 1920 x 1080 Optical drive No Form Factor Fixed Screen Aspect Ratio 16: 9 LED backlight yes Screen size (inch) 15.6-inch Display size (cm) 39.6 cm Screen Diagonal (cm / inch) 39.6 cm / 15.6 inches Image resolution Full HD

Specs are as shown below...

Display: 15.6 inch (1920 x 1080) 
Processor: Intel Core i5-6200U 
RAM: 8 GB 
Storage: 128 GB eMMC + 1 TB HDD 
Graphics card: Intel HD Graphics 520

Now let me write the pros and cons - 

pros -

*****************************************************************************************

1. cheap price and fabulous quality

2. keyboard is nice and big - the keys have a nice responsive kick that i found very comfortable... i tried a few other expensive laptops but was massively disappointed by the key repsonse my fingers received... just to let you know - i just love to type and i type very fast and if i don't get a proper keyboard - no matter how impressive the other features are - it will be a big NO NO - but not with this laptop - i was impressed and still am after 30 odd days of rigorous use... a big thumbs up

3. display is quite good at this price...

4. pretty fast response time - switch it on and it doesn't take much time to come to life... its pretty fast

 *****************************************************************************************

cons -

1. Biggest disappointment is the battery - battery doesn't last that long and your power cable has to be somewhere near...

2. There is no indication of caps-lock - no way to know that your caps-lock is on or off - no light indicator on the Caps Key!

3. The DOT (or fullstop) key is very small and it's an irritation. Bad design!!!

4. Build quality of laptop is not good; screen looks very much vulnerable as the bezels are so weak and screen is wobbly/shaky if you just touch it gently... 

5. shift + right or left arrow - should selct the words - which doens't work at all and that's irritating... really really irritating...

*****************************************************************************************

FINAL VERDICT - considering that it is only 499 Euro and all the features it has - I would still recommend this... however if you can spend more - definitely go for a branded and better laptop with good build quality.

generate ssh keys in linux

[root@local-some-env ~]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:DS23JsXVJ0hS5PzpK3DfKsDIP0kvPO96lO5ABDIEFHA

root@local-some-env
The key's randomart image is:
+---[RSA 2048]----+
|      blah   |
|     blahhhh.  |
|      o o =.o  o |
|       . * o . . |
|        S+*   o  |
|      . +=+ ..   |
|     o = ..+ ... |
|      * =.  o ...|
|      .X=.   oo. |
+----[SHA256]-----+
[root@local-some-env ~]# ls -ltra /root/.ssh/
total 8
dr-xr-x---. 4 root root  136 Jun 28 14:30 ..
-rw-r--r--. 1 root root  406 Jun 28 14:30 id_rsa.pub
-rw-------. 1 root root 1679 Jun 28 14:30 id_rsa
drwx------. 2 root root   38 Jun 28 14:30 .
 

 

rhel vs centos - which one to choose

it's better to choose centos because it's not licensed  and you get the work done just as well as you would have on RHEL ...........................................................................................very little differences if at all there is any - BETWEEN CENTOS and RHEL....

Of course - dear reader, please don't quote me on this - and do your own piece of research... 

i am hoping that centos should be able to do your work without you needing to burn a hole in your pocket... 

so whenever you have the opportunity to launch an instance in cloud - for example in google cloud - choose the os image as centos - that way the monthly billing will be less.... very handy advise - for free - so go - enjoy!!!!!!!!!!!!!!!!!!!!

***************************for example uname -a output for centos can be -  3.10.0-862.3.2.el7.x86_64   

... well right now when i write this it is so - will change in future may be - things are changing fast - real real fast............................

Install Docker CE on RHEL

sudo yum install -y yum-utils device-mapper-persistent-data lvm2

sudo yum-config-manager --add-repo  https://download.docker.com/linux/centos/docker-ce.repo
adding repo from: https://download.docker.com/linux/centos/docker-ce.repo
grabbing file https://download.docker.com/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo

sudo yum-config-manager --enable docker-ce-edge
sudo yum-config-manager --enable docker-ce-test

You can disable the edge or test repository by running the yum-config-manager command with the --disable flag. To re-enable it, use the --enable flag. The following command disables the edge repository.

sudo yum-config-manager --disable docker-ce-edge
Note: Starting with Docker 17.06, stable releases are also pushed to the edge and test repositories.

sudo yum install docker-ce

install docker compose ->
sudo curl -L https://github.com/docker/compose/releases/download/1.21.2/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose

[root@local ~]# docker-compose --version
docker-compose version 1.21.2, build a133471
[root@local ~]#

**************beware of this error***************

Cannot connect to the Docker daemon at unix:///var/run/docker.sock

even after installing docker the above error might trouble you - so start the docker service to solve that - 

[dipesh.majumdar@some-instance ~]$ sudo service docker start
Redirecting to /bin/systemctl start docker.service
[dipesh.majumdar@some-instance ~]$ sudo service docker status
Redirecting to /bin/systemctl status docker.service
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)

docker process should be visible

ps -ef |grep docker
root     20724     1  0 23:04 ?        00:00:00 /usr/bin/dockerd
root     20730 20724  0 23:04 ?        00:00:00 docker-containerd --config /var/run/docker/containerd/containerd.toml
dipesh.+ 21186 20549  0 23:09 pts/1    00:00:00 grep --color=auto docker

..................................................

.....................................

View older posts »