Skip to content

Instantly share code, notes, and snippets.

View aojea's full-sized avatar

Antonio Ojea aojea

View GitHub Profile
import socket
for i in range(100):
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1)
try:
s.bind(('0.0.0.0', 65000))
except:
print "Binding problem"
s.close()
@aojea
aojea / pyscript.py
Created December 2, 2017 16:14 — forked from nhoffman/pyscript.py
Python script template
#!/usr/bin/env python
"""A simple python script template.
"""
from __future__ import print_function
import os
import sys
import argparse
# Copyright 2011, Dell
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
@aojea
aojea / round_robin.py
Created August 13, 2018 20:28
Round Robin Tournament
# import the necessary packages
import argparse
import datetime
import time
# construct the argument parser and parse the arguments
ap = argparse.ArgumentParser()
ap.add_argument("-n", "--number", type=int, help="number of participants")
@aojea
aojea / cloud-config
Last active December 5, 2018 15:23
cloud-init to install devstack
#cloud-config
#
# Use to spawn an instance and install devstack
# openstack server create --flavor m1.large --image opensuse150 --key-name mykey --security-group default --security-group "ping/ssh" --user-data cloud-config --nic net-id=cb4f16fb-248e-4095-b359-691f07d307fc leap15-devstack
groups:
- stack
users:
- default
@aojea
aojea / cloud-config
Last active December 5, 2018 15:24
Cloud config to install devstack with dual stack
#cloud-config
#
# Use to spawn an instance and install devstack
# openstack server create --flavor m1.large --image opensuse150 --key-name mykey --security-group default --security-group "ping/ssh" --user-data cloud-config --nic net-id=cb4f16fb-248e-4095-b359-691f07d307fc leap15-devstack
groups:
- stack
users:
- default
# this config file contains all config fields with comments
kind: Config
apiVersion: kind.sigs.k8s.io/v1alpha2
# 1 control plane node and 3 workers
nodes:
# the control plane node config
- role: control-plane
# patch the generated kubeadm config with some extra settings
kubeadmConfigPatches:
- |
@aojea
aojea / BUG: unable to handle kernel NULL pointer dereference
Last active April 23, 2019 07:58
BUG: unable to handle kernel NULL pointer dereference
# Create a docker container with privileges
docker run --privileged -i -t ubuntu
# Inside the container create an overlay and moun the /sys/class/dmi/id folder
mkdir -p /tmp/overlay && \
> mount -t tmpfs tmpfs /tmp/overlay && \
> mkdir -p /tmp/overlay/{upper,work} && \
> mount -t overlay overlay -o lowerdir=/sys/class/dmi/id,upperdir=/tmp/overlay/upper,workdir=/tmp/overlay/work /sys/class/dmi/id
# Check that the overlay is mounted
root@ba04ffbf6b53:/# mount
overlay on / type overlay (rw,relatime,lowerdir=/home/aojeagarcia/docker/overlay2/l/CJ5RY5KARMA2TGYBAZXKZ2UATK:/home/aojeagarcia/docker/overlay2/l/IH76YKNGVA4ANHOR2BJREE6YO4:/home/aojeagarcia/docker/overlay2/l/XHSQFRMONPMIOATXRYRMERF4RX:/home/aojeagarcia/docker/overlay2/l/NXCCDT6GQF62DMTR2AVCOIGT52:/home/aojeagarcia/docker/overlay2/l/BG34R5QJL3GEGBP24JDPITUB6H,upperdir=/home/aojeagarcia/docker/overlay2/fb3e50a942f1a3bc47f4ff9808b21a23af5cd7971f8a5e257441ddfa4b6e644d/diff,workdir=/home/aojeagarcia/docker/overlay2/fb3e50a942f1a3bc47f4ff9808b21a23af5cd7971f8a
@aojea
aojea / custom-upstream-dns.yml
Last active May 27, 2019 11:12
force all non-cluster DNS lookups to go through a specific nameserver
---
apiVersion: v1
data:
Corefile: |
.:53 {
log
errors
health
kubernetes cluster.local in-addr.arpa ip6.arpa {
pods insecure
@aojea
aojea / ip-masq.yaml
Last active May 27, 2019 12:48
ip masq configuration
apiVersion: v1
data:
config: |-
nonMasqueradeCIDRs:
- 10.244.0.0/16
masqLinkLocal: true
resyncInterval: 10s
kind: ConfigMap
metadata:
labels: