Skip to content

Instantly share code, notes, and snippets.

@lalyos
lalyos / README.md
Last active May 7, 2019 10:27
craft lunch

bla bla

kubectl apply ...

Copyright 2019

@lalyos
lalyos / compile-kubectl.ms
Created May 6, 2019 17:25
compile kubectl from source
## compile kubectl
./hack/build-go.sh
./hack/build-go.sh cmd/kubectl
KUBE_VERBOSE=9 V=9 make --no-print-directory -C ./hack/.. all WHAT=cmd/kubectl
./hack/make-rules/build.sh cmd/kubectl
@lalyos
lalyos / compose-on-kubernetes.md
Last active December 6, 2018 11:11
compose-on-kubernetes running on GKE

Docker just opensourced compose-on-kubernetes (COK for short), and I wanted to run on GKE. This is the jurney:

Architecture

You will be able to use plain-old-compose files against k8s. Actually the docker-compose.yml have to be transformed to a Stack CustomResourceDefinition, and than a controller will take care of creating the all the necesseary k8s resources (deployments, services)

You can create those CRDs in 2 ways:

@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: