Monday, June 14, 2021

SUDO + root/GUI utilities

In below example, a regular user is required to open "virt-manager" as root user but using sudo only.


bash-4.1$ ssh -X user1@server110

user1@server110's password: 

Last login: Mon Jun 14 22:27:41 2021 from xsjengvm209130.xilinx.com

[user1@server110 ~]$ 

[user1@server110 ~]$ xauth list

server110.xilinx.com/unix:11  MIT-MAGIC-COOKIE-1  136e42cdc96bbb1df129bdd21aa

server110.xilinx.com/unix:10  MIT-MAGIC-COOKIE-1  102f992984f06d2f91847ce5955

[user1@server110 ~]$ 

[user1@server110 ~]$ sudo xauth add server110.xilinx.com/unix:11  MIT-MAGIC-COOKIE-1  136e42cdc96bbb1df129bdd21aa

[user1@server110 ~]$ sudo xauth add server110.xilinx.com/unix:10  MIT-MAGIC-COOKIE-1  102f992984f06d2f91847ce5955

[user1@server110 ~]$ 

[user1@server110 ~]$ sudo virt-manager

[user1@server110 ~]$ 

Tuesday, April 13, 2021

Ansible - Installation on Ubuntu 18.04

 



root@host1:~# which ansible

root@host1:~# 


root@host1:~# apt update

Hit:1 http://localrepo.localdomain.com/ubuntu/dists/bionic  InRelease

Hit:2 http://localrepo.localdomain.com/ubuntu/releases/puppet/bionic  InRelease

Hit:3 http://localrepo.localdomain.com/ubuntu/releases/bionic-latest bionic-security InRelease

Hit:4 http://localrepo.localdomain.com/ubuntu/releases/18.04.5 bionic-updates InRelease

Hit:5 http://localrepo.localdomain.com/ubuntu/releases/18.04.5 bionic InRelease

Hit:6 http://archive.ubuntu.com/ubuntu bionic InRelease         

Get:7 http://archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]

Get:8 http://archive.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]

Get:9 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages [2,006 kB]

Get:10 http://archive.ubuntu.com/ubuntu bionic-updates/main i386 Packages [1,263 kB]

Get:11 http://archive.ubuntu.com/ubuntu bionic-updates/main Translation-en [406 kB]

Get:12 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 DEP-11 Metadata [295 kB]

Get:13 http://archive.ubuntu.com/ubuntu bionic-updates/universe amd64 Packages [1,729 kB]

Get:14 http://archive.ubuntu.com/ubuntu bionic-updates/universe i386 Packages [1,566 kB]

Get:15 http://archive.ubuntu.com/ubuntu bionic-updates/universe Translation-en [367 kB]

Get:16 http://archive.ubuntu.com/ubuntu bionic-updates/universe amd64 DEP-11 Metadata [290 kB]

Get:17 http://archive.ubuntu.com/ubuntu bionic-updates/multiverse amd64 DEP-11 Metadata [2,468 B]

Get:18 http://archive.ubuntu.com/ubuntu bionic-updates/restricted amd64 Packages [305 kB]

Get:19 http://archive.ubuntu.com/ubuntu bionic-updates/restricted Translation-en [41.3 kB]

Get:20 http://archive.ubuntu.com/ubuntu bionic-security/main i386 Packages [959 kB]

Get:21 http://archive.ubuntu.com/ubuntu bionic-security/main amd64 Packages [1,664 kB]

Get:22 http://archive.ubuntu.com/ubuntu bionic-security/main Translation-en [314 kB]

Get:23 http://archive.ubuntu.com/ubuntu bionic-security/main amd64 DEP-11 Metadata [49.0 kB]

Get:24 http://archive.ubuntu.com/ubuntu bionic-security/universe i386 Packages [980 kB]

Get:25 http://archive.ubuntu.com/ubuntu bionic-security/universe amd64 Packages [1,119 kB]

Get:26 http://archive.ubuntu.com/ubuntu bionic-security/universe Translation-en [252 kB]

Get:27 http://archive.ubuntu.com/ubuntu bionic-security/universe amd64 DEP-11 Metadata [60.3 kB]

Get:28 http://archive.ubuntu.com/ubuntu bionic-security/multiverse amd64 DEP-11 Metadata [2,464 B]

Get:29 http://archive.ubuntu.com/ubuntu bionic-security/restricted amd64 Packages [283 kB]

Get:30 http://archive.ubuntu.com/ubuntu bionic-security/restricted Translation-en [37.7 kB]

Fetched 14.2 MB in 10s (1,380 kB/s)                                                                                          

Reading package lists... Done

Building dependency tree       

Reading state information... Done

19 packages can be upgraded. Run 'apt list --upgradable' to see them.

root@host1:~# 

root@host1:~# apt install software-properties-common

Reading package lists... Done

Building dependency tree       

Reading state information... Done

software-properties-common is already the newest version (0.96.24.32.14).

0 upgraded, 0 newly installed, 0 to remove and 19 not upgraded.

root@host1:~# 

root@host1:~# apt-add-repository --yes --update ppa:ansible/ansible

Hit:1 http://localrepo.localdomain.com/ubuntu/dists/bionic  InRelease

Hit:2 http://localrepo.localdomain.com/ubuntu/releases/puppet/bionic  InRelease

Hit:3 http://localrepo.localdomain.com/ubuntu/releases/bionic-latest bionic-security InRelease

Hit:4 http://localrepo.localdomain.com/ubuntu/releases/18.04.5 bionic-updates InRelease

Hit:5 http://localrepo.localdomain.com/ubuntu/releases/18.04.5 bionic InRelease

Get:6 http://ppa.launchpad.net/ansible/ansible/ubuntu bionic InRelease [15.9 kB]                                 

Hit:7 http://archive.ubuntu.com/ubuntu bionic InRelease                                                          

