Skip to content

Instantly share code, notes, and snippets.

View matti's full-sized avatar
🎯
Focusing

Matti Paksula matti

🎯
Focusing
View GitHub Profile
#!/usr/bin/env bash
set -euo pipefail
export PAGER=""
TARGET_DBNAME=$1
psql --dbname "$TARGET_DBNAME" -c "SELECT * FROM pg_stat_activity;"
#TODO: user hardcoded to postgres

Beautiful Bash

until something is true

if "creation" command fails, sleep 1

while true; do
  kubectl get namespace mynamespace && break
 kubectl create namespace mynamespace || sleep 1
@matti
matti / add.sh
Created July 29, 2017 11:12
alpine docker add package from edge testing
apk add --no-cache -X http://dl-cdn.alpinelinux.org/alpine/edge/testing \
x11vnc
@matti
matti / 10-wancarp
Last active December 9, 2023 08:28 — forked from spali/10-wancarp
Disable WAN Interface on CARP Backup
#!/usr/local/bin/php
<?php
require_once("config.inc");
require_once("system.inc");
require_once("interfaces.inc");
require_once("util.inc");
$subsystem = !empty($argv[1]) ? $argv[1] : '';
$type = !empty($argv[2]) ? $argv[2] : '';
version: '3.9'
services:
worker:
image: ghcr.io/usvacomputer/platform/worker:2adbe3a8aa4ff7f5f7edc30131148184b1c4c1ed
environment:
- USVA_ENV=matti-1
- USVA_DOMAIN=usva.io
- USVA_NAME=default
privileged: true
failed to create containerd task: failed to create shim task: failed to mount rootfs component: invalid argument: unknown\"" component=containerd stream=stderr
time="2023-11-14 20:00:39" level=info msg="E1114 20:00:39.603695 99 remote_runtime.go:176] \"RunPodSandbox from runtime service failed\" err=\"rpc error: code = Unknown desc = failed to create containerd task: failed to create shim task: failed to mount rootfs component: invalid argument: unknown\"" component=kubelet stream=stderr
time="2023-11-14 20:00:39" level=info msg="E1114 20:00:39.603730 99 kuberuntime_sandbox.go:72] \"Failed to create sandbox for pod\" err=\"rpc error: code = Unknown desc = failed to create containerd task: failed to create shim task: failed to mount rootfs component: invalid argument: unknown\" pod=\"kube-system/kube-proxy-nlgsw\"" component=kubelet stream=stderr
time="2023-11-14 20:00:39" level=info msg="E1114 20:00:39.603743 99 kuberuntime_manager.go:1122] \"CreatePodSandbox for pod failed\" err=\"rpc error: c
rbac:
create: true
podSecurityPolicy:
enabled: false
imagePullSecrets:
# - name: "image-pull-secret"
## Define serviceAccount names for components. Defaults to component's fully qualified name.
@matti
matti / gist:7ff6913241b8839fb624bd084133f1dd
Created December 21, 2022 12:20
google_data_studio_custom_query
SELECT *
FROM `project.dataset.table`
WHERE
time BETWEEN PARSE_TIMESTAMP("%Y%m%d", @DS_START_DATE) AND PARSE_TIMESTAMP("%Y%m%d", @DS_END_DATE)

Kumbersome Kubernetes

kubectl get pods on a node

kubectl get pods --all-namespaces \
  --output jsonpath="{range .items[?(@.spec.nodeName=='ip-192-168-13-3.eu-north-1.compute.internal')]}{@.metadata.namespace}{': '}{@.metadata.name}{'\n'}"

kubectl get instance types

while true; do
nodesWithFailingPods=""
if failedPods=$(kubectl get pods -n default --no-headers | awk '$4 > 1 {print $1}') && [[ "$failedPods" != "" ]]; then
for failedPod in $failedPods; do
echo "$(date) pod failed too many times: '$failedPod'"
if failedPodNodeName=$(kubectl get pod -n default "$failedPod" -ojsonpath='{.spec.nodeName'}); then
nodesWithFailingPods="$nodesWithFailingPods $failedPodNodeName"
fi
done