Skip to content

Instantly share code, notes, and snippets.

@lalyos
lalyos / kubectl_get_resource.sh
Last active November 25, 2018 12:35
fix kubectl autocomplete
## usage: . <(curl -sL bit.ly/kubectl-fix)
if ! [[ "$KUBECTL_AUTOCOMP_FIXED" ]]; then
__kubectl_get_resource () { if [[ ${#nouns[@]} -eq 0 ]]; then local kubectl_out; if kubectl_out=$(kubectl api-resources $(__kubectl_override_flags) -o name --cached --verbs=get 2>/dev/null); then COMPREPLY=($( compgen -W "${kubectl_out[*]}" -- "$cur" )); return 0; fi; return 1; fi; __kubectl_parse_get "${nouns[${#nouns[@]} -1]}"; }
KUBECTL_AUTOCOMP_FIXED=1
fi
@lalyos
lalyos / minikube-hyperkit.md
Last active September 4, 2018 12:42
minikube with hyperkit

minikube is an easy way to work with local kubernetes on osx. By default its uses VirtulBox to create a VM which hosts docker/kubernetes. But you can use different vm drivers to manage the VM. Hyperkit seems to be a more reliable hypervisor.

The rest of this document explains how to use minikube with the hyperkit driver

install minikube

You can check if you have minikube installed:

$ minikube version
@lalyos
lalyos / etcd-list-keys.md
Last active April 26, 2024 16:14
k8s etcd list keys

You can demostrate how kubernetes stores everything in etcd (v3):

One-liner

You can exec etcdctl rigth in the etc pod:

kubectl exec -it \
  -n kube-system etcd-minikube \
  -- sh -c 'ETCDCTL_CACERT=/var/lib/localkube/certs/etcd/ca.crt \
 ETCDCTL_CERT=/var/lib/localkube/certs/etcd/peer.crt \
@lalyos
lalyos / openresty.md
Created June 28, 2018 09:15
openresty lua sample docker

use openresty/openresty:alpine as a base image it has an /etc/nginx/conf.d/ dir

    location /lua {                                                                                    
      content_by_lua '                                                                                 
        ngx.say("hello from lua")                                                                      
        ngx.say("host: ", os.getenv("HOSTNAME"))                                                       
      ';                                                                                               
    }                                                                                                  
@lalyos
lalyos / README.md
Created June 26, 2018 15:06
k8s nginx expose logs to a browser as http ws via sidecar

Install

apt-get -qq update
apt-get install -y curl unzip # jq neovim procps dnsutils
curl -LO https://github.com/joewalnes/websocketd/releases/download/v0.3.0/websocketd-0.3.0-linux_amd64.zip
cp ./websocketd /usr/local/bin/
unzip websocketd-0.3.0-linux_amd64.zip
@lalyos
lalyos / web.yaml
Last active July 2, 2018 05:44
config map example
apiVersion: v1
data:
index.html: hello from config
kind: ConfigMap
metadata:
name: webconfig
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
@lalyos
lalyos / README.md
Last active June 26, 2025 10:23
k8s with curl
curl -s -k \
  --cert ~/.minikube/client.p12 \
  --key  ~/.minikube/client.key \
  --pass tcuser \
  https://192.168.64.8:8443/api/v1/pods \
    |jq '.items[].metadata.name'
@lalyos
lalyos / pwd-api.md
Last active March 15, 2018 22:03
play with docker API pwd

save session id

export SESSION=balei8na02jg00e4suhg

create instance:

curl https://labs.play-with-docker.com/sessions/$SESSION/instances -X POST
@lalyos
lalyos / worshop.md
Last active January 30, 2018 18:06
docker hybrid workshop