4/22/20

Install and Deploy Kubernetes on Ubuntu


# Install Docker

sudo apt-get -y remove docker docker-engine docker.io containerd runc
sudo apt-get -y update
sudo apt-get install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
sudo apt-get -y update
sudo apt-get -y install docker-ce docker-ce-cli containerd.io
sudo usermod -a -G docker $USER


# Install Kubernetes

sudo apt-get update && sudo apt-get install -y apt-transport-https
sudo curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
sudo apt-add-repository "deb http://apt.kubernetes.io/ kubernetes-xenial main"
sudo apt-get update
sudo apt-get install -y kubelet kubeadm kubectl kubernetes-cni

# Disable swap memory

sudo swapoff -a

# Initialize Kubernetes

sudo kubeadm init --pod-network-cidr=192.168.0.0/16

mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config

sudo kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml

# Join Nodes

kubeadm join 192.168.0.10:6443 --token e8dzsm.gtyjl7vlyljn3xyd \
--discovery-token-ca-cert-hash sha256:d6ad7ec4f706b394b0a01b6cba229ab100bc903fdaa33463482e28df5fc28e97

# Get List of Nodes

sudo kubectl get nodes

3/6/20

Kubernetes TLS certificate errors


Error:
Unable to connect to the server: x509: certificate signed by unknown authority

Fix:
unset KUBECONFIG
export KUBECONFIG=/etc/kubernetes/admin.conf

mv  $HOME/.kube $HOME/.kube.bak
mkdir $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config

Sudo without password in Ubuntu/Debian



sudo visudo
user ALL=(ALL) NOPASSWD:ALL

3/5/20

MacOS Connect to KVM

Install:
brew tap jeffreywildman/homebrew-virt-manager
brew install virt-manager virt-viewer libvirt

Fix error (g-io-error-quark: Error opening file /usr/local/Cellar/libosinfo/1.7.1/share/libosinfo/pci.ids: No such file or directory (1)):

mkdir -p /usr/local/Cellar/libosinfo/1.7.1/share/libosinfo/
cd /usr/local/Cellar/libosinfo/1.7.1/share/libosinfo/
wget https://pci-ids.ucw.cz/v2.2/pci.ids
wget http://www.linux-usb.org/usb.ids

Copy ssh key:
ssh-copy-id -i ~/.ssh/id_rsa.pub [email protected]_address

Connect:
virt-manager -c 'qemu+ssh://[email protected]_address/system?socket=/var/run/libvirt/libvirt-sock'

9/5/19

Migrating Local Mongo to MongoDB Atlas



Stop database writes
#> mongo --host=localhost --eval "db.fsyncLock()"

Back up the data from the localhost database
#> mongodump --host=localhost --port=27017

Write the data to MongoDB Atlas
#> mongorestore --ssl --host cluster0-shard-00-00-qfovx.mongodb.net --port 27017 -u user -p password dump

6/14/19

uWSGI with Python 3.7 in Ubuntu 18

Packages
sudo apt install python3.7 python3.7-dev uwsgi uwsgi-src uuid-dev libcap-dev libpcre3-dev

Build
cd ~
export PYTHON=python3.7
uwsgi --build-plugin "/usr/src/uwsgi/plugins/python python37"

Install
sudo mv python37_plugin.so /usr/lib/uwsgi/plugins/python37_plugin.so
sudo chmod 644 /usr/lib/uwsgi/plugins/python37_plugin.so

10/16/18

SSLError(SSLError(1, u'[SSL: SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 alert handshake failure (_ssl.c:661)'),))

pip install pyOpenSSL
pip install ndg-httpsclient
pip install pyasn1

or

easy_install pyOpenSSL
easy_install ndg-httpsclient
easy_install pyasn1