Skip to content

Instantly share code, notes, and snippets.

@alexeldeib
alexeldeib / repro.sh
Last active April 28, 2023 16:53
debug exit vs stdout and failures
#!/usr/bin/env bash
retrycmd_if_failure() {
retries=$1; wait_sleep=$2; timeout=$3; shift && shift && shift
for i in $(seq 1 $retries); do
timeout $timeout "${@}" && break || \
if [ $i -eq $retries ]; then
echo Executed \"$@\" $i times;
return 1
else
sleep $wait_sleep
@alexeldeib
alexeldeib / runtimes.yaml
Created April 27, 2023 15:44
WASM runtime classes
---
apiVersion: node.k8s.io/v1
kind: RuntimeClass
metadata:
name: wasmtime-spin-v0-3-0
handler: "spin-v0-3-0"
scheduling:
nodeSelector:
"kubernetes.azure.com/spin-v0-3-0": "true"
---
@alexeldeib
alexeldeib / README.md
Last active June 18, 2024 15:25
Join unmanaged nodes to AKS

Usage

Assuming you already have a usable kubeconfig with sufficient privileges:

KUBE_CA="$(kubectl -n kube-public get cm kube-root-ca.crt -o jsonpath="{.data.ca\.crt}" | base64 -w0)"
FQDN="$(kubectl config view --minify --output jsonpath='{.clusters[0].cluster.server}')"
TOKEN="$(kubeadm token create)"

sed -i "s|KUBE_CA_CERT_PLACE_HOLDER|${KUBE_CA}|g" ./bootstrap.sh
@alexeldeib
alexeldeib / main.go
Last active March 31, 2023 16:29
unpack/repack containerd snapshot manually
package main
import (
"context"
"fmt"
"log"
"os"
"time"
"github.com/containerd/containerd"
@alexeldeib
alexeldeib / doc.md
Created March 17, 2023 15:04
GPT4 explains Linux networking

Q: Can you explain the flow of a packet from a user through a load balancer to a linux machine across a bridge interface to a container veth in a separate network namespace?

A: Yes, I can explain the flow of a packet from a user through a load balancer to a Linux machine across a bridge interface to a container veth in a separate network namespace. Here's a step-by-step explanation of the process:

  1. User sends a packet: A user (client) initiates a connection to a service, typically by sending a request to a specific IP address and port number. The packet contains source and destination IP addresses and port numbers.
  2. Load balancer: The request reaches a load balancer, which is responsible for distributing incoming network traffic across multiple servers to ensure that no single server is overwhelmed with too much traffic. The load balancer uses algorithms like round-robin, least connections, or other custom rules to determine which server should handle the request. It then forwards the packet to the
@alexeldeib
alexeldeib / envoy.yaml
Last active March 17, 2023 18:41
envoy https + https proxy connect listener
admin:
access_log_path: /tmp/admin_access.log
address:
socket_address:
address: 127.0.0.1
protocol: TCP
port_value: 9901
static_resources:
listeners:
- name: listener_0
@alexeldeib
alexeldeib / provision_start.sh
Created March 9, 2023 15:12
AKS minimal node join script
#!/usr/bin/env bash
die() { echo "$*" 1>&2 ; exit 1; }
if [ -z "${API_SERVER_NAME}" ]; then
die "API_SERVER_NAME must contain Kubernetes API server FQDN for node join."
fi
if [ -z "${TLS_BOOTSTRAP_TOKEN}" ]; then
die "TLS_BOOTSTRAP_TOKEN must TLS bootstrap token for node join."
@alexeldeib
alexeldeib / config.proto
Last active February 16, 2023 17:53
Analysis of AKS node provisioning variables
syntax = "proto3";
package agentbaker.v1;
// illustrative division only
message Configuration {
// System Configuration
string api_server_endpoint = 1;
string cluster_certificate_authority = 2;
@alexeldeib
alexeldeib / code.py
Created February 12, 2023 21:55
PM2.5/CO2/Humidity - RP2040 Trinkey + SCD41 + BME680 + PMSA0003I CircuitPython + Featherwing LCD
import time
import board
import busio
import displayio
import terminalio
# import specific sensor libs
import adafruit_scd4x
import adafruit_bme680
from adafruit_pm25.i2c import PM25_I2C
@alexeldeib
alexeldeib / proxy.yaml
Last active January 13, 2023 22:15
Override AKS HTTP proxy variables per pod (explicit or with config map)
---
apiVersion: v1
kind: ConfigMap
metadata:
name: proxy-config
namespace: default
data:
NO_PROXY: &no_proxy "foo"
no_proxy: *no_proxy # avoid repetition by using yaml anchors if desired
http_proxy: &http_proxy ""