Skip to content

Instantly share code, notes, and snippets.

Avatar
🇿🇦

Ruan Bekker ruanbekker

🇿🇦
View GitHub Profile
@ruanbekker
ruanbekker / ec2_asg_launch_config_spot.md
Last active Nov 17, 2020
Create EC2 Spot Instance Launch Config and Auto Scaling Group with AWS CLI
View ec2_asg_launch_config_spot.md

Userdata:

$ cat userdata.txt
#!/bin/bash
CLUSTER_NAME="aws-qa-ecs"
ENVIRONMENT_NAME="qa"
INSTANCE_LIFECYCLE="spot"
MY_HOSTNAME="$(curl -s http://169.254.169.254/latest/meta-data/local-hostname)"
INSTANCE_ID="$(curl -s http://instance-data/latest/meta-data/instance-id)"
@ruanbekker
ruanbekker / userdata_ecs.txt
Created Nov 16, 2020
EC2 Userdata with Prometheus Node Exporter and Loki for ECS
View userdata_ecs.txt
#!/bin/bash
AWS_ACCOUNT="dev"
CLUSTER_NAME="aws-qa-ecs"
ENVIRONMENT_NAME="qa"
NODE_EXPORTER_VERSION="1.0.1"
NODE_EXPORTER_USER="node_exporter"
MY_HOSTNAME="$(curl -s http://169.254.169.254/latest/meta-data/local-hostname)"
INSTANCE_ID="$(curl -s http://instance-data/latest/meta-data/instance-id)"
INSTANCE_LIFECYCLE="$(curl -s http://169.254.169.254/latest/meta-data/instance-life-cycle)"
REGION="$(curl -s http://instance-data/latest/meta-data/placement/availability-zone | rev | cut -c 2- | rev)"
@ruanbekker
ruanbekker / aws_ec2_odemand_spot.md
Last active Nov 16, 2020
AWS Price Difference between On-Demand and Spot
View aws_ec2_odemand_spot.md

OnDemand:

$ curl -s https://raw.githubusercontent.com/powdahound/ec2instances.info/master/www/instances.json | jq -r '.[] | select(.instance_type == "t2.micro") | .pricing."eu-west-1".linux.ondemand'
0.0126

Spot:

@ruanbekker
ruanbekker / loki_logcli_promtail.md
Last active Nov 12, 2020
Quick Demonstration how to Pipe to Loki with Loki, LogCLI and Promtail
View loki_logcli_promtail.md

Provision a VM with Multipass:

$ multipass shell
$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 18.04.4 LTS
Release:	18.04
Codename:	bionic
@ruanbekker
ruanbekker / kvm_host_one_provider.md
Created Oct 6, 2020
Setup a KVM Host on OneProvider
View kvm_host_one_provider.md

Update and install cpu-checker to see if we can use hardware virtualization:

$ apt update && apt upgrade -y
$ apt install cpu-checker -y

Test with kvm-ok:

@ruanbekker
ruanbekker / convert_ssh2_to_openssh.md
Last active Oct 6, 2020
Convert SSH2 format public keys to OpenSSH format
View convert_ssh2_to_openssh.md

SSH2 format will look like this:

---- BEGIN SSH2 PUBLIC KEY ----
Comment: "rsa-key-20201005"
AAAA
....
abcdef==
---- END SSH2 PUBLIC KEY ----
View assume-role-policy.json
{
"Version": "2012-10-17",
"Statement": [
{
"Action": "sts:AssumeRole",
"Principal": {
"Service": "ec2.amazonaws.com"
},
"Effect": "Allow",
"Sid": ""
@ruanbekker
ruanbekker / terraform_kvm.md
Last active Sep 27, 2020
Terraform with KVM
View terraform_kvm.md

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 Sep 23, 2020 — forked from denji/nginx-tuning.md
NGINX tuning for best performance
View nginx-tuning.md

Moved to git repository: https://github.com/denji/nginx-tuning

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.

You can’t perform that action at this time.