Cheatsheets

k8s

  • Deploy pod with AWS tools
    apiVersion: v1
    kind: Pod
    metadata:
      name: aws-toolkit
    spec:
      containers:
      - image: jshimko/kube-tools-aws:latest
        name: aws-toolkit
        command: [ "/bin/bash", "-c", "--" ]
        args: [ "while true; do sleep 30; done;" ]
  • Scale up all deployments in NS
    kubectl get deployment -o json | jq  -r '.items[] | .metadata.name ' | xargs -I{} kubectl scale {} --replicas=3
  • Show all resources in namespace
    kubectl api-resources -o name | xargs -I {} kubectl get {} --show-kind --ignore-not-found
  • Troubleshoot DNS resolution with infoblox tools
    kubectl run -it --rm --restart=Never --image=infoblox/dnstools:latest dnstools
  • port fwd with selector
    kubectl port-forward -n xxx "$(kubectl get -n xxx pod --selector=nginxhello=app -o jsonpath='{.items..metadata.name}')" 4040
    
    

VIM

  • Remove all comments from vim console
    g/\v^(#|$|;)/d