Skip to content

Instantly share code, notes, and snippets.

View qrkourier's full-sized avatar

Kenneth Bingham qrkourier

View GitHub Profile
@qrkourier
qrkourier / docker-hub-tag-multi-platform-latest.bash
Last active May 22, 2024 15:46
Tag the last known good semver as latest
(set -euxopipefail
GOOD_VERSION=1.0.0
for REPO in ziti-{cli,controller,router}; do
docker buildx imagetools create --tag openziti/${REPO}:latest openziti/${REPO}:${GOOD_VERSION}
done
)
@qrkourier
qrkourier / artifactory-unpublish.zsh
Last active May 22, 2024 15:49
Delete a bad version from DEB/RPM Artifactory repos
(
set -euxopipefail
ARTIFACTORY_REPO='zitipax-openziti-(rpm|deb)-stable'
DELETE="--dry-run"
: DELETE="--quiet"
BAD_VERSION=1.1.8
declare -a ARTIFACTS=(openziti{,-controller,-router})
@qrkourier
qrkourier / artifactory-retention.zsh
Created April 2, 2024 22:05
Artifactory retention policy
(
set -euxopipefail
ARTIFACTORY_REPO='zitipax-(openziti-(rpm|deb)-test|fork-(rpm|deb)-stable)'
: DELETE="--quiet"
DELETE="--dry-run"
RETENTION_DAYS=30
declare -a ARTIFACTS=(ziti-edge-tunnel openziti{,-controller,-router} zrok{,-share})
@qrkourier
qrkourier / transcode-to-mp4.py
Created February 14, 2024 23:50
to convert videos in a folder to MP4 and remove the old file if successful, say "python transcode-to-mp4.py FOLDER --delete"
import os
import sys
from os import chdir, walk
from os.path import dirname, getsize, join
from pathlib import Path
from shutil import move
import ffmpeg
import filetype
@qrkourier
qrkourier / zrok-test-cli-versions.py
Created January 18, 2024 22:32
ensure a list of BASH commands, e.g., `zrok enable` succeed for a list of zrok versions selected by criteria like min/max version and age.
import datetime
import logging
import os
import re
import time
import docker
import requests
from packaging import version
@qrkourier
qrkourier / ziti-mfa.bash
Last active February 28, 2024 18:28
send Ziti Edge Tunnel MFA when Yubikey is present
#!/usr/bin/env bash
set -o errexit
set -o nounset
set -o pipefail
if systemctl is-enabled --quiet ziti-edge-tunnel.service && ykman piv info &>/dev/null
then
RESPONSE=$(ykman oath accounts code "$ZITI_IDENTITY" \
| awk '{print $2;}' \
@qrkourier
qrkourier / ziti-jwt.py
Last active May 21, 2024 15:10
parse or verify a Ziti enrollment token as JWT
#!/usr/bin/env python
# This script parses and attempts to verify the signature of a Ziti JWT token and prints the header, payload, and
# analysis of the token.
import argparse
import json
import logging
import os
import ssl
@qrkourier
qrkourier / docker-get-libc-versions.bash
Created August 21, 2023 15:00
print table of Linux distros' libc versions by running a Docker container
for OS in \
oraclelinux:{7..9} \
debian:{buster,bullseye,bookworm} \
registry.access.redhat.com/ubi{8,9}/ubi \
ubuntu:{bionic,focal,jammy} \
quay.io/centos/centos:7 \
fedora:{34,35,36} \
rockylinux/rockylinux:{8,9};
do
(
@qrkourier
qrkourier / Dockerfile.debian
Last active July 20, 2023 16:44
ziti-edge-tunnel Dockerfile for Debian
# this was the main Dockerfile before we adopted the RH UBI source image. This may still be useful for building arm 32bit images.
FROM debian:buster-slim as fetch-ziti-artifacts
# This build stage grabs artifacts that are copied into the final image.
# It uses the same base as the final image to maximize docker cache hits.
ARG ZITI_VERSION
ARG GITHUB_BASE_URL
ARG GITHUB_REPO
@qrkourier
qrkourier / krun
Last active April 15, 2023 21:33
run any command in any container image in any Kubernetes namespace
# krun busybox whoami
krun(){
local NAMESPACE=default
local PRIVILEGED=false
while getopts 'n:pu:' OPT; do
case $OPT in
n) NAMESPACE=$OPTARG
;;
p) PRIVILEGED=true