Skip to content

Instantly share code, notes, and snippets.

View discordianfish's full-sized avatar

Johannes 'fish' Ziemke discordianfish

View GitHub Profile
@discordianfish
discordianfish / README.md
Last active March 6, 2023 13:21
DIAMBRA Engine Troubleshooting

Run DIAMBRA Engine without CLI

Agents connect via network using gRPC to DIAMBRA Engine running in a Docker container. The diambra CLI's run command starts the DIAMBRA Engine in a Docker container and sets up the environment to make it easy to connect to the Engine. For troubleshooting it might be useful to run the Engine manually, using hostnetworking.

Creating the ~/.diambra and ~/.diambra/credentials is only needed when you never ran the diambra cli before. Otherwise this step can be skipped.

Start Engine

Linux/MacOS:

@discordianfish
discordianfish / ecs
Last active February 17, 2023 13:37
chatgpt generated ecs cli
#!/bin/bash
ECS_CONTEXT_FILE=~/.ecs/context
# Check if the ECS context file exists
if [ -f "$ECS_CONTEXT_FILE" ]; then
# Read the active cluster from the ECS context file
ECS_CLUSTER=$(cat "$ECS_CONTEXT_FILE")
fi
@discordianfish
discordianfish / bundle-bin.sh
Created October 27, 2022 10:49
Script to copy binaries including their dynamically linked libraries to a target directory, useful for creating minimal container/docker images
#!/bin/bash
set -euo pipefail
BIN=$1
TARGET=$2
mkdir -p "$TARGET"
bundle() {
lib="$1"
target="$2"
@discordianfish
discordianfish / README.md
Last active February 7, 2022 21:40
Simple "VPN" to connect k3s to apiserver with private IP

My k3s server is running on 192.168.1.1 in my LAN. While I can expose the TLS endpoint to the public internet, my IP is dynamic. This doesn't play well with Kubernetes since when kubelet is connecting to the TLS endpoint, it retrieves a list of apiservers and tries to connect to them directly. So instead I add the apiserver's private IP to the loopback interface and run an ssh tunnel to forward it.

So with the unit file above, you can join a node with:

curl -sfL https://get.k3s.io | K3S_URL=https://192.168.1.1:6443 K3S_TOKEN=mynodetoken sh -
@discordianfish
discordianfish / lsdisks
Created January 9, 2022 13:02
List disks with path and id(s)
#!/bin/bash
set -euo pipefail
declare -A paths
declare -A ids
for f in /dev/disk/by-path/*; do
[[ "$f" == *"-part"* ]] && continue
paths[$(readlink -f "$f")]+="$(basename "$f") "
done
@discordianfish
discordianfish / nginx.conf
Created November 19, 2021 10:35
minimal nginx config with CORS and COEP headers set
daemon off;
events {}
error_log /dev/stdout info;
http {
include /usr/local/etc/nginx/mime.types;
access_log /dev/stdout;
server {
Guten Tag,
vor einiger Zeit haben Sie auf unserer Petitionsplattform WeAct einen Appell
unterzeichnet. Nach dem Unterzeichnen wollten Sie allerdings nicht weiter über
WeAct oder einzelne Petitionen informiert werden. Es tut uns leid, dass wir Sie
heute dennoch anschreiben müssen.
Leider ist es nämlich auf WeAct zu einem Daten-Problem gekommen, von dem auch
Sie betroffen sind. Wir sind daher nach den Vorgaben der
Datenschutzgrundverordnung dazu verpflichtet, Ihnen diese Mail zu senden.
#!/bin/bash
set -euo pipefail
TMP=$(mktemp -d)
trap "rm -r '$TMP'" EXIT
cd "$TMP"
NAMESPACE=custom-metrics
NAME=custom-metrics-apiserver.$NAMESPACE
{
"data": {
"type": "match",
"id": "64cd06de-00a2-4a20-8537-45ff72fa45c0",
"attributes": {
"createdAt": "2018-04-03T22:50:59Z",
"duration": 1948,
"gameMode": "duo-fpp",
"patchVersion": "",
"shardId": "pc-eu",
@discordianfish
discordianfish / README.md
Created April 2, 2018 16:53
Snippets to help converting kubernetes env variables to secrets + references

Convert deployment manifest env to secret ref

cat deployment.yaml | yaml2json \
  | jq '.spec.template.spec.containers[0].env|map(.key = .name)|map(.valueFrom = { "secretKeyRef": { "name": "secret-name", "key": .key|ascii_downcase }}|del(.value))' \
  | json2yaml

Convert deployment manifest env to secret data mapping:

cat deployment.yaml | yaml2json \