Skip to content

Instantly share code, notes, and snippets.

View johananl's full-sized avatar

Johanan Liebermann johananl

View GitHub Profile
@johananl
johananl / supervisord.sh
Last active January 14, 2016 13:38 — forked from mhayes/supervisord.sh
init.d for supervisord for Amazon Linux AMI
#!/bin/sh
# Amazon Linux AMI startup script for a supervisor instance
#
# chkconfig: 2345 80 20
# description: Autostarts supervisord.
# Source function library.
. /etc/rc.d/init.d/functions
supervisorctl="/usr/local/bin/supervisorctl"
@johananl
johananl / Makefile
Last active May 18, 2018 12:35
Generic Makefile for Go apps
GOCMD=go
GOBUILD=$(GOCMD) build
GOCLEAN=$(GOCMD) clean
BINARY_NAME=myapp
.PHONY: test
test:
$(GOCMD) test -v ./...
.PHONY: build
@johananl
johananl / redis.service
Last active July 19, 2018 22:12
Running a container as a systemd service
# Put this file under /etc/systemd/system/redis.service
[Unit]
Description=Redis Container
After=docker.service
Requires=docker.service
[Service]
TimeoutStartSec=0
Restart=always
@johananl
johananl / kvm_nested_virtualization.txt
Last active October 22, 2021 12:49
KVM nested virtualization
L0 = bare metal machine
L1 = VM on bare metal
L2 = VM on VM
First, ensure virtualization is enabled on L0 as described here: https://docs.fedoraproject.org/en-US/quick-docs/using-nested-virtualization-in-kvm/#proc_enabling-nested-virtualization-in-kvm
Next, launch L1 with the following Vagrant config (or an equivalent directly on the hypervisor):
Vagrant.configure("2") do |config|
config.vm.box = "generic/ubuntu1604"
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 update
sudo apt-get install -y docker-ce
sudo gpasswd -a $USER docker
echo "Please re-log"
@johananl
johananl / Dockerfile
Last active October 17, 2018 16:40
KVM + Vagrant in Docker
# This is based on a Redhat blogpost:
# https://www.projectatomic.io/blog/2014/10/libvirtd_in_containers/
# https://github.com/projectatomic/docker-image-examples/blob/master/rhel-libvirt/libvirtd/Dockerfile
FROM centos:7
ENV VAGRANT_VERSION=2.2.0
RUN yum -y install systemd libvirt-daemon-driver-* libvirt-daemon libvirt-daemon-kvm libvirt-devel qemu-kvm gcc make wget openssh-clients && yum clean all; \
(cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; done); \
rm -f /lib/systemd/system/multi-user.target.wants/*;\
@johananl
johananl / README.md
Created October 30, 2018 20:14
KVM in runc

KVM in runc

Running a KVM virtual machine inside a runc contianer.

Requirements

  • A host which can run KVM virtual machines using Vagrant.

Setting up a test VM

@johananl
johananl / main.tf
Created January 4, 2019 21:59
Spot servers on Packet
provider "packet" {
auth_token = "${var.auth_token}"
}
# Packet auth token. Generate it on your Packet account. More info:
# https://support.packet.com/kb/articles/api-integrations
variable "auth_token" {}
# The Packet project ID. More info: https://support.packet.com/kb/articles/api-integrations
variable "project_id" {}
@johananl
johananl / httpbin.yaml
Created January 11, 2019 00:10
k8s ingress test (httpbin)
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: httpbin
labels:
app: httpbin
spec:
replicas: 3
selector:
@johananl
johananl / instructions.md
Last active January 13, 2019 16:12
Running a local k8s cluster using Vagrant and kubeadm

Requirements

These instructions assume running Vagrant with a libvirt provider.

Install the vagrant-libvirt plugin using the following:

vagrant plugin install vagrant-libvirt