Hit:8 http://archive.ubuntu.com/ubuntu bionic-updates InRelease                      

Hit:9 http://archive.ubuntu.com/ubuntu bionic-security InRelease

Get:10 http://ppa.launchpad.net/ansible/ansible/ubuntu bionic/main amd64 Packages [816 B]

Get:11 http://ppa.launchpad.net/ansible/ansible/ubuntu bionic/main i386 Packages [816 B]              

Get:12 http://ppa.launchpad.net/ansible/ansible/ubuntu bionic/main Translation-en [476 B]

Fetched 18.0 kB in 3s (6,092 B/s)                   

Reading package lists... Done

root@host1:~# 

root@host1:~# apt install ansible

Reading package lists... Done

Building dependency tree       

Reading state information... Done

The following additional packages will be installed:

  python-asn1crypto python-cffi-backend python-crypto python-cryptography python-enum34 python-httplib2 python-idna

  python-ipaddress python-jinja2 python-markupsafe python-paramiko python-pkg-resources python-setuptools python-six

  python-yaml sshpass

Suggested packages:

  python-crypto-doc python-cryptography-doc python-cryptography-vectors python-enum34-doc python-jinja2-doc python-gssapi

  python-setuptools-doc

The following NEW packages will be installed:

  ansible python-asn1crypto python-cffi-backend python-crypto python-cryptography python-enum34 python-httplib2 python-idna

  python-ipaddress python-jinja2 python-markupsafe python-paramiko python-pkg-resources python-setuptools python-six

  python-yaml sshpass

0 upgraded, 17 newly installed, 0 to remove and 19 not upgraded.

Need to get 7,392 kB of archives.

After this operation, 66.4 MB of additional disk space will be used.

Do you want to continue? [Y/n] Y

Get:1 http://localrepo.localdomain.com/ubuntu/releases/18.04.5 bionic/main amd64 python-markupsafe amd64 1.0-1build1 [13.0 kB]

Get:2 http://localrepo.localdomain.com/ubuntu/releases/bionic-latest bionic-security/main amd64 python-jinja2 all 2.10-1ubuntu0.18.04.1 [94.8 kB]

Get:3 http://localrepo.localdomain.com/ubuntu/releases/18.04.5 bionic/main amd64 python-yaml amd64 3.12-1build2 [115 kB]             

Get:4 http://localrepo.localdomain.com/ubuntu/releases/18.04.5 bionic/main amd64 python-asn1crypto all 0.24.0-1 [72.7 kB]            

Get:5 http://localrepo.localdomain.com/ubuntu/releases/18.04.5 bionic/main amd64 python-cffi-backend amd64 1.11.5-1 [63.4 kB]        

Get:6 http://localrepo.localdomain.com/ubuntu/releases/18.04.5 bionic/main amd64 python-enum34 all 1.1.6-2 [34.8 kB]                 

Get:7 http://localrepo.localdomain.com/ubuntu/releases/18.04.5 bionic/main amd64 python-idna all 2.6-1 [32.4 kB]                     

Get:8 http://localrepo.localdomain.com/ubuntu/releases/18.04.5 bionic/main amd64 python-ipaddress all 1.0.17-1 [18.2 kB]             

Get:9 http://localrepo.localdomain.com/ubuntu/releases/18.04.5 bionic/main amd64 python-six all 1.11.0-2 [11.3 kB]                   

Get:10 http://localrepo.localdomain.com/ubuntu/releases/bionic-latest bionic-security/main amd64 python-cryptography amd64 2.1.4-1ubuntu1.4 [276 kB]

Get:11 http://localrepo.localdomain.com/ubuntu/releases/bionic-latest bionic-security/main amd64 python-paramiko all 2.0.0-1ubuntu1.2 [110 kB]

Get:12 http://localrepo.localdomain.com/ubuntu/releases/18.04.5 bionic/main amd64 python-crypto amd64 2.6.1-8ubuntu2 [244 kB]        

Get:13 http://localrepo.localdomain.com/ubuntu/releases/18.04.5 bionic/main amd64 python-pkg-resources all 39.0.1-2 [128 kB]         

Get:14 http://localrepo.localdomain.com/ubuntu/releases/18.04.5 bionic/main amd64 python-setuptools all 39.0.1-2 [329 kB]

Get:15 http://localrepo.localdomain.com/ubuntu/releases/18.04.5 bionic/universe amd64 sshpass amd64 1.06-1 [10.5 kB]

Get:16 http://ppa.launchpad.net/ansible/ansible/ubuntu bionic/main amd64 ansible all 2.9.20-1ppa~bionic [5,804 kB]

Get:17 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 python-httplib2 all 0.9.2+dfsg-1ubuntu0.3 [34.9 kB]

Fetched 7,392 kB in 2s (4,867 kB/s)                                          

Selecting previously unselected package python-markupsafe.

(Reading database ... 350454 files and directories currently installed.)

Preparing to unpack .../00-python-markupsafe_1.0-1build1_amd64.deb ...

Unpacking python-markupsafe (1.0-1build1) ...

Selecting previously unselected package python-jinja2.

Preparing to unpack .../01-python-jinja2_2.10-1ubuntu0.18.04.1_all.deb ...

Unpacking python-jinja2 (2.10-1ubuntu0.18.04.1) ...

Selecting previously unselected package python-yaml.

Preparing to unpack .../02-python-yaml_3.12-1build2_amd64.deb ...

Unpacking python-yaml (3.12-1build2) ...

Selecting previously unselected package python-asn1crypto.

Preparing to unpack .../03-python-asn1crypto_0.24.0-1_all.deb ...

Unpacking python-asn1crypto (0.24.0-1) ...

Selecting previously unselected package python-cffi-backend.

Preparing to unpack .../04-python-cffi-backend_1.11.5-1_amd64.deb ...

Unpacking python-cffi-backend (1.11.5-1) ...

Selecting previously unselected package python-enum34.

Preparing to unpack .../05-python-enum34_1.1.6-2_all.deb ...

Unpacking python-enum34 (1.1.6-2) ...

Selecting previously unselected package python-idna.

Preparing to unpack .../06-python-idna_2.6-1_all.deb ...

Unpacking python-idna (2.6-1) ...

Selecting previously unselected package python-ipaddress.

Preparing to unpack .../07-python-ipaddress_1.0.17-1_all.deb ...

Unpacking python-ipaddress (1.0.17-1) ...

Selecting previously unselected package python-six.

Preparing to unpack .../08-python-six_1.11.0-2_all.deb ...

Unpacking python-six (1.11.0-2) ...

Selecting previously unselected package python-cryptography.

Preparing to unpack .../09-python-cryptography_2.1.4-1ubuntu1.4_amd64.deb ...

Unpacking python-cryptography (2.1.4-1ubuntu1.4) ...

Selecting previously unselected package python-paramiko.

Preparing to unpack .../10-python-paramiko_2.0.0-1ubuntu1.2_all.deb ...

Unpacking python-paramiko (2.0.0-1ubuntu1.2) ...

Selecting previously unselected package python-httplib2.

Preparing to unpack .../11-python-httplib2_0.9.2+dfsg-1ubuntu0.3_all.deb ...

Unpacking python-httplib2 (0.9.2+dfsg-1ubuntu0.3) ...

Selecting previously unselected package python-crypto.

Preparing to unpack .../12-python-crypto_2.6.1-8ubuntu2_amd64.deb ...

Unpacking python-crypto (2.6.1-8ubuntu2) ...

Selecting previously unselected package python-pkg-resources.

Preparing to unpack .../13-python-pkg-resources_39.0.1-2_all.deb ...

Unpacking python-pkg-resources (39.0.1-2) ...

Selecting previously unselected package python-setuptools.

Preparing to unpack .../14-python-setuptools_39.0.1-2_all.deb ...

Unpacking python-setuptools (39.0.1-2) ...

Selecting previously unselected package sshpass.

Preparing to unpack .../15-sshpass_1.06-1_amd64.deb ...

Unpacking sshpass (1.06-1) ...

Selecting previously unselected package ansible.

Preparing to unpack .../16-ansible_2.9.20-1ppa~bionic_all.deb ...

Unpacking ansible (2.9.20-1ppa~bionic) ...

Setting up python-idna (2.6-1) ...

Setting up python-yaml (3.12-1build2) ...

Setting up python-asn1crypto (0.24.0-1) ...

Setting up python-crypto (2.6.1-8ubuntu2) ...

Setting up python-pkg-resources (39.0.1-2) ...

Setting up python-markupsafe (1.0-1build1) ...

Setting up python-httplib2 (0.9.2+dfsg-1ubuntu0.3) ...

Setting up python-cffi-backend (1.11.5-1) ...

Setting up python-six (1.11.0-2) ...

Setting up sshpass (1.06-1) ...

Setting up python-enum34 (1.1.6-2) ...

Setting up python-ipaddress (1.0.17-1) ...

Setting up python-setuptools (39.0.1-2) ...

Setting up python-jinja2 (2.10-1ubuntu0.18.04.1) ...

Setting up python-cryptography (2.1.4-1ubuntu1.4) ...

Setting up python-paramiko (2.0.0-1ubuntu1.2) ...

Setting up ansible (2.9.20-1ppa~bionic) ...

Processing triggers for man-db (2.8.3-2ubuntu0.1) ...

root@host1:~# 

root@host1:~# which ansible

/usr/bin/ansible

root@host1:~# 

root@host1:~# 


Monday, April 12, 2021

LVM Volumes Resize - Increase and decrease example (rootvol)

 


#########################################################################################################################

#

#                                LVM - SHRINKING A VOLUME AND EXT4 FILESYSTEM 

#

#########################################################################################################################



root@system1:~# df -h /scratch

Filesystem                  Size  Used Avail Use% Mounted on

/dev/mapper/vg00-scratchlv   74G   53M   70G   1% /scratch


root@system1:~# umount /scratch


root@system1:~# e2fsck -f  /dev/mapper/vg00-scratchlv

e2fsck 1.44.1 (24-Mar-2018)

Pass 1: Checking inodes, blocks, and sizes

Pass 2: Checking directory structure

Pass 3: Checking directory connectivity

Pass 4: Checking reference counts

Pass 5: Checking group summary information

/dev/mapper/vg00-scratchlv: 12/4898816 files (0.0% non-contiguous), 451906/19589120 blocks

root@system1:~# 


root@system1:~# resize2fs /dev/mapper/vg00-scratchlv 1G

resize2fs 1.44.1 (24-Mar-2018)

Resizing the filesystem on /dev/mapper/vg00-scratchlv to 262144 (4k) blocks.

The filesystem on /dev/mapper/vg00-scratchlv is now 262144 (4k) blocks long.



root@system1:~# lvreduce -L 1G /dev/mapper/vg00-scratchlv

  WARNING: Reducing active logical volume to 1.00 GiB.

  THIS MAY DESTROY YOUR DATA (filesystem etc.)

Do you really want to reduce vg00/scratchlv? [y/n]: y

  Size of logical volume vg00/scratchlv changed from <74.73 GiB (19130 extents) to 1.00 GiB (256 extents).

  Logical volume vg00/scratchlv successfully resized.

root@system1:~# 


root@system1:~# e2fsck -f  /dev/mapper/vg00-scratchlv

e2fsck 1.44.1 (24-Mar-2018)

Pass 1: Checking inodes, blocks, and sizes

Pass 2: Checking directory structure

Pass 3: Checking directory connectivity

