DNS is something so fundamental to most of our systems functioning that it’s often overlooked in initial troubleshooting, it’s also incredibly hard to troubleshoot if it’s only intermittently failing.
[Read More]GitLab Copy & Paste: Added Backticks
Running Multiple Server Processes From One Script
Doing local development on a bunch of interconnected services I often want to start multiple long running server processes.
This is the basic script I use for that.
[Read More]kubectx & kubens
When working with multiple Kubernetes clusters and namespaces switching context can be a chore.
For this I enjoy using kubectx and kubens.
They can be installed using kubectl krew
.
kubectl krew install ctx
kubectl krew install ns
Simple Redirect View for Django
I often find myself replacing an existing MVP based on static html with a Django app, or just needing to preserve some old URL scheme.
This is the code I use to do that:
from django.shortcuts import redirect
def redirect_view(request, redirectable, permanent=True):
return redirect(redirectable)
Which can then be used like this:
from django.urls import path
from . import views
urlpatterns = [
path("old-url/", views.redirect_view, {"redirectable": "new_view"}),
path("some-thing/", views.redirect_view, {"redirectable": "some_thing_new", permanent=False}),
]
Cleanup After Script Exit
Many of my scripts work with temporary files, usually relative to the scripts directory1,
while at the same time using set -e
to exit as soon as something fails.
In this scenario the script leaves behind these temporary files by default, which is not desireable.
We can however do a proper cleanup using the trap
concept.
iperf Cheatsheet
Vault CLI in Containers
In many CI/CD workflows interfacing with Hashicorp Vault is required.
However, their CLI (or better called unified binary1) is stupidly big with more than 400MB and they seem to have no interest in making it any smaller2.
This is often a undesired size increase, especially when optimizing for pull and run time in CI/CD.
This note outlines a solution that brings us down from 400MB+ on disk for vault
to about 300KB using curl
and jq
.
Caddy
Caddy: Manual Maintenance Mode
Coming from NGINX and others the concept of a maintenance mode that can be manually enabled is something I have used many times before.
With Caddy it is equally as easy, just using a less obvious syntax.
[Read More]Find files and folders with spaces
On Linux/Unix/MacOS:
find . | grep " "
On Windows:
Get-ChildItem -Path "." -Recurse -Filter "* *" | Format-Table FullName
PicoCSS Sticky Footer
A sticky footer using [[picocss]]
html,
body {
height: 100vh;
}
body > footer {
position: sticky;
top: 100vh;
}
HaProxy: Think About DNS Resolution
By default HAProxy resolves all DNS names in it’s config on startup and then never again.
This might cause issues down the road if DNS records, for example the ones for backends, change.
This section of the documentation is a good starting point as it describes IP address resolution using DNS in HAProy really well: https://docs.haproxy.org/3.0/configuration.html#5.3
Additionally this guide can also be helpful: https://www.haproxy.com/documentation/haproxy-configuration-tutorials/dns-resolution/
Renovate Bot: Limit Manager To Folder (Ignore Paths)
JQ Cheatsheet
sed: Delimiter Issues
When doing variable substitution with sed things break if the value contains the delimiter used by sed.
[Read More]Interactive Containers Cheatsheet
Most of these should work the same with any OCI compliant client.
Tested with podman
and docker
, unless otherwise indicated.
# Run container interactively
podman run -it IMAGE:TAG SHELL
# With auto removing the container on exit
podman run -it --rm IMAGE:TAG SHELL
# With current working dir mounted to container
podman run -it -v ${PWD}:/tmp/host-dir/ IMAGE:TAG SHELL
# Detaching from the interactive session
# Keybinding: Ctrl+P, then Ctrl+Q
# Attaching to a container
podman attach "ID OR NAME"
Windows 11: Taskbar
For some reason Microsoft, in their infinite wisdom, decided to no longer support moving the taskbar to other edges of the screen with Windows 11.
Using a utility like ExplorerPatcher the whole task bar can be reverted to something close to Windows 10, including moving it to all screen edges.
Bash: Find All Folders Containing File With Name
fileName="my-file.yaml"
find . -type f -name "$fileName" -printf "%h\n"
Managing Multiple Kube Config Files
This is a simple script that takes multiple kube config files and deeply merges them into one.
[Read More]