Skip to content

Instantly share code, notes, and snippets.


Cory O'Daniel coryodaniel

Block or report user

Report or block coryodaniel

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
coryodaniel / weird.mock.ex
Created Jun 27, 2019
Per process / test mock
View weird.mock.ex
defmodule K8s.Mock do
@moduledoc """
A single interface to use for an environment, but allow each process to define its own module that implements behaviors to respond.
Good for tests, two tests can independently register the HTTP responses they should receive w/o having the confusing shared http_provider mock currently in k8s
use GenServer
# TODO methods that the http behavior has go here, when executing should look up
# the registered module for the calling pid
View nginx.pod.yaml
apiVersion: v1
kind: Pod
name: nginx
name: nginx
- name: nginx
image: nginx
coryodaniel / k8s.ex
Last active Jun 21, 2019
K8s.Controller to k8s client?
View k8s.ex
# Thinking about moving controller functionality from Bonny to K8s.
# Currently k8s is very focused around HTTP, but controllers are a common concept, so YMMV.
# This may be a piece of yarn, and end up pulling too much operator functionality.
# In that case, I'm using this for spit balling the API for Bonny v1.
# Start a new controller w/ default
K8s.Controller.start("", :bars, mod: BarController)
K8s.Controller.start("", :bars,
mod: BarController,
coryodaniel /
Created Jun 19, 2019
Thoughts about errors & logging

When an error occurs in a function and there is no expectation that the caller can deal with it, returning {:error, error} feels noisy.

Is this better? It makes the assumption that the caller doesnt care. The error is logged for a human operator to see.

def get_some_pods() do
  response = Client.get_pods()
  case response do
coryodaniel / unique_test_id.ex
Last active Jun 16, 2019
ExUnit Unique Test Identifier
View unique_test_id.ex
# I forget how to get the test "id" constantly.
defmodule FooTest do
@moduledoc false
use ExUnit.Case, async: true
test "show that ID", ctx do
IO.puts ctx[:test]
coryodaniel / state-nabber.rb
Created May 15, 2019
Nab some values out of a terraform state file
View state-nabber.rb
#! /usr/bin/env ruby
require "json"
resources = [
# "google_service_account.my_service_account",
file ="state.json")
coryodaniel /
Last active Mar 27, 2019
Connect to a failing kubernetes pod to inspect mounts, etc

Update the command/args:

command: [ "/bin/sh", "-c", "--" ]
args: [ "while true; do sleep 30; done;" ]

Run a command

kubectl exec my-pod -c my-container -- ls /
coryodaniel /
Created Mar 13, 2019
GKE make me cluster admin
kubectl create clusterrolebinding "cluster-admin-$(whoami)" --clusterrole=cluster-admin --user="$(gcloud config get-value core/account)"
coryodaniel /
Created Mar 12, 2019
Escaping dot/period in jsonpath
kubectl get secrets ${secret_name} -o "jsonpath={.data['ca\.crt']}" | base64 -D
coryodaniel / job.yaml
Created Mar 8, 2019
cluster bootstrap job
View job.yaml
apiVersion: batch/v1
kind: Job
name: bootstrapper
name: bootstrapper
You can’t perform that action at this time.