linux

Kubernetes

kubectl Cheat Sheet
https://kubernetes.io/docs/reference/kubectl/cheatsheet/

Dump Kubernetes Objects
kubectl get componentstatuses
kubectl get configmaps
kubectl get daemonsets
kubectl get deployments
kubectl get events
kubectl get endpoints
kubectl get horizontalpodautoscalers
kubectl get ingress
kubectl get jobs
kubectl get limitranges
kubectl get nodes
kubectl get namespaces
kubectl get pods
kubectl get pods --all-namespaces -o wide
kubectl get persistentvolumes
kubectl get persistentvolumeclaims
kubectl get quota

Duplicity with S3

Install
sudo apt install -y duplicity python-boto

SSH
duplicity incr --log-file /tmp/duplicity.log /etc/ scp://foo@10.0.1.123//media/etc

S3
vi ~/.boto
[Credentials]
aws_access_key_id = KEY_ID
aws_secret_access_key = SECRET_ACCESS_KEY

# create backup to s3
duplicity full --log-file /tmp/duplicity.log /etc/ s3://s3.example.com/backup/host.examp.eocm/etc/

duplicity list-current-files s3+http://bucket/folder

WebDav
export FTP_PASSWORD="pass1234"

LXD: Create container with profile (connect to VLAN)

create profile
lxc profile copy default mgmt-dev
# lxc profile list
lxc profile device set mgmt-dev eth0 nictype macvlan
lxc profile device set mgmt-dev eth0 parent mgmt-dev-v4432
lxc profile show mgmt-dev

create container with profile
lxc launch ubuntu:18.04 bionic-mgmt-dev -p mgmt-dev
lxc ls

Enable container nesting
lxc config set bionic-mgmt-dev security.nesting true

Configure IP
cat < /var/lib/lxd/containers/bionic-mgmt-dev/rootfs/etc/netplan/50-cloud-init.yaml
network:
version: 2

Flash LibreELEC to S905X

Latest version:
https://kszaq.libreelec.tv/s905/

wget https://kszaq.libreelec.tv/s905/8.2/8.2.3.1/LibreELEC-S905.arm-8.2-8.2.3.1.img.gz -P /tmp/
gzip -d /tmp/LibreELEC-S905.arm-8.2-8.2.3.1.img.gz -C /tmp
dd if=/tmp//tmp/LibreELEC.USB-SD.Creator.Linux-64bit.bin of=/dev/mmcblk0

1. remove power connector from the box
2. insert sd card to to the box
3. press button inside aux connector and connect power to the box
4. enable ssh service on the box
5. ssh root@your_box_ip (pass: libreelec)
6. installtointernal

Links

kexec (reboot without hardware initialization)

echo "kexec-tools kexec-tools/load_kexec select true" | sudo debconf-set-selections

sudo apt install -y kexec-tools
#sudo kexec -l /boot/vmlinuz-4.15.0-32-generic --initrd=/boot/initrd.img-4.15.0-32-generic --reuse-cmdline
#sudo kexec -e
#systemctl kexec

sudo kexec -l /vmlinuz --initrd=/initrd.img --reuse-cmdline && sudo systemctl kexec

- name: Enable kexec
lineinfile:
path: /etc/default/kexec
regexp: '^LOAD_KEXEC='
line: 'LOAD_KEXEC=true'
when: ('dev' in group_names)

Links
https://liranv.github.io/post/booting-memtest86-uefi/

ironic / bifrost

# load env
. /opt/stack/bifrost/env-vars

# list nodes
ironic node-list

# remove / shutdown existing node
ironic node-set-provision-state foo.example.com deleted

# load node configuration
export BIFROST_INVENTORY_SOURCE=/opt/openstack-prepare-baremetal/bifrost/json/foo.example.com.json

# add new node
ansible-playbook -i inventory/bifrost_inventory.py enroll-dynamic.yaml
ironic node-update foo.example.com add properties/capabilities='boot_mode:uefi'

# deploy
ansible-playbook -v -i inventory/bifrost_inventory.py deploy-dynamic.yaml

# show node details