Skip to content

Instantly share code, notes, and snippets.

View stevenctl's full-sized avatar

Steven Landow stevenctl

View GitHub Profile
@stevenctl
stevenctl / extract.sh
Created May 26, 2021 16:38
Split kubeconfig into individual files.
#!/bin/bash
cd "$(dirname "$0")"
for ctx in $(kubectl config get-contexts -o name); do
FILE="$ctx.yaml"
# if we have exactly 4 parts, it's probably a GKE cluster. Use the shortname and hope there aren't collisions.
SHORTNAME=$(echo $ctx | cut -d'_' -f4)
if [ -n $SHORTNAME ]; then
FILE=$SHORTNAME.yaml
fi
package main
import (
"fmt"
"sync"
"time"
"go.uber.org/atomic"
"istio.io/istio/pkg/config/schema/collections"
kubelib "istio.io/istio/pkg/kube"
#!/bin/bash
set -e
set -u
set -o pipefail
SERVICE="vm"
NAMESPACE="echo"
NETWORK=""
CLUSTER="Kubernetes"
@stevenctl
stevenctl / test-framework.md
Last active December 28, 2020 22:21
Istio Test Framework Wiki Updates
@stevenctl
stevenctl / main.go
Last active October 15, 2020 01:58
Istio Kubeconfig Extension
package main
import (
"fmt"
"encoding/json"
"istio.io/istio/pkg/kube"
"k8s.io/apimachinery/pkg/runtime"
)

Writing Good Tests

Keeping test times low

Re-use echos

Spinning up services for tests is one of the slower pieces of writing a test. Wherever possible, keep this setup in your suite's Setup to avoid long test times.

var (
# triggers a new "b" pod to be created
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: b
spec:
replicas: 1
selector:
matchLabels:
# scales deployment a to 500 replicas
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: a
spec:
replicas: 500
selector:
matchLabels:
# sets up a, b, c deployments with services for a and b
---
apiVersion: v1
kind: Service
metadata:
name: a
labels:
app: a
spec:
ports:
@stevenctl
stevenctl / delve-pilot.md
Last active January 20, 2023 20:07
Debugging Pilot in K8S

Debugging Pilot with Delve

First build pilot with GCFLAGS="all=-n -l":

GCFLAGS="all=-N -l" HUB=docker.io/slandow TAG=slandow BUILD_IN_CONTAINER=1 make docker.pilot

Then we can wrap that image in one that includes delve: