Skip to content

Instantly share code, notes, and snippets.

View mrunalp's full-sized avatar

Mrunal Patel mrunalp

View GitHub Profile
@mrunalp
mrunalp / ipvlan_setup.txt
Created February 13, 2015 18:38
ipvlan setup
1. Setup a Fedora 21 VM using virt-builder and import into virt-manager.
2. Download and compile https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.19.tar.xz with CONFIG_IPVLAN=m.
3. Copy the kernel to /boot and add it to grub using grub2-mkconfig and dracut. Reboot.
4. Steps from https://github.com/torvalds/linux/blob/master/Documentation/networking/ipvlan.txt with additional comments --
(a) Create two network namespaces - ns0, ns1
ip netns add ns0
ip netns add ns1
(b) Create two ipvlan slaves on eth0 (master device)
ip link add link eth0 ipvl0 type ipvlan mode l2
set -x
network_ip=10.1.0.0/16
tap_ip=10.1.0.1
new_ip=$1
net_container=$(docker run -d kubernetes/pause)
echo $net_container
pid=$(docker inspect --format "{{.State.Pid}}" ${net_container})
ipaddr=$(docker inspect --format "{{.NetworkSettings.IPAddress}}" ${net_container})
@mrunalp
mrunalp / system_test.go
Created March 10, 2015 23:50
system_test.go
package system_test
import (
"io/ioutil"
"os"
"testing"
"github.com/docker/libcontainer/system"
"github.com/docker/libcontainer/selinux"
)
@mrunalp
mrunalp / mnt.c
Last active August 29, 2015 14:19
unshare and bind mount namespace
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <sched.h>
#include <errno.h>
#include <sys/mount.h>
#include <sys/types.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <unistd.h>
@mrunalp
mrunalp / pod.json
Created May 23, 2015 00:19
/dev/shm sharing
{
"apiVersion": "v1beta2",
"desiredState": {
"manifest": {
"containers": [
{
"image": "kubernetes/pause",
"name": "hello-container1",
"ports": [
{
unshare -Urm --mount-proc
1. Apply this simple patch so that bind mounts aren't converted to private in runc
diff --git a/libcontainer/rootfs_linux.go b/libcontainer/rootfs_linux.go
index 21f380d..c1dfce5 100644
--- a/libcontainer/rootfs_linux.go
+++ b/libcontainer/rootfs_linux.go
@@ -400,7 +400,7 @@ func mknodDevice(dest string, node *configs.Device) error {
func prepareRoot(config *configs.Config) error {
flag := syscall.MS_SLAVE | syscall.MS_REC
if config.Privatefs {
#!/bin/bash
while read line
do
echo $line > /tmp/myoutput
done < /dev/stdin
mkdir -p /var/log/journal/9876
mkdir -p /busybox/var/log/journal/9876
#!/bin/bash
umount /busybox/var/log/journal/9876
rm -rf /var/log/journal/9876
umount /busybox/etc/machine-id
rm -rf /busybox/etc/machine-id
rm -rf /tmp/busybox/etc/
@mrunalp
mrunalp / regmachine.go
Created August 19, 2015 21:08
Use dbus to register a container as a machine so it shows up in machine ctl
package main
import (
"encoding/hex"
"flag"
"log"
"github.com/godbus/dbus"
)