Skip to content

Instantly share code, notes, and snippets.

View JoooostB's full-sized avatar
☁️
Cloudy with a chance of downtime.

Joost Buskermolen JoooostB

☁️
Cloudy with a chance of downtime.
View GitHub Profile
@JoooostB
JoooostB / force-delete-ns.sh
Created January 15, 2024 15:07
You've tried anything, and still can't delete one or multiple namespaces that are stuck in Terminating? Try this after starting a kubectl proxy instead:
for NAMESPACE in list of namespaces; do kubectl get namespace $NAMESPACE -o json |jq '.spec = {"finalizers":[]}' >${NAMESPACE}.json; curl -k -H "Content-Type: application/json" -X PUT --data-binary @${NAMESPACE}.json 127.0.0.1:8001/api/v1/namespaces/$NAMESPACE/finalize; done
@JoooostB
JoooostB / servicemonitor-kubelet.yaml
Created December 28, 2023 09:58
Scrape kubelet & cAdvisor metrics using ServiceMonitor below
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
labels:
app: kubelet
scraper: prometheus-agent
name: kubelet
spec:
endpoints:
- bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token
@JoooostB
JoooostB / .zshrc
Created March 6, 2023 10:46
Merge all Kubernetes cluster config files into one
...
if [ -d ~/.kube/configs ]; then
if [ -z "$KUBECONFIG_MANUAL" ]; then
export KUBECONFIG=$(find -L ~/.kube/configs -name "*.yaml" -type f 2>/dev/null | xargs -I % echo -n ":%")
fi
fi
...
@JoooostB
JoooostB / external-secrets-key-prefix.yaml
Last active January 11, 2023 14:02
Gatekeeper ConstraintTemplate that validates if the prefix of a namespace (all characters until first -) is equal to spec.dataFrom.*.extract.key or spec.data.*.remoteRef.key from an ExternalSecret. This ensures teams can only access their own prefixed secrets.
kind: ConstraintTemplate
apiVersion: templates.gatekeeper.sh/v1beta1
metadata:
name: externalsecretskeyprefix
annotations:
argocd.argoproj.io/sync-wave: "2"
argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true
description: >-
Validates if the prefix of a namespace (all characters until first -) is equal to spec.dataFrom.*.extract.key or spec.data.*.remoteRef.key from an ExternalSecret.
This ensures teams can only access their own secrets.
@JoooostB
JoooostB / end.gcode
Created December 10, 2022 11:46
Creality Ender 3 V2 GCODE start & end instructions
G91 ;Relative positioning
G1 E-2 F2700 ;Retract a bit
G1 E-2 Z0.2 F2400 ;Retract and raise Z
G1 X5 Y5 F3000 ;Wipe out
G1 Z10 ;Raise Z more
G90 ;Absolute positionning
G1 X0 Y{machine_depth} ;Present print
M106 S0 ;Turn-off fan
M104 S0 ;Turn-off hotend
@JoooostB
JoooostB / es-docker-hub.yaml
Created October 5, 2022 06:39
ExternalSecret to create Docker Hub- or any other imagePullSecret from AWS Secret Manager
apiVersion: external-secrets.io/v1beta1
kind: ExternalSecret
metadata:
name: es-docker-hub-token
spec:
data:
- remoteRef:
key: /eks/docker-hub-token
secretKey: token
refreshInterval: 1h
@JoooostB
JoooostB / k8s-postgres-probes.md
Last active June 7, 2022 12:15
Readiness- & Livenessprobes for PostgreSQL on Kubernetes using environment variables

I always end up reinventing the wheel when setting up Readiness- & LivenessProbes for Postgres deployments on Kubernetes, which is why I decided to share it here for others to enjoy too.

As you'd like to use environment variables, make sure to prefix the readiness and liveness commands with bash -c:

readinessProbe:
  exec:
    command: ["bash", "-c", "psql -w -U $POSTGRES_USER -d $POSTGRES_DB SELECT 1"]
  initialDelaySeconds: 15
 timeoutSeconds: 2
import utime
import struct
import urandom
from ulora import TTN, uLoRa
from machine import Pin
# Refer to device pinout / schematics diagrams for pin details
# (https://www.thethingsnetwork.org/forum/t/big-esp32-sx127x-topic-part-3/18436)
LORA_CS = const(18)
LORA_SCK = const(5)
@JoooostB
JoooostB / traefik-forward-auth.yaml
Created January 26, 2020 16:38
Traefik Forward Auth for Traefik V2 on Kubernetes
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: traefik-sso
labels:
app: traefik-sso
spec:
template:
metadata:
labels:
@JoooostB
JoooostB / decryptor.py
Created July 5, 2019 09:37
Polybius Square Decryptor - Copenhagen Security Summer Camp - KEA
import re
encrypted = 'ENCODED THINGY HERE'
# Change the cipher accordingly
dict = {
"13": "E",
"33": "T",
"21": "O",
"53": "N",