Skip to content

Instantly share code, notes, and snippets.

Avatar

Mark Betz Markbnj

View GitHub Profile
View helpful kubernetes commands
get the IP addresses of a pod or pods
kubectl get pods [POD] -o=custom-columns=NAME:.metadata.name,PODIP:.status.podIP
get the name of the node a pod is scheduled on
kubectl get pods [POD] -o=custom-columns=name:.metadata.name,node:.spec.nodeName
get the resource requests and limits for a deployment
kubectl get deployment [DEPLOYMENT] -o go-template --template="{{range .spec.template.spec.containers}}{{printf \"%s %s\n\" .name .resources}}{{end}}"
get pods that have a >0 restart count
View download.py
import threading
from contextlib import closing
import requests
from Queue import Queue
input_file = u"test_input.txt"
def on_download_complete(url, file_name):
@Markbnj
Markbnj / geonames-org-wrapper.py
Created Aug 11, 2015
A simple geonames.org wrapper in python
View geonames-org-wrapper.py
import requests
import json
# For information on endpoints and arguments see the geonames
# API documentation at:
#
# http://www.geonames.org/export/web-services.html
class Geonames(object):
@Markbnj
Markbnj / check_docker.sh
Created Oct 17, 2015
Check kernel configuration for docker compatibility
View check_docker.sh
curl https://raw.githubusercontent.com/docker/docker/master/contrib/check-config.sh | bash
# yes, I know
@Markbnj
Markbnj / docker-inject-ec2-host-ip.sh
Created Aug 11, 2015
Inject the ec2 instance private IP into a docker container at start
View docker-inject-ec2-host-ip.sh
# Sometimes you need to get the IP of the ec2 instance a container
# is running on. This script will get the IP from the local metadata
# service and inject it as an environment var.
localip=$(curl -s http://169.254.169.254/latest/meta-data/local-ipv4)
export HOST_IP=$localip
sudo docker run -i -t -e "HOST_IP=$localip" --name="test" -h="test" some-repo
View keybase.md

Keybase proof

I hereby claim:

  • I am markbnj on github.
  • I am markbnj (https://keybase.io/markbnj) on keybase.
  • I have a public key ASAurAAcEgjhAvcXHWw1ujCICb_8e98HV3FWERnAIkDu5go

To claim this, I am signing this object:

View validator.py
import json
import os
from bravado_core.spec import Spec
from bravado_core.validate import validate_object
from yaml import load, Loader, dump, Dumper
def validate_car(car):
validate_object(spec, Car, car)
View mycars_app.py
import json
import os
import syslog
import validator
from flask import Flask, request, make_response
from jsonschema.exceptions import ValidationError
class BadRequestError(Exception):
""" Signals a malformed request body
View swagger-spec-4.yaml
paths:
/swagger:
get:
summary: Return swagger API specification
description: |
Returns the My Cars API spec as a json swagger doc.
tags:
- Meta
responses:
'200':
View swagger-spec-3.yaml
Car:
type: object
required:
...
properties:
...
registration:
$ref: '#/definitions/Registration'