Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am stephanx on github.
  • I am stephanx (https://keybase.io/stephanx) on keybase.
  • I have a public key ASCdgOW_nnusZqtNi44db7wOp-ojTwa4woomocjxWfLOxgo

To claim this, I am signing this object:

apiVersion: apps/v1
kind: StatefulSet
metadata:
labels:
app: elasticsearch
name: elasticsearch
spec:
replicas: {{ .Values.global.elasticsearch.replicas }}
selector:
matchLabels:
FROM python:3.6.4-slim-stretch
# Set up jenkins-slave & nodejs
# remoting changelog: https://github.com/jenkinsci/remoting/blob/master/CHANGELOG.md#315
ARG REMOTING_VERSION=3.15
ARG KUBE_VERSION=1.9.0
ARG NODEJS_VERSION=8
# Pay mind to https://launchpad.net/~webupd8team/+archive/ubuntu/java?field.series_filter= for the ubuntu java release and the java versions
ARG UBUNTU_JAVA_RELEASE=bionic
@StephanX
StephanX / gist:40db23418a3c43e58f00de815c992c42
Created April 14, 2018 00:05
kubernetes python blocking list
box ~> ipython
Python 3.6.5 (default, Mar 30 2018, 06:41:53)
Type 'copyright', 'credits' or 'license' for more information
IPython 6.2.1 -- An enhanced Interactive Python. Type '?' for help.
In [1]: from kubernetes import client, config
In [2]: config.load_kube_config(context="dev.k8s.mycompany.io")
In [3]: api_instance = client.RbacAuthorizationV1beta1Api(client.ApiClient())
alias ku='kubectl'
alias kube='kubectl'
kubectl() {
if [[ $1 == "namespace" || $1 == "ns" ]] ; then
if [[ $2 ]] ; then
command kubectl config set-context $(kubectl config current-context) --namespace=${2} 2>&1 >>/dev/null
else command kubectl config view $(kubectl config current-context) | grep namespace | awk '{ print $2 }'
fi
elif [[ $1 == "desc" || $1 == "de" ]] ; then
#!/bin/bash
# configures bash prompt based on current kubernetes cluster context and namespace
# based on https://pracucci.com/display-the-current-kubelet-context-in-the-bash-prompt.html
__kube_ps1()
{
CONTEXT=$(kubectl config view | grep current-context | awk '{ print $NF }' | awk -F '.' '{ print $1 }')
NS=$(kubectl config view $(kubectl config current-context) | grep namespace | awk '{ print $2 }')
if [ -n "$CONTEXT" ]; then
echo "[${CONTEXT}][${NS}]"
#!/bin/sh
# This will make your life easier when you want to shell into a kubernetes pod
if [ "$1" = "" ]; then
echo "Usage: kshell <pod>"
exit 1
fi
COLUMNS=`tput cols`
LINES=`tput lines`
TERM=xterm
kubectl exec -i -t $1 env COLUMNS=$COLUMNS LINES=$LINES TERM=$TERM bash
$ sudo apt-get install cryptsetup # or on redhat - yum install cryptsetup-luks
Reading package lists... Done
Building dependency tree
Reading state information... Done
cryptsetup is already the newest version (2:1.6.6-5ubuntu2).
0 upgraded, 0 newly installed, 0 to remove and 63 not upgraded.
$ truncate -s 100m myencryptedcontainer
$ cryptsetup -y -v luksFormat myencryptedcontainer
root@somehost:/opt/my-app/current# ruby --version
ruby 2.0.0p451 (2014-02-24 revision 45167) [x86_64-linux]
root@somehost:/opt/my-app/current# bundle exec pumactl -F config/puma.rb --state tmp/my-app.state restart
Puma starting in single mode...
* Version 2.8.2 (ruby 2.0.0-p451), codename: Sir Edmund Percival Hillary
* Min threads: 0, max threads: 16
* Environment: development
loaded methods.rb
tried to load...
* Listening on tcp://0.0.0.0:2121