Pass 4: Checking reference counts

Pass 5: Checking group summary information

/dev/mapper/vg00-scratchlv: 12/65536 files (0.0% non-contiguous), 140322/262144 blocks


 

root@system1:~# mount /scratch

root@system1:~# df -h /scratch

Filesystem                  Size  Used Avail Use% Mounted on

/dev/mapper/vg00-scratchlv  496M   21M  409M   5% /scratch

 


#########################################################################################################################

#

#                                LVM - EXPANDING A VOLUME AND EXT4 FILESYSTEM 

#

#########################################################################################################################



root@system1:~# df -h /

Filesystem               Size  Used Avail Use% Mounted on

/dev/mapper/vg00-rootlv   19G   18G     0 100% /

 

root@system1:~# blkid /dev/mapper/vg00-rootlv

/dev/mapper/vg00-rootlv: UUID="5f562e25-6fa0-4cea-8058-6506dbc1dfde" TYPE="ext4"


 

root@system1:~# pvs

  PV         VG   Fmt  Attr PSize   PFree  

  /dev/sda6  vg00 lvm2 a--  <99.52g <73.73g


 

root@system1:~# vgs

  VG   #PV #LV #SN Attr   VSize   VFree  

  vg00   1   4   0 wz--n- <99.52g <73.73g


 

root@system1:~# lvs

  LV        VG   Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert

  rootlv    vg00 -wi-ao---- 19.07g                                                    

  scratchlv vg00 -wi-ao----  1.00g                                                    

  swaplv    vg00 -wi-ao---- <1.91g                                                    

  tmplv     vg00 -wi-ao----  3.81g                                                    

root@system1:~# 


root@system1:~# lvextend -l +100%FREE /dev/mapper/vg00-rootlv

  Size of logical volume vg00/rootlv changed from 19.07 GiB (4882 extents) to <92.80 GiB (23756 extents).

  Logical volume vg00/rootlv successfully resized.

 

root@system1:~# df -h /

Filesystem               Size  Used Avail Use% Mounted on

/dev/mapper/vg00-rootlv   19G   18G     0 100% /


root@system1:~# resize2fs /dev/mapper/vg00-rootlv

resize2fs 1.44.1 (24-Mar-2018)

Filesystem at /dev/mapper/vg00-rootlv is mounted on /; on-line resizing required

old_desc_blocks = 3, new_desc_blocks = 12

The filesystem on /dev/mapper/vg00-rootlv is now 24326144 (4k) blocks long.


root@system1:~# df -h /

Filesystem               Size  Used Avail Use% Mounted on

/dev/mapper/vg00-rootlv   92G   18G   70G  21% /

root@system1:~# 


root@system1:~# lvs

  LV        VG   Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert

  rootlv    vg00 -wi-ao---- <92.80g                                                    

  scratchlv vg00 -wi-ao----   1.00g                                                    

  swaplv    vg00 -wi-ao----  <1.91g                                                    

  tmplv     vg00 -wi-ao----   3.81g                                                    




Tuesday, March 23, 2021

Kubernetes up and running in less than 30 minutes!

The process of running Kubernetes is very simple. All we need is a Ubuntu system. 

These notes are taken using an Ubuntu 18.04.5 system with updated repo and latest patch installed. 

This is a result of following step by step instructions at https://ubuntu.com/tutorials/install-a-local-kubernetes-with-microk8s#1-overview



