Skip to content

Instantly share code, notes, and snippets.

View aojea's full-sized avatar

Antonio Ojea aojea

View GitHub Profile
@aojea
aojea / nodeport-svc.yaml
Created August 12, 2020 14:25
node port service
apiVersion: apps/v1
kind: Deployment
metadata:
name: httpd-deployment
labels:
app: MyApp
spec:
replicas: 2
selector:
matchLabels:
@aojea
aojea / dual-stack.yaml
Last active February 4, 2021 17:02
deploy dual stack application in kubernets
apiVersion: apps/v1
kind: Deployment
metadata:
name: httpd-deployment
labels:
app: MyDualApp
spec:
replicas: 2
selector:
matchLabels:
# full credit https://dev.to/selfup/concurrent-tcp-server-in-go-4afp
package main
import (
"bufio"
"fmt"
"log"
"net"
)
@aojea
aojea / next_subnet.go
Last active January 22, 2024 07:43
golang subnet tools
package main
import (
"fmt"
"net"
)
// broadcastAddress returns the broadcast address of the subnet
func broadcastAddress(subnet *net.IPNet) net.IP{
n := len(subnet.IP)
@aojea
aojea / vxlan_ns_scenario.sh
Last active January 22, 2024 07:43
Test vxlan tunnnels with network namespaces
# Create 2 network namespaces
sudo ip netns add NorthNS
sudo ip netns add SouthNS
# Connect the namespaces using a veth pair
sudo ip link add name vethSouth type veth peer name vethNorth
sudo ip link set netns NorthNS dev vethNorth
sudo ip link set netns SouthNS dev vethSouth
# Configure the namespaces network so they can reach each other
@aojea
aojea / ipv6_commits.sh
Last active February 29, 2020 23:12
Kubernetes IPv6 commits per month
#!/bin/bash
# Go to the kubernetes repo
cd $GOROOT/src/k8s.io/kubernetes
# Obtain all k8s releases
git log --tags --simplify-by-decoration --pretty="format:%ai %d" | grep -E 'v1.\d+.0\)' > git.k8s.releases
# Obtain all commits with ipv6 in its commit
git log --pretty=format:"%ci %s" --all | grep -i ipv6 | cut -d- -f1,2 | uniq -c > git.ipv6.txt
# Plot it
gnuplot -p << EOF
set title "Kubernetes IPv6 commits per month"
@aojea
aojea / externalname.md
Last active January 27, 2020 22:22
Dual Stack DNS services

Service

kubectl --context kind-kind  get service my-service -o yaml
apiVersion: v1
kind: Service
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
from kubernetes import client, config
import sys
# Obtain the namespace, the service name and the lb ip as the arguments
if len(sys.argv) != 4:
print ("Usage: lb.py namespace service_name ip")
sys.exit(1)
ns = sys.argv[1]
name = sys.argv[2]
@aojea
aojea / create_listener.go
Created December 20, 2019 11:29
CreateListener
package main
import (
"fmt"
"net"
"time"
)
func main() {
fmt.Println(CreateListener("", "0.0.0.0:9999"))
@aojea
aojea / README.md
Last active September 12, 2023 15:22
Who is holding the iptables lock

How to repro

$ exec 3> /run/xtables.lock

$ flock 3

$ python getlock.py
2023-09-12 15:21:24.453191 WARNING: process with pid: /proc/25720, cmdline: -su, accessing the lock for 5 seconds
 PID TTY STAT TIME COMMAND