Skip to content

Instantly share code, notes, and snippets.

View dwdraju's full-sized avatar

Raju Dawadi dwdraju

View GitHub Profile
@dwdraju
dwdraju / gcloud-sql-import.md
Last active June 23, 2018 06:24
Import sql file to google cloud sql
@dwdraju
dwdraju / gcs-hacks.md
Last active January 1, 2019 18:39
Gcloud Cloud Storage - Size, Bucket LifeCycle
{
"lifecycle": {
  "rule": [
  {
    "action": {"type": "Delete"},
    "condition": {
      "age": 7,
    }
 }
@dwdraju
dwdraju / gke-pod-access.md
Last active June 18, 2018 09:23
Accessing kubernetes pod in GKE
@dwdraju
dwdraju / docker-install.md
Last active August 1, 2018 10:34
Install docker Ubuntu
sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    software-properties-common -y && \
    curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - && \
    sudo apt-key fingerprint 0EBFCD88
@dwdraju
dwdraju / vault-unseal
Created June 15, 2018 09:15
vault-unseal
egrep -m3 '^Unseal Key' vault-key.txt | cut -f2- -d: | tr -d ' ' | while read key; do vault unseal ${key}; done
@dwdraju
dwdraju / os-nova.py
Created June 9, 2018 18:51
os-client
from os import environ as env
from novaclient import client
VERSION="2"
USERNAME=env['OS_USERNAME']
PASSWORD=env['OS_PASSWORD']
PROJECT_ID=env['OS_PROJECT_NAME']
AUTH_URL=env['OS_AUTH_URL']
nova = client.Client(VERSION, USERNAME, PASSWORD, PROJECT_ID, AUTH_URL)
@dwdraju
dwdraju / kubectl-cp.md
Created June 4, 2018 05:40
kubectl copy files to and from multiple pods

for podname in $(kubectl get pods -o json| jq -r '.items[].metadata.name'); do kubectl cp "${podname}":/opt ${podname}; done

Get pods with container image

http http://localhost:8001/api/v1/namespaces/default/pods | jq '.items[] | .spec.containers[].image + "       " + .metadata.name'

Get node names

http http://localhost:8001/api/v1/nodes | jq '.items[].metadata.name'
@dwdraju
dwdraju / kubectl-trick.md
Last active June 23, 2018 06:33
kubectl-trick
  • Run single pod
  kubectl run --generator=run-pod/v1 foobar --image=nginx
  • Get yaml without unusable variables
kubectl get deployments ghost --export -n ghost -o yaml
@dwdraju
dwdraju / watch-file.sh
Created May 15, 2018 06:52
Watch file content change with md5 hash
FILE=test2; tail -F $FILE 2>/dev/null | ( while read; do NEWHASH=$(md5sum $FILE | cut -d\ -f1); if [ "$HASH" != "$NEWHASH" ]; then echo "File changed!"; HASH=$NEWHASH; fi; done; )