Skip to content

Instantly share code, notes, and snippets.

View ruanbekker's full-sized avatar
🇿🇦

Ruan Bekker ruanbekker

🇿🇦
View GitHub Profile
@ruanbekker
ruanbekker / assume-role-policy.json
Created September 28, 2020 08:42 — forked from clstokes/assume-role-policy.json
Example: Terraform IAM Role
{
"Version": "2012-10-17",
"Statement": [
{
"Action": "sts:AssumeRole",
"Principal": {
"Service": "ec2.amazonaws.com"
},
"Effect": "Allow",
"Sid": ""
@ruanbekker
ruanbekker / terraform_kvm.md
Last active September 27, 2020 15:05
Terraform with KVM

Double check that security_driver = "none" is uncommented in /etc/libvirt/qemu.conf and restart sudo systemctl restart libvirtd for permission denied issue

cd /tmp/
mkdir -p ~/.local/share/terraform/plugins/registry.terraform.io/dmacvicar/libvirt/0.6.2/linux_amd64
wget https://github.com/dmacvicar/terraform-provider-libvirt/releases/download/v0.6.2/terraform-provider-libvirt-0.6.2+git.1585292411.8cbe9ad0.Ubuntu_18.04.amd64.tar.gz
tar -xvf terraform-provider-libvirt-0.6.2+git.1585292411.8cbe9ad0.Ubuntu_18.04.amd64.tar.gz
mv ./terraform-provider-libvirt  ~/.local/share/terraform/plugins/registry.terraform.io/dmacvicar/libvirt/0.6.2/linux_amd64/
@ruanbekker
ruanbekker / nginx-tuning.md
Created September 23, 2020 12:22 — forked from denji/nginx-tuning.md
NGINX tuning for best performance

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.

@ruanbekker
ruanbekker / deployment-green-hostname-rpi.yaml
Created September 21, 2020 06:05
Sample Kubernetes Web Application for Raspberry Pi
apiVersion: v1
kind: Namespace
metadata:
name: color
labels:
name: color
---
kind: Deployment
apiVersion: apps/v1
metadata:

Setup Kubernetes on KVM

This will show you how to setup a 1 node kubernetes (node) on KVM using k3s from the k3os iso

Install KVM

Install KVM:

$ apt install bridge-utils qemu-kvm virtinst -y
@ruanbekker
ruanbekker / kubernetes_service_accounts.md
Last active January 22, 2024 07:52
Kubernetes Service Accounts
@ruanbekker
ruanbekker / bypass_certificate_error.md
Created September 2, 2020 10:05
Bypass NET::ERR_CERT_INVALID Certificate Error

Pritunl's letsencrypt cerificate expired and trying to access pritunl's ui presented a NET::ERR_CERT_INVALID error and for some reason you cant bypass it. While I couldnt restart the server at that time, I had to look at a way to access the UI to change the web domain to convert the SSL termination to a Load Balancer.

Thanks to this post: https://stackoverflow.com/questions/58802767/no-proceed-anyway-option-on-neterr-cert-invalid-in-chrome-on-macos you can do:

  • Right click, select inspect element
  • click on console tab
  • Copy paste sendCommand(SecurityInterstitialCommandId.CMD_PROCEED) press Enter
@ruanbekker
ruanbekker / mysql_joins_performance_2020_06.md
Last active April 14, 2021 04:27
Performance Optimizations: Adding Indexes to improve joins speed

I am tinkering around with databases and want to make notes of performance optimizations by adding indexes.

I have 2 tables:

mysql> show tables;
+----------------------+
| Tables_in_customerdb |
+----------------------+
@ruanbekker
ruanbekker / hackernews_python.md
Last active June 12, 2020 17:03
Get Top 10 Stories on Hackernews in Python

Related:

import requests
import json

def get_top_ten():
    ids = requests.get('https://hacker-news.firebaseio.com/v0/topstories.json?print=pretty').json()[0:10]
 for id in ids: