Search This Blog

Saturday, June 1, 2019

k8s - Cheet Sheet


This is a work in progress

Storage:

Storage class:

Make a storage class non-default:

kubectl patch storageclass <your-class-name> -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"false"}}}'

Thursday, January 25, 2018

Linux: Add timestamp in history

  • Add the timestamp in history command (in ~/.bashrc):
export HISTTIMEFORMAT="%F %T : "
  437  2017-02-06 17:04:28 : history
  438  2017-02-06 17:05:09 : vi ~/.bashrc 
  439  2017-02-06 17:14:46 : history

Linux: Change your hostname

A few different ways are possible to change your hostname in linux.


  • With hostnamectl:
As root: 
[root@toolz ~]# hostnamectl set-hostname NEW-HOSTNAME

Then login/logout to see effects

Postgres: Install Postgresql-server 9.2 on Centos 7.2


  • You search for the package you'll want to install
  • [root@toolz ~]# yum search postgres|grep server

  • To get more details:
  • [root@toolz ~]# yum info postgresql-server.x86_64

  • Then install it:
  • [root@toolz ~]# yum install postgresql-server.x86_64

  • Setup the postgres password:
  • [root@toolz ~]# passwd postgres

  • Init the postgres first DB
  • [root@toolz ~]# sudo postgresql-setup initdb

  • Setup your connections:
  • [root@toolz ~]# sudo vi /var/lib/pgsql/data/pg_hba.conf

  • Start postgresql service
  • [root@toolz ~]# systemctl start postgresql

  • And finaly enable it to start automatically at next boot
  • [root@toolz ~]# systemctl enable postgresql


What to do next:
  • pg_hba.conf
  • create databases and users
  • postgresql-server logging

Thursday, January 11, 2018

Linux: apt





Common errors:

gpg: keyserver receive failed: No dirmngr

The error will look like:
root@deb15:~# apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 0DF731E45CE24F27EEEB1450EFDC8610341D9410
Executing: /tmp/apt-key-gpghome.CQvyuFwlWI/gpg.1.sh --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 0DF731E45CE24F27EEEB1450EFDC8610341D9410
gpg: failed to start the dirmngr '/usr/bin/dirmngr': No such file or directory
gpg: connecting dirmngr at '/tmp/apt-key-gpghome.CQvyuFwlWI/S.dirmngr' failed: No such file or directory
gpg: keyserver receive failed: No dirmngr


To fix it, just install dirmngr:
root@deb15:~# apt install dirmngr


Now, all's fine:
root@deb15:~# apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 0DF731E45CE24F27EEEB1450EFDC8610341D9410 Executing: /tmp/apt-key-gpghome.zspnEwdIk3/gpg.1.sh --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 0DF731E45CE24F27EEEB1450EFDC8610341D9410 gpg: key EFDC8610341D9410: public key "Spotify Public Repository Signing Key " imported gpg: Total number processed: 1 gpg: imported: 1

Wednesday, November 15, 2017

Linux: Create a bootable usb key

It's pretty simple and straight forward to create bootable USB on linux.

dd if=image.iso of=/dev/sdX bs=4M && sync


with:

  • if: Input FIle (your ISO)
  • of: Output File. /dev/sdX represent your USB key. Replace X with the letter of your volume (can be found with fdisk -l)
  • bs: Block Size
  • sync: make sure all data in buffer are written to disk 

Tuesday, November 14, 2017

Linux: Change your lost root password

Careful, this doesn't work on Centos 7

On startup, go to rescue mode. e to edit the line.

Add int=/bin/bash in the linux/kernel line (depending if you're using grub or grub2). Start it.
When on the command line, mount your file system and change your password:
# mount -o rw, remount /
# passwd
# touch / .autorelabel
# /sbin/reboot -f


Now, you have a new root password ;)