bash-4.1$ ssh automata
Welcome to Ubuntu 18.04.5 LTS (GNU/Linux 4.15.0-139-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

  System information as of Tue Mar 23 15:33:21 PDT 2021

  System load:  2.79               Processes:           267
  Usage of /:   52.1% of 18.65GB   Users logged in:     0
  Memory usage: 6%                 IP address for eth0: 10.17.14.36
  Swap usage:   0%

 * Introducing self-healing high availability clusters in MicroK8s.
   Simple, hardened, Kubernetes for production, from RaspberryPi to DC.

     https://microk8s.io/high-availability

 * Canonical Livepatch is available for installation.
   - Reduce system reboots and improve kernel security. Activate at:
     https://ubuntu.com/livepatch

0 packages can be updated.
0 of these updates are security updates.


The use of this system is restricted to authorized persons only.  All others will be prosecuted to the full extent of the law.

Last login: Mon Mar 22 20:32:29 2021 from 172.19.223.120
$ sudo su -

We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:

    #1) Respect the privacy of others.
    #2) Think before you type.
    #3) With great power comes great responsibility.

Password: 
root@automata:~# 
root@automata:~# 
root@automata:~# 
root@automata:~# 
root@automata:~# snap install microk8s --classic
2021-03-23T15:37:55-07:00 INFO Waiting for automatic snapd restart...
microk8s (1.20/stable) v1.20.4 from Canonical✓ installed
root@automata:~# 

root@automata:~# ps -eaf | grep -i k8
root      4293     1  0 15:42 ?        00:00:00 /bin/bash /snap/microk8s/2074/control-plane-kicker
root      4328     1  0 15:42 ?        00:00:10 /bin/bash /snap/microk8s/2074/apiservice-kicker
root      4422     1  0 15:42 ?        00:00:00 /bin/bash /snap/microk8s/2074/run-cluster-agent-with-args
root      4498  4293  0 15:42 ?        00:00:21 /snap/microk8s/2074/usr/bin/python3 /snap/microk8s/2074/scripts/wrappers/control-plane-kicker.py
root      4575  4422  0 15:42 ?        00:00:04 python3 /snap/microk8s/2074/usr/bin/gunicorn3 cluster.agent:app --bind 0.0.0.0:25000 --keyfile /var/snap/microk8s/2074/certs/server.key --certfile /var/snap/microk8s/2074/certs/server.crt --timeout 240
root      4975  4575  0 15:42 ?        00:00:01 python3 /snap/microk8s/2074/usr/bin/gunicorn3 cluster.agent:app --bind 0.0.0.0:25000 --keyfile /var/snap/microk8s/2074/certs/server.key --certfile /var/snap/microk8s/2074/certs/server.crt --timeout 240
root      6653     1  1 15:43 ?        00:02:05 /snap/microk8s/2074/bin/containerd --config /var/snap/microk8s/2074/args/containerd.toml --root /var/snap/microk8s/common/var/lib/containerd --state /var/snap/microk8s/common/run/containerd --address /var/snap/microk8s/common/run/containerd.sock
root      6793     1 15 15:43 ?        00:26:53 /snap/microk8s/2074/kube-apiserver --cert-dir=/var/snap/microk8s/2074/certs --service-cluster-ip-range=10.152.183.0/24 --authorization-mode=AlwaysAllow --service-account-key-file=/var/snap/microk8s/2074/certs/serviceaccount.key --client-ca-file=/var/snap/microk8s/2074/certs/ca.crt --tls-cert-file=/var/snap/microk8s/2074/certs/server.crt --tls-private-key-file=/var/snap/microk8s/2074/certs/server.key --kubelet-client-certificate=/var/snap/microk8s/2074/certs/server.crt --kubelet-client-key=/var/snap/microk8s/2074/certs/server.key --secure-port=16443 --token-auth-file=/var/snap/microk8s/2074/credentials/known_tokens.csv --insecure-port=0 --storage-backend=dqlite --storage-dir=/var/snap/microk8s/2074/var/kubernetes/backend/ --allow-privileged=true --service-account-issuer=https://kubernetes.default.svc --service-account-signing-key-file=/var/snap/microk8s/2074/certs/serviceaccount.key --feature-gates=RemoveSelfLink=false --requestheader-client-ca-file=/var/snap/microk8s/2074/certs/front-proxy-ca.crt --requestheader-allowed-names=front-proxy-client --requestheader-extra-headers-prefix=X-Remote-Extra- --requestheader-group-headers=X-Remote-Group --requestheader-username-headers=X-Remote-User --proxy-client-cert-file=/var/snap/microk8s/2074/certs/front-proxy-client.crt --proxy-client-key-file=/var/snap/microk8s/2074/certs/front-proxy-client.key
root      6894     1  0 15:43 ?        00:00:03 /snap/microk8s/2074/kube-proxy --kubeconfig=/var/snap/microk8s/2074/credentials/proxy.config --cluster-cidr=10.1.0.0/16 --healthz-bind-address=127.0.0.1
root      7017     1  2 15:43 ?        00:05:01 /snap/microk8s/2074/kubelet --kubeconfig=/var/snap/microk8s/2074/credentials/kubelet.config --cert-dir=/var/snap/microk8s/2074/certs --client-ca-file=/var/snap/microk8s/2074/certs/ca.crt --anonymous-auth=false --network-plugin=cni --root-dir=/var/snap/microk8s/common/var/lib/kubelet --fail-swap-on=false --cni-conf-dir=/var/snap/microk8s/2074/args/cni-network/ --cni-bin-dir=/var/snap/microk8s/2074/opt/cni/bin/ --feature-gates=DevicePlugins=true --eviction-hard=memory.available<100Mi,nodefs.available<1Gi,imagefs.available<1Gi --container-runtime=remote --container-runtime-endpoint=/var/snap/microk8s/common/run/containerd.sock --containerd=/var/snap/microk8s/common/run/containerd.sock --node-labels=microk8s.io/cluster=true --authentication-token-webhook=true
root      7304     1  0 15:43 ?        00:00:33 /snap/microk8s/2074/kube-scheduler --kubeconfig=/var/snap/microk8s/2074/credentials/scheduler.config --address=127.0.0.1
root      7351     1  2 15:43 ?        00:03:59 /snap/microk8s/2074/kube-controller-manager --kubeconfig=/var/snap/microk8s/2074/credentials/controller.config --service-account-private-key-file=/var/snap/microk8s/2074/certs/serviceaccount.key --root-ca-file=/var/snap/microk8s/2074/certs/ca.crt --cluster-signing-cert-file=/var/snap/microk8s/2074/certs/ca.crt --cluster-signing-key-file=/var/snap/microk8s/2074/certs/ca.key --address=127.0.0.1 --use-service-account-credentials
root      7565     1  0 15:44 ?        00:00:00 /snap/microk8s/2074/bin/containerd-shim-runc-v1 -namespace k8s.io -id 1ed00a8fc04726723b38d4ec6bb5d8713971dca1d207cad187df52570b7323e8 -address /var/snap/microk8s/common/run/containerd.sock
root      7765     1  0 15:44 ?        00:00:00 /snap/microk8s/2074/bin/containerd-shim-runc-v1 -namespace k8s.io -id 31fff9ce896973c6ff1361d2b4c1e71ef15f5cb9e2e12a9c3ab41709237cff1b -address /var/snap/microk8s/common/run/containerd.sock
root      8088     1  0 15:44 ?        00:00:47 /snap/microk8s/2074/bin/containerd-shim-runc-v1 -namespace k8s.io -id c95e1c0ca506dfc04a75d02bc96b2ad2a3546bfd86eddfa5b0bcfe204d90d068 -address /var/snap/microk8s/common/run/containerd.sock
root      8258     1  0 15:44 ?        00:00:13 /snap/microk8s/2074/bin/containerd-shim-runc-v1 -namespace k8s.io -id c451c511aa4214c9bfa2d482b5344400c8dd70742d643d83b89405b5a23db7bb -address /var/snap/microk8s/common/run/containerd.sock
root     31031  2789  0 18:39 pts/0    00:00:00 grep --color=auto -i k8
root@automata:~# 


root@automata:~# snap info microk8s
name:      microk8s
summary:   Lightweight Kubernetes for workstations and appliances
publisher: Canonical✓
store-url: https://snapcraft.io/microk8s
contact:   https://github.com/ubuntu/microk8s
license:   unset
description: |
  MicroK8s is the smallest, simplest, pure production Kubernetes for clusters, laptops, IoT and
  Edge, on Intel and ARM. One command installs a single-node K8s cluster with carefully selected
  add-ons on Linux, Windows and macOS.  MicroK8s requires no configuration, supports automatic
  updates and GPU acceleration. Use it for offline development, prototyping, testing, to build your
  CI/CD pipeline or your IoT apps.
commands:
  - microk8s.add-node
  - microk8s.cilium
  - microk8s.config
  - microk8s.ctr
  - microk8s.dashboard-proxy
  - microk8s.dbctl
  - microk8s.disable
  - microk8s.enable
  - microk8s.helm
  - microk8s.helm3
  - microk8s.inspect
  - microk8s.istioctl
  - microk8s.join
  - microk8s.juju
  - microk8s.kubectl
  - microk8s.leave
  - microk8s.linkerd
  - microk8s
  - microk8s.refresh-certs
  - microk8s.remove-node
  - microk8s.reset
  - microk8s.start
  - microk8s.status
  - microk8s.stop
services:
  microk8s.daemon-apiserver:            simple, enabled, active
  microk8s.daemon-apiserver-kicker:     simple, enabled, active
  microk8s.daemon-cluster-agent:        simple, enabled, active
  microk8s.daemon-containerd:           simple, enabled, active
  microk8s.daemon-control-plane-kicker: simple, enabled, active
  microk8s.daemon-controller-manager:   simple, enabled, active
  microk8s.daemon-etcd:                 simple, enabled, inactive
  microk8s.daemon-flanneld:             simple, enabled, inactive
  microk8s.daemon-kubelet:              simple, enabled, active
  microk8s.daemon-proxy:                simple, enabled, active
  microk8s.daemon-scheduler:            simple, enabled, active
snap-id:      EaXqgt1lyCaxKaQCU349mlodBkDCXRcg
tracking:     1.20/stable
refresh-date: today at 15:41 PDT
channels:
  1.20/stable:      v1.20.4         2021-03-16 (2074) 218MB classic
  1.20/candidate:   v1.20.4         2021-03-10 (2074) 218MB classic
  1.20/beta:        v1.20.4         2021-03-10 (2074) 218MB classic
  1.20/edge:        v1.20.5         2021-03-22 (2094) 218MB classic
  latest/stable:    v1.20.4         2021-03-17 (2074) 218MB classic
  latest/candidate: v1.20.4         2021-03-09 (2081) 190MB classic
  latest/beta:      v1.20.4         2021-03-09 (2081) 190MB classic
  latest/edge:      v1.20.5         2021-03-22 (2093) 189MB classic
  dqlite/stable:    –                                       
  dqlite/candidate: –                                       
  dqlite/beta:      –                                       
  dqlite/edge:      v1.16.2         2019-11-07 (1038) 189MB classic
  1.21/stable:      –                                       
  1.21/candidate:   –                                       
  1.21/beta:        v1.21.0-beta.1  2021-03-12 (2085) 191MB classic
  1.21/edge:        v1.21.0-alpha.3 2021-03-08 (2080) 190MB classic
  1.19/stable:      v1.19.8         2021-03-16 (2060) 216MB classic
  1.19/candidate:   v1.19.8         2021-03-10 (2060) 216MB classic
  1.19/beta:        v1.19.8         2021-03-10 (2060) 216MB classic
  1.19/edge:        v1.19.9         2021-03-22 (2095) 216MB classic
  1.18/stable:      v1.18.16        2021-03-16 (2055) 198MB classic
  1.18/candidate:   v1.18.16        2021-03-09 (2055) 198MB classic
  1.18/beta:        v1.18.16        2021-03-09 (2055) 198MB classic
  1.18/edge:        v1.18.16        2021-02-17 (2055) 198MB classic
  1.17/stable:      v1.17.17        2021-01-15 (1916) 177MB classic
  1.17/candidate:   v1.17.17        2021-01-14 (1916) 177MB classic
  1.17/beta:        v1.17.17        2021-01-14 (1916) 177MB classic
  1.17/edge:        v1.17.17        2021-01-13 (1916) 177MB classic
  1.16/stable:      v1.16.15        2020-09-12 (1671) 179MB classic
  1.16/candidate:   v1.16.15        2020-09-04 (1671) 179MB classic
  1.16/beta:        v1.16.15        2020-09-04 (1671) 179MB classic
  1.16/edge:        v1.16.15        2020-09-02 (1671) 179MB classic
  1.15/stable:      v1.15.11        2020-03-27 (1301) 171MB classic
  1.15/candidate:   v1.15.11        2020-03-27 (1301) 171MB classic
  1.15/beta:        v1.15.11        2020-03-27 (1301) 171MB classic
  1.15/edge:        v1.15.11        2020-03-26 (1301) 171MB classic
  1.14/stable:      v1.14.10        2020-01-06 (1120) 217MB classic
  1.14/candidate:   ↑                                       
  1.14/beta:        ↑                                       
  1.14/edge:        v1.14.10        2020-03-26 (1303) 217MB classic
  1.13/stable:      v1.13.6         2019-06-06  (581) 237MB classic
  1.13/candidate:   ↑                                       
  1.13/beta:        ↑                                       
  1.13/edge:        ↑                                       
  1.12/stable:      v1.12.9         2019-06-06  (612) 259MB classic
  1.12/candidate:   ↑                                       
  1.12/beta:        ↑                                       
  1.12/edge:        ↑                                       
  1.11/stable:      v1.11.10        2019-05-10  (557) 258MB classic
  1.11/candidate:   ↑                                       
  1.11/beta:        ↑                                       
  1.11/edge:        ↑                                       
  1.10/stable:      v1.10.13        2019-04-22  (546) 222MB classic
  1.10/candidate:   ↑                                       
  1.10/beta:        ↑                                       
  1.10/edge:        ↑                                       
installed:          v1.20.4                    (2074) 218MB classic
root@automata:~# 

root@automata:~# microk8s enable dns dashboard storage
Enabling DNS
Applying manifest
serviceaccount/coredns created
configmap/coredns created
deployment.apps/coredns created
service/kube-dns created
clusterrole.rbac.authorization.k8s.io/coredns created
clusterrolebinding.rbac.authorization.k8s.io/coredns created
Restarting kubelet
DNS is enabled
Enabling Kubernetes Dashboard
Enabling Metrics-Server
clusterrole.rbac.authorization.k8s.io/system:aggregated-metrics-reader created
clusterrolebinding.rbac.authorization.k8s.io/metrics-server:system:auth-delegator created
rolebinding.rbac.authorization.k8s.io/metrics-server-auth-reader created
Warning: apiregistration.k8s.io/v1beta1 APIService is deprecated in v1.19+, unavailable in v1.22+; use apiregistration.k8s.io/v1 APIService
apiservice.apiregistration.k8s.io/v1beta1.metrics.k8s.io created
serviceaccount/metrics-server created
deployment.apps/metrics-server created
service/metrics-server created
clusterrole.rbac.authorization.k8s.io/system:metrics-server created
clusterrolebinding.rbac.authorization.k8s.io/system:metrics-server created
clusterrolebinding.rbac.authorization.k8s.io/microk8s-admin created
Metrics-Server is enabled
Applying manifest
serviceaccount/kubernetes-dashboard created
service/kubernetes-dashboard created
secret/kubernetes-dashboard-certs created
secret/kubernetes-dashboard-csrf created
secret/kubernetes-dashboard-key-holder created
configmap/kubernetes-dashboard-settings created
role.rbac.authorization.k8s.io/kubernetes-dashboard created
clusterrole.rbac.authorization.k8s.io/kubernetes-dashboard created
rolebinding.rbac.authorization.k8s.io/kubernetes-dashboard created
clusterrolebinding.rbac.authorization.k8s.io/kubernetes-dashboard created
deployment.apps/kubernetes-dashboard created
service/dashboard-metrics-scraper created
deployment.apps/dashboard-metrics-scraper created

If RBAC is not enabled access the dashboard using the default token retrieved with:

token=$(microk8s kubectl -n kube-system get secret | grep default-token | cut -d " " -f1)
microk8s kubectl -n kube-system describe secret $token

In an RBAC enabled setup (microk8s enable RBAC) you need to create a user with restricted
permissions as shown in:
https://github.com/kubernetes/dashboard/blob/master/docs/user/access-control/creating-sample-user.md

Enabling default storage class
deployment.apps/hostpath-provisioner created
storageclass.storage.k8s.io/microk8s-hostpath created
serviceaccount/microk8s-hostpath created
clusterrole.rbac.authorization.k8s.io/microk8s-hostpath created
clusterrolebinding.rbac.authorization.k8s.io/microk8s-hostpath created
Storage will be available soon
root@automata:~# 


root@automata:~# microk8s kubectl get all --all-namespaces
NAMESPACE     NAME                                             READY   STATUS    RESTARTS   AGE
kube-system   pod/calico-node-t5lpg                            1/1     Running   1          179m
kube-system   pod/calico-kube-controllers-847c8c99d-b72lc      1/1     Running   0          179m
kube-system   pod/coredns-86f78bb79c-wknf2                     0/1     Running   0          28s
kube-system   pod/metrics-server-8bbfb4bdb-65vb6               0/1     Pending   0          15s
kube-system   pod/kubernetes-dashboard-7ffd448895-wlvw8        0/1     Pending   0          6s
kube-system   pod/dashboard-metrics-scraper-6c4568dc68-rgkwt   0/1     Pending   0          6s
kube-system   pod/hostpath-provisioner-5c65fbdb4f-q296v        0/1     Pending   0          3s

NAMESPACE     NAME                                TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)                  AGE
default       service/kubernetes                  ClusterIP   10.152.183.1     <none>        443/TCP                  179m
kube-system   service/kube-dns                    ClusterIP   10.152.183.10    <none>        53/UDP,53/TCP,9153/TCP   28s
kube-system   service/metrics-server              ClusterIP   10.152.183.116   <none>        443/TCP                  15s
kube-system   service/kubernetes-dashboard        ClusterIP   10.152.183.230   <none>        443/TCP                  6s     ====> THIS ONE IS MOST IMPORTANT LINK !!!
kube-system   service/dashboard-metrics-scraper   ClusterIP   10.152.183.103   <none>        8000/TCP                 6s

