Skip to content

Instantly share code, notes, and snippets.

View Stono's full-sized avatar
💭
coding!

Karl Stoney Stono

💭
coding!
View GitHub Profile
@Stono
Stono / gzip-decompressor.yaml
Created February 3, 2024 11:38
Gzip decompression EnvoyFilter
apiVersion: networking.istio.io/v1alpha3
kind: EnvoyFilter
metadata:
annotations:
description: Adds an accept-encoding (gzip) header to outbound requests, decompresses
responses
name: Enable compressed requests between services
name: enforce-compression
spec:
configPatches:
@Stono
Stono / gzip-compressor.yaml
Last active December 17, 2024 18:39
Gzip compression EnvoyFilter
apiVersion: networking.istio.io/v1alpha3
kind: EnvoyFilter
metadata:
annotations:
description: Ensures all Sidecars are capable of returning a gzip response
name: Enable Gzip
name: enable-gzip
namespace: istio-system
spec:
configPatches:
@Stono
Stono / shutdown-sidecar-handler.ts
Created July 18, 2023 13:14
shutdown sidecar handler
import { retry } from '@at/infrastructure-runtime-common/decorators'
import { isRejected } from '@at/infrastructure-runtime-common/utils/promises'
import type { Kubernetes } from '@at/kubernetes'
import { PatchType } from '@at/kubernetes/client'
import type { Models } from '@at/kubernetes/models'
import { KubernetesEventType } from '@at/kubernetes/watchClient'
import { Logger } from '@at/platform-logger'
import { EventHandler } from 'lib/handlers/eventHandler'
import type { ObserverHandlerOptions } from 'types/dynamic/server'
@Stono
Stono / x-workload-name-envoyfilter.yaml
Created October 15, 2021 15:15
Adds a workload name header to outbound requests in istio
apiVersion: networking.istio.io/v1alpha3
kind: EnvoyFilter
metadata:
name: add-x-workload-header
namespace: istio-system
annotations:
name: Add Workload Header
description: Adds an x-workload-header
spec:
configPatches:
#!/bin/bash
TOTAL=$(istioctl proxy-status | tail -n +2 | awk '{print $7}' | wc -l)
prog() {
local w=100 p=$1; shift
pct="$(( $p*$w/$TOTAL ))"
printf -v dots "%*s" "$pct" ""; dots=${dots// /.};
printf "\r\e[K|%-*s| %3d %%" "$w" "$dots" "$pct";
}
groups:
# These sum(irate()) functions are in separate groups, so they run in parallel
- name: istio.workload.istio_request_duration_milliseconds_bucket
interval: 10s
rules:
- record: workload:istio_request_duration_milliseconds_bucket:rate1m
expr: |
sum(irate(istio_request_duration_milliseconds_bucket{reporter="source", source_workload!=""}[1m]))
by (
@Stono
Stono / pilot-agent-agent
Created June 25, 2019 16:14
A wrapper entrypoint for istio-proxy, which makes it slightly more graceful shutting down and also adds support for calling envoys quitquitquit endpoint
#!/bin/bash
echo "Starting custom autotrader pilot-agent wrapper..."
echo "Pilot-agent args: $@"
/usr/local/bin/pilot-agent "$@" &
AGENT_PID=$!
echo "Pilot agent started with pid: $AGENT_PID"
log() {
echo "[pilot-agent-agent] $*"
#!/usr/bin/ruby
require 'json'
require 'net/http'
require 'shellwords'
require 'time'
require 'uri'
require 'yaml'
@target_sidecar_image = YAML.load(YAML.load(`kubectl --namespace=istio-system get configmap istio-sidecar-injector -o yaml`)['data']['config'])['template'].match(/.*(eu.gcr.io\/at-artefacts\/platform-istio-proxy.*)".*/)[1]
#!/bin/bash
echo "Deleting istio components..."
array=( istio istio-crd istio-grafana istio-prometheus istio-jaeger kube-state-metrics prometheus-alertmanager )
for i in "${array[@]}"
do
echo " - Removing: $i"
helm del --purge $i
done
#!/bin/bash
set +e
rm -rf /tmp/istio-debug*
mkdir /tmp/istio-debug
cd /tmp/istio-debug
for pod in $(kubectl --namespace=istio-system get pods --no-headers -l istio=pilot | awk '{print $1}'); do
echo "Gathering info from $pod"
mkdir $pod
cd $pod