Skip to content

Instantly share code, notes, and snippets.

View shearluck's full-sized avatar

Noel Jarencio shearluck

  • Philippines
View GitHub Profile
qemu-img create -f qcow2 /mount/path/disk.qcow2 -o preallocation=metadata 20G
sudo virsh attach-disk domain --source /mnt/files/VM/work/minikube.qcow2 --target vdc --cache none --persistent
@shearluck
shearluck / password_generator.sh
Created May 11, 2020 08:34
Linux random password generator
LEN=$1
< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c$LEN
@shearluck
shearluck / cloud-init.sh
Created April 23, 2020 09:20 — forked from ebal/cloud-init.sh
Cloud-init example using a Generic Cloud CentOS-7 on a libvirtd qmu/kvm lab
#!/bin/sh
if [ "$EUID" -ne 0 ]; then
echo -e "\nPlease run as root\neg. sudo $0 \n"
exit
fi
GITHUB_USERNAME="ebal"
cd `mktemp -d`
@shearluck
shearluck / qemu-mac-host.sh
Last active December 3, 2019 15:19
arch-mac-qemu
qemu-system-x86_64 -m 2048 -accel hvf -smp 2 -net nic -net user -device VGA,vgamem_mb=128,edid=on,xres=1680,yres=1050 -hda arch.img
# Mac host, access usb
-device pci-ohci
# Mac host, access usb raw storage device
-hdb /dev/disk2
mkdir .auth
# Create basic auth
docker run \
--entrypoint htpasswd \
registry:2 -Bbn testuser testpassword > .auth/htpasswd
# Make sure to serve this into an HTTPS load balancer/frontend
docker run -d \
-p 5000:5000 \
@shearluck
shearluck / pod.yaml
Last active October 17, 2022 07:44
Kubernetes k3s, EC2 spot instance, ECR, Private registry
apiVersion: v1
kind: Pod
metadata:
name: <app-name>
labels:
app: <app-name>
spec:
containers:
- name: <app-name>
image: <account>.dkr.ecr.us-west-2.amazonaws.com/<app-name>:latest
@shearluck
shearluck / k3s-setup.sh
Created April 30, 2019 02:40
K3s Centos 7 setup
echo 'net.netfilter.nf_conntrack_max=65528
net.ipv4.netfilter.ip_conntrack_max=65535' >> /etc/sysctl.conf
iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
sysctl -p /etc/sysctl.conf
curl -sfL https://get.k3s.io | sh -
# How many hours
DURATION_HRS=1
let DURATION_MINS=$DURATION_HRS*60
aws ec2 request-spot-instances --block-duration-minutes $DURATION_MINS --launch-specification file://bastion-spot-specs.json
@shearluck
shearluck / ec2-authorize-ssh-myip.sh
Created April 29, 2019 03:33
SSH authorize my IP
MYIP=`curl -s ipinfo.io/ip`
aws ec2 authorize-security-group-ingress --group-id $SG_ID --ip-permissions IpProtocol=tcp,FromPort=22,ToPort=22,IpRanges="[{CidrIp=$MYIP/32}]"
@shearluck
shearluck / make-lvm.sh
Last active April 19, 2019 17:09
Make LVM
# Wipe existing partition
sudo wipefs -a /dev/sdX
# Create PV
sudo pvcreate /dev/sdX
# Create VG
sudo vgcreate VolGroup00 /dev/sdX
# Create LV