NAMESPACE     NAME                         DESIRED   CURRENT   READY   UP-TO-DATE   AVAILABLE   NODE SELECTOR            AGE
kube-system   daemonset.apps/calico-node   1         1         1       1            1           kubernetes.io/os=linux   179m

NAMESPACE     NAME                                        READY   UP-TO-DATE   AVAILABLE   AGE
kube-system   deployment.apps/calico-kube-controllers     1/1     1            1           179m
kube-system   deployment.apps/coredns                     0/1     1            0           28s
kube-system   deployment.apps/metrics-server              0/1     1            0           15s
kube-system   deployment.apps/kubernetes-dashboard        0/1     1            0           6s
kube-system   deployment.apps/dashboard-metrics-scraper   0/1     1            0           6s
kube-system   deployment.apps/hostpath-provisioner        0/1     1            0           4s

NAMESPACE     NAME                                                   DESIRED   CURRENT   READY   AGE
kube-system   replicaset.apps/calico-kube-controllers-847c8c99d      1         1         1       179m
kube-system   replicaset.apps/coredns-86f78bb79c                     1         1         0       28s
kube-system   replicaset.apps/metrics-server-8bbfb4bdb               1         1         0       15s
kube-system   replicaset.apps/kubernetes-dashboard-7ffd448895        1         1         0       6s
kube-system   replicaset.apps/dashboard-metrics-scraper-6c4568dc68   1         1         0       6s
kube-system   replicaset.apps/hostpath-provisioner-5c65fbdb4f        1         1         0       4s
root@automata:~# 
root@automata:~# 
root@automata:~# 
root@automata:~# logout




TIME TO OPEN KUBERNETES WEB INTERFACE:

$ firefox    https://10.152.183.230/




ON A DIFFERENT TERMINAL:: (IN order to retrieve token needed to sign-into K8 console)::


root@automata:~# token=$(microk8s kubectl -n kube-system get secret | grep default-token | cut -d " " -f1)
root@automata:~# microk8s kubectl -n kube-system describe secret $token
Name:         default-token-tgt6l
Namespace:    kube-system
Labels:       <none>
Annotations:  kubernetes.io/service-account.name: default
              kubernetes.io/service-account.uid: def37df5-8bda-49ec-9591-fb7a893e2c1b

Type:  kubernetes.io/service-account-token

Data
====
ca.crt:     1103 bytes
namespace:  11 bytes
token:      eyJhbGciOiJSUzI1NiIsImtpZCI6IlN4Sk9saWtEc01xX19MUS12bFc3dTJlTU9DVHpfbmwtZEZ3eUJjT1gzVVUifQ.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlLXN5c3RlbSIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJkZWZhdWx0LXRva2VuLXRndDZsIiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQubmFtZSI6ImRlZmF1bHQiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC51aWQiOiJkZWYzN2RmNS04YmRhLTQ5ZWMtOTU5MS1mYjdhODkzZTJjMWIiLCJzdWIiOiJzeXN0ZW06c2VydmljZWFjY291bnQ6a3ViZS1zeXN0ZW06ZGVmYXVsdCJ9.GctSaD4bAEzMtJAnoMDD2mQKZAZZyd2reL3w3ZqYvQNUl1hlBaM0Cab55qFnp-7fzeHgDJZ4EDqCJFIpMr1ZHsVvtqulPaHMqKObATgilSBmP7hiltC6fq-PpI_wqHGK77BTbE1ScSkaO9IzkQstd0go1aTjVdxy6Nw7HduEvHtWR_wymcJZPM3k6sHByr8M0pZ4MfaQJcZhJhmEvHKbwHiSONN06oauoXzjjzt1Ghqh8XpNGPlWEg223KmEiDpyxJHCqKG2iWntbN-SnnP4akifr6fDcT-E08LqoGr7SkT8Gz3rmTINI2Q1f3lYsssceWbhE5Q32YYmcqJAu4tmOg
root@automata:~# 







</pre>

Sunday, November 1, 2020

gnome-terminal not opening in Ubuntu

While logged into GNOME in Ubuntu, gnome-terminal will not open. Log file shows as below:
Nov  2 04:42:36 dhcp-31 dbus-daemon[1178]: [session uid=1000 pid=1178] Activating service name='org.gnome.Nautilus' requested by ':1.35' (uid=1000 pid=1415 comm="/usr/bin/gnome-shell " label="unconfined")
Nov  2 04:42:36 dhcp-31 dbus-daemon[1178]: [session uid=1000 pid=1178] Activating service name='org.gnome.Calculator.SearchProvider' requested by ':1.35' (uid=1000 pid=1415 comm="/usr/bin/gnome-shell " label="unconfined")
Nov  2 04:42:36 dhcp-31 dbus-daemon[1178]: [session uid=1000 pid=1178] Activating service name='org.gnome.Characters.BackgroundService' requested by ':1.35' (uid=1000 pid=1415 comm="/usr/bin/gnome-shell " label="unconfined")
Nov  2 04:42:36 dhcp-31 dbus-daemon[1178]: [session uid=1000 pid=1178] Successfully activated service 'org.gnome.Characters.BackgroundService'
Nov  2 04:42:36 dhcp-31 dbus-daemon[1178]: [session uid=1000 pid=1178] Successfully activated service 'org.gnome.Nautilus'
Nov  2 04:42:36 dhcp-31 dbus-daemon[1178]: [session uid=1000 pid=1178] Successfully activated service 'org.gnome.Calculator.SearchProvider'
Nov  2 04:42:39 dhcp-31 systemd[1162]: Started Application launched by gnome-shell.
Nov  2 04:42:49 dhcp-31 gnome-shell[1997]: # Error constructing proxy for org.gnome.Terminal:/org/gnome/Terminal/Factory0: Error calling StartServiceByName for org.gnome.Terminal: Timeout was reached
Nov  2 04:43:04 dhcp-31 gnome-shell[1415]: Received error from DBus search provider org.gnome.Terminal.desktop during XUbuntuCancel: Gio.IOErrorEnum: Timeout was reached
Nov  2 04:43:04 dhcp-31 org.gnome.Terminal.desktop[2052]: # Error constructing proxy for org.gnome.Terminal:/org/gnome/Terminal/Factory0: Error calling StartServiceByName for org.gnome.Terminal: Timeout was reached
Nov  2 04:43:04 dhcp-31 systemd[1162]: gnome-launched-org.gnome.Terminal.desktop-2050.scope: Succeeded.
This can be resolved by defining LANG in locale.
root@dhcp2066-31:~# cat /etc/default/locale 
#  File generated by update-locale
LANG="en_US"
LANGUAGE="en_US:"
LANG=en_US.UTF-8
Rebooted and problem solved!!!