Skip to content

Instantly share code, notes, and snippets.

@iMartyn
iMartyn / create-helm-crds.md
Last active May 5, 2020 10:01
Create helm chart from cert-manager CRDs for pre-install

How to create a helm chart from the CRDs that jetstack provide

Requirements

  • curl
  • k8s-yaml-splitter (go get github.com/latchmihay/k8s-yaml-splitter)
  • gnu sed
  • yq (jq wrapper for yaml files - pip install yq)

Note

@iMartyn
iMartyn / terraform-debug.txt
Created February 24, 2020 12:33
Partial debug output
2020/02/24 13:32:25 [DEBUG] Starting graph walk: walkValidate
6e4374afabd81544fc5ebe", sending new deps
2020-02-24T13:32:25.087+0100 [INFO] plugin: configuring client automatic mTLS
2020-02-24T13:32:25.115+0100 [DEBUG] plugin: starting plugin: path=/home/martyn/src/github.com/freight-hub/infrastructure-terraform/environments/sandbox/aws/.terraform/plugins/linux_amd64/terraform-provider-aws_v2.50.0_x4 args=[/home/martyn/src/github.com/freight-hub/infrastructure-terraform/environments/sandbox/aws/.terraform/plugins/linux_amd64/terraform-provider-aws_v2.50.0_x4]
2020-02-24T13:32:25.115+0100 [DEBUG] plugin: plugin started: path=/home/martyn/src/github.com/freight-hub/infrastructure-terraform/environments/sandbox/aws/.terraform/plugins/linux_amd64/terraform-provider-aws_v2.50.0_x4 pid=17118
2020-02-24T13:32:25.115+0100 [DEBUG] plugin: waiting for RPC address: path=/home/martyn/src/github.com/freight-hub/infrastructure-terraform/environments/sandbox/aws/.terraform/plugins/linux_amd64/terraform-provider-aws_v2.50.0
@iMartyn
iMartyn / zonefile2hostsfile
Created September 19, 2018 10:20
awk and grep to convert dns zonefile to hosts file
#!/bin/bash
ZONEFILE=$1
grep 'ORIGIN\|A\W\+[0-9]\{1,3\}' $ZONEFILE | awk '{if ($1 == "$ORIGIN") {mydomain=$2} else if ($2 == "A") {print $3 " " mydomain} else {{print $4 " " $1 "." mydomain}}}'
@iMartyn
iMartyn / keybase.md
Created April 4, 2018 12:10
2018 keybase proof

Keybase proof

I hereby claim:

  • I am iMartyn on github.
  • I am imartyn (https://keybase.io/imartyn) on keybase.
  • I have a public key whose fingerprint is 4B37 1244 4E36 6B22 E2B7 8CA9 C6EE 3F21 DD37 0D86

To claim this, I am signing this object:

@iMartyn
iMartyn / mini-port-forward.bash
Created December 20, 2017 17:34
Port-forward minikube ports to localhost ports
#!/bin/bash
MINIKUBE_IP=$(minikube ip)
MINIKUBE_KEY_LOCATION=${HOME}/.minikube/machines/minikube/id_rsa
STARTING_PORT=8080
CURRENT_PORT=${STARTING_PORT}
for servicename in $*; do
HIGH_PORT=$(kubectl get svc ${servicename} -o custom-columns=':spec.ports[*].nodePort' | tail -n1)
if echo $HIGH_PORT | grep -q ,; then

Because people don't seem to be getting why this is a bug, I'm gonna try and show it here in clear examples :

This example is of for example a nodejs microservice with pods with label app: data-app listening on Port: 3000 This is exposed as a service in the cluster as a http endpoint and should be accessible inside the cluster as http://coolservice(.namespace.svc.cluster.local)/ This should also be exposed as https://mycoolservice.example.com/ It should not be exposed inside the cluster as http://coolservice:443/ as that is whilst not RFC breaking afaik, extremely bad practice and extremely hard for users to reason about.

Exhibit A : Listens externally on port 80 as SSL! :

apiVersion: v1
@iMartyn
iMartyn / kubedump.bash
Last active August 14, 2017 17:27
Dump kubernetes cluster into folders containing yaml files
#!/bin/bash
CALLEDFROM=${PWD}
SEARCHFOR='^- apiVersion.*'
OPTIND=1
NAMESPACED=0
while getopts "n" opt; do
case "${opt}" in
n)
@iMartyn
iMartyn / gist:dc385c99493a2b853f033bf3455b1ac4
Created June 14, 2017 13:51
fluentd config based on tectonic's config
#general
<match fluent.**>
type null
</match>
<source>
@type http
port 9880
bind 0.0.0.0
</source>
<source>
@iMartyn
iMartyn / commit-msg
Last active January 20, 2021 14:01
Add Jira ref to commit messages
#!/bin/sh
# Uncomment below if you want the commit messages to start [refs: jira-123] or you'll just get [jira-123]
#PREAMBLE="refs: "
SED=sed
# If you're on mac and you don't have gnu sed installed, heaven help you.
if uname | grep "Darwin" 2>&1 > /dev/null; then
SED=gsed
# Put in your .bashrc :
#Include branch in prompt
__git_ps1 ()
{
local b="$(git symbolic-ref HEAD 2>/dev/null)";
if [ -n "$b" ]; then
printf " (%s)" "${b##refs/heads/}";
fi
}