Skip to content

Instantly share code, notes, and snippets.

View mjhuber's full-sized avatar

Micah Huber mjhuber

View GitHub Profile
@mjhuber
mjhuber / readme.md
Last active September 8, 2020 17:53
istio

Istio

istioctl

istioctl is the main tool used to interact with istio in a cluster. You can install it with brew:

brew install istioctl

Debug steps

@mjhuber
mjhuber / upgrade.md
Last active April 6, 2020 14:53
taint based gke upgrade

GKE Upgrades

  1. Upgrade the masters. This is done by incrementing the google_container_cluster.min_master_version field to the desired version. Masters will update one by one.
  2. Create new node pools using the new version.
  3. Taint the old nodes. Pods will get scheduled onto the new nodes.
$ kubectl get nodes --no-headers -l cloud.google.com/gke-nodepool=<node-pool-name> | awk '{print $1}' | xargs -I kubectl taint nodes {} legacy=true:NoExecute
  1. Leave the old node pools around for a couple of weeks but scale them to 0. They'll be available if we need to go back.
@mjhuber
mjhuber / main.go
Last active February 5, 2020 13:49
We All Love Reflection
package main
import (
"fmt"
"reflect"
"regexp"
"strings"
)
// Test is a test struct
@mjhuber
mjhuber / main.go
Created December 20, 2019 20:48
Traverse a nested object by yaml/json tags
package main
import (
"fmt"
"reflect"
"regexp"
"strings"
)
type Monitor struct {
version: '3.1'
services:
mongo:
image: mongo:4.0
restart: always
networks:
- n8n
environment:
@mjhuber
mjhuber / resources.sh
Created May 7, 2019 20:28
Get k8s resources
#!/usr/bin/env bash
NAMESPACE="default"
DEPLOYMENTS=$(kubectl get deploy -n $NAMESPACE --no-headers | awk '{print $1}')
for deploy in $DEPLOYMENTS; do
echo "$deploy"
resources=$(kubectl get deploy/$deploy -n $NAMESPACE -o json | jq '.spec.template.spec.containers[0].resources')
mem_limit=$(echo $resources | jq '.limits.memory')
mem_req=$(echo $resources | jq '.requests.memory')
@mjhuber
mjhuber / init.coffee
Last active June 28, 2019 19:01
Atom-settings-sync
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->
@mjhuber
mjhuber / readme.md
Last active January 15, 2019 15:36
kubehunter

Running kubehunter

  1. Go to https://kube-hunter.aquasec.com/ and generate a token.
  2. Install the chart with reckoner.
namespace: infra
repository: stable
minimum_versions:
 helm: 2.10.0
@mjhuber
mjhuber / HelmPrivs.yml
Created December 3, 2018 15:58
Helm in a non default namespace
apiVersion: v1
kind: Namespace
metadata:
name: helm-system
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: tiller
namespace: helm-system
@mjhuber
mjhuber / readme.md
Last active October 24, 2018 13:49
setting up the .ninja ingress

Setting up an Ingress

Setting up an ingress involves a few steps:

  1. Installing an ingress controller. Nginx is the most common ingress controller. The helm chart is available here.

To identify the ingress controller, we assign it a name as an "ingress class" which can be used later to refer to it in the ingress object.