Skip to content

Instantly share code, notes, and snippets.

View coryodaniel's full-sized avatar
☘️
O'Internets

Cory O'Daniel coryodaniel

☘️
O'Internets
View GitHub Profile
apiVersion: apps/v1
kind: Deployment
metadata:
creationTimestamp: null
labels:
app: my-deployment
name: my-deployment
spec:
replicas: 1
selector:
./overlays/prod/kustomization.yaml
./overlays/staging/kustomization.yaml
./pasta
./base/deployment.yaml
./base/kustomization.yaml
@coryodaniel
coryodaniel / kustomize.vars.pasta
Last active October 7, 2019 18:53
Kustomize w/ per-overlay input vars (via pasta.rb)
eyIuL292ZXJsYXlzL3Byb2Qva3VzdG9taXphdGlvbi55YW1sIjoibmFtZXNwYWNlOiBwcm9kXG5iYXNlczpcbiAgLSAuLi8uLi9iYXNlXG5jb25maWdNYXBHZW5lcmF0b3I6XG4gIC0gbmFtZTogbXktY29uZmlnXG4gICAgYmVoYXZpb3I6IHJlcGxhY2VcbiAgICBsaXRlcmFsczpcbiAgICAgIC0gTUlYX0VOVj1wcm9kXG4iLCIuL292ZXJsYXlzL3N0YWdpbmcva3VzdG9taXphdGlvbi55YW1sIjoibmFtZXNwYWNlOiBzdGFnaW5nXG5iYXNlczpcbiAgLSAuLi8uLi9iYXNlXG4iLCIuL3Bhc3RhIjoiIyEgL3Vzci9iaW4vZW52IHJ1YnlcblxucmVxdWlyZSAnb3B0cGFyc2UnXG5yZXF1aXJlICdqc29uJ1xucmVxdWlyZSBcImJhc2U2NFwiXG5yZXF1aXJlICdmaWxldXRpbHMnXG5cbiRvdXQgPSBcIi90bXAvbG9sXCJcbm9wdGlvbnMgPSB7fVxuT3B0aW9uUGFyc2VyLm5ldyBkbyB8b3B0c3xcbiAgb3B0cy5iYW5uZXIgPSBcIlVzYWdlOiBwYXN0YS5yYiBbb3B0aW9uc11cIlxuXG4gIG9wdHMub24oXCItdlwiLCBcIi0tW25vLV12ZXJib3NlXCIsIFwiUnVuIHZlcmJvc2VseVwiKSBkbyB8dnxcbiAgICBvcHRpb25zWzp2ZXJib3NlXSA9IHZcbiAgZW5kXG5cbiAgb3B0cy5vbihcIi1wU1RSXCIsIFwiLS1wYXN0ZT1TVFJcIiwgXCJTdHJpbmcgdG8gcGFzdGVcIikgZG8gfHB8XG4gICAgb3B0aW9uc1s6cGFzdGVdID0gcFxuICBlbmRcblxuICBvcHRzLm9uKFwiLWNQQVRIXCIsIFwiLS1jb3B5PVBBVEhcIiwgXCJQYXRoIHRvIGNvcHlcIikgZG8gfGN8XG4gICAg
@coryodaniel
coryodaniel / pasta.rb
Last active October 7, 2019 18:50
pasta - copy and paste filesystems
#! /usr/bin/env ruby
require 'optparse'
require 'json'
require "base64"
require 'fileutils'
$out = "/tmp/lol"
options = {}
OptionParser.new do |opts|
@coryodaniel
coryodaniel / todo-crd.yaml
Created September 24, 2019 17:02
Todo CRD
kind: CustomResourceDefinition
apiVersion: apiextensions.k8s.io/v1beta1
metadata:
name: todos.todoapp.bonny.run
spec:
group: todoapp.bonny.run
names:
kind: Todo
plural: todos
shortNames:
@coryodaniel
coryodaniel / list-k8s-roles.sh
Last active September 20, 2019 16:34
Get rolebindings for a service account
# Bindings for a specific SA
kubectl get clusterrolebindings,rolebinding -o json | jq -r '
.items[] |
select(
.subjects // [] | .[] |
[.kind,.namespace,.name] == ["ServiceAccount","default","default"]
) |
.metadata.name'
# Summary of rolebindings, clusterrolebindings
@coryodaniel
coryodaniel / shell.yaml
Last active September 20, 2019 16:36
k8s pod shell
# Run shell in cluster w/ kubectl exec -it shell -- /bin/bash
apiVersion: v1
kind: Pod
metadata:
name: shell
spec:
containers:
- name: shell
#image: busybox
#image: byrnedo/alpine-curl
@coryodaniel
coryodaniel / weird.mock.ex
Created June 27, 2019 23:54
Per process / test mock
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
@coryodaniel
coryodaniel / nginx.pod.yaml
Created June 26, 2019 23:25
Basic Nginx Pod
apiVersion: v1
kind: Pod
metadata:
name: nginx
labels:
name: nginx
spec:
containers:
- name: nginx
image: nginx
@coryodaniel
coryodaniel / k8s.ex
Last active June 21, 2019 19:09
K8s.Controller to k8s client?
# 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("foo.example.com/v1", :bars, mod: BarController)
K8s.Controller.start("foo.example.com/v1", :bars,
mod: BarController,