Skip to content

Instantly share code, notes, and snippets.

Avatar

Adrian Ursu ursuad

  • Advance Leap Ltd
  • London, United Kindom
View GitHub Profile
View blog_20190205_use_klog_with_cobra.go
# Source: https://flowerinthenight.com/blog/2019/02/05/golang-cobra-klog
package main
import (
goflag "flag"
"github.com/spf13/cobra"
flag "github.com/spf13/pflag"
"k8s.io/klog"
)
@ursuad
ursuad / gist:bc1dbcab86b9544c5453df6400ba9c81
Created Mar 14, 2018 — forked from anikitenko/gist:b41206a49727b83a530142c76b1cb82d
[Golang] Convert size in bytes to Bytes, Kilobytes, Megabytes, GB and TB
View gist:bc1dbcab86b9544c5453df6400ba9c81
package main
import (
"fmt"
"math"
"strconv"
)
var (
sizeInMB float64 = 999 // This is in megabytes
@ursuad
ursuad / masq.sh
Created Oct 31, 2017 — forked from mowings/masq.sh
script to get xet xhyve working with all vpn interfaces
View masq.sh
#!/bin/bash
interfaces=( $(netstat -in | egrep 'utun\d .*\d+\.\d+\.\d+\.\d+' | cut -d ' ' -f 1) )
rulefile="rules.tmp"
echo "" > $rulefile
sudo pfctl -a com.apple/tun -F nat
for i in "${interfaces[@]}"
do
RULE="nat on ${i} proto {tcp, udp, icmp} from 192.168.64.0/24 to any -> ${i}"
echo $RULE >> $rulefile
done
View keybase.md

Keybase proof

I hereby claim:

  • I am ursuad on github.
  • I am ursuad (https://keybase.io/ursuad) on keybase.
  • I have a public key ASA0k9R6djMVQSjquz69dEZEiAGa44zliIFXotpuntTVdwo

To claim this, I am signing this object:

@ursuad
ursuad / gist:81238fd33bd6a6135f25c76abdc6160f
Created Dec 20, 2016 — forked from mbn18/gist:0d6ff5cb217c36419661
How to install nsenter on Ubuntu 14.04
View gist:81238fd33bd6a6135f25c76abdc6160f
# Ubuntu 14.04 don't have nsenter - the straight forward way required me to install build tools and etc.
# I preferred to keep the system clean and install nsenter in a container and then copy the command to the host
# Note - its also possible to run nsenter from a container (didn't tried) https://github.com/jpetazzo/nsenter
# start a container
docker run --name nsenter -it ubuntu:14.04 bash
## in the docker
apt-get update
apt-get install git build-essential libncurses5-dev libslang2-dev gettext zlib1g-dev libselinux1-dev debhelper lsb-release pkg-config po-debconf autoconf automake autopoint libtool
@ursuad
ursuad / README.md
Created Oct 12, 2016 — forked from adambom/README.md
Backup Kubernetes Cluster State
View README.md

Run this in order to backup all you k8s cluster data. It will be saved in a folder bkp. To restore the cluster, you can run kubectl apply -f bkp.

Please note: this recovers all resources correctly, including dynamically generated PV's. However, it will not recover ELB endpoints. You will need to update any DNS entries manually, and manually remove the old ELB's.

Please note: This has not been tested with all resource types. Supported resource types include:

  • services
  • replicationcontrollers
  • secrets
  • deployments
  • horizontal pod autoscalers
View federation-apiserver.yaml
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: federation-apiserver
namespace: federation
labels:
app: federated-cluster
spec:
template:
metadata:
View federation-controller-manager.yaml
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: federation-controller-manager
namespace: federation
labels:
app: federated-cluster
spec:
template:
metadata:
@ursuad
ursuad / kafka-cheat-sheet.md
Last active Nov 26, 2021
Quick command reference for Apache Kafka
View kafka-cheat-sheet.md

Kafka Topics

List existing topics

bin/kafka-topics.sh --zookeeper localhost:2181 --list

Describe a topic

bin/kafka-topics.sh --zookeeper localhost:2181 --describe --topic mytopic

Purge a topic

bin/kafka-topics.sh --zookeeper localhost:2181 --alter --topic mytopic --config retention.ms=1000

... wait a minute ...

@ursuad
ursuad / exercise.tour.go
Created May 24, 2016 — forked from zyxar/exercise.tour.go
tour.golang exercise solutions
View exercise.tour.go
/* Exercise: Loops and Functions #43 */
package main
import (
"fmt"
"math"
)
func Sqrt(x float64) float64 {
z := float64(2.)