Skip to content

Instantly share code, notes, and snippets.

kubectl get pods | grep Evicted | awk '{print $1}' | xargs kubectl delete pod
@theundefined
theundefined / HAProxy_and_K8s.md
Created June 14, 2017 06:45 — forked from suside/HAProxy_and_K8s.md
Kubernetes + HAProxy sticky session affinity

Kubernetes + HAProxy sticky session affinity

  1. Make sure you have balance source in haproxy.
  2. Backend server section in haproxy config should have all your k8s nodes.
  3. sessionAffinity in k8s is irrelevant.
  4. Exposed k8s service need to have nodePort set and this annotation:

kubectl annotate service myService service.beta.kubernetes.io/external-traffic=OnlyLocal

This will cause internal k8s loadbalancer on nodeⁿ to route traffic only to pod on nodeⁿ. From Haproxy point of view it will look like nodeⁿ:nodePort === pod on nodeⁿ:port thus disabling k8s LB completly.

import scala.concurrent._
import java.util.concurrent.atomic.AtomicReference
def interruptableFuture[T](fun: Future[T] => T)(implicit ex: ExecutionContext): (Future[T], () => Boolean) = {
val p = Promise[T]()
val f = p.future
val aref = new AtomicReference[Thread](null)
p tryCompleteWith Future {
val thread = Thread.currentThread
aref.set(thread)
@schmmd
schmmd / mvn2sbt.scala
Last active December 14, 2015 07:29
Create an sbt file from a pom file.
import scala.xml._
val scalaVersion = args.headOption
def quote(s: String) = "\"" + s + "\""
val xml = XML.loadString(scala.io.Source.stdin.getLines.mkString("\n"))
val name = (xml \ "artifactId").text
@larsar
larsar / shared_folder_centos_virtualbox.txt
Created January 27, 2012 08:04
Mount shared folder on CentOS in VirtualBox
# The VirtualBox documentation[1] for how to install guest additions
# for Linux on a virtual host is somewhat messy. So here is what
# I did to make it work.
# Install the packages required
yum update
yum install gcc kernel-devel make
reboot
@gclaramunt
gclaramunt / Circularbuffer.scala
Created November 23, 2011 17:33
circular buffer
package my.collections
class CirculrBufferIterator[T](buffer:Array[T], start:Int) extends Iterator[T]{
var idx=0
override def hasNext = idx<buffer.size
override def next()={
val i=idx
idx=idx+1
buffer(i)
}
@terrancesnyder
terrancesnyder / setenv.sh
Created May 23, 2011 00:07
./setenv.sh - example setenv.sh with defaults set for minimal time spent in garbage collection
#! /bin/sh
# ==================================================================
# ______ __ _____
# /_ __/___ ____ ___ _________ _/ /_ /__ /
# / / / __ \/ __ `__ \/ ___/ __ `/ __/ / /
# / / / /_/ / / / / / / /__/ /_/ / /_ / /
#/_/ \____/_/ /_/ /_/\___/\__,_/\__/ /_/
# Multi-instance Apache Tomcat installation with a focus
# on best-practices as defined by Apache, SpringSource, and MuleSoft
@retronym
retronym / mvn2sbt.scala
Created May 3, 2010 17:17
mvn2sbt: quick hack to turn <dependencies> into SBT
object scala {
val version = "SCALA_VERSION$"
}
val xml = <dependencies>
<dependency>
<groupId>org.scalanlp</groupId>
<artifactId>scalala_${scala.version}</artifactId>
<version>0.3.1</version>
</dependency>