Skip to content

Instantly share code, notes, and snippets.

View felixkrohn's full-sized avatar
🤖
doing a bit here, a byte there.

Felix Krohn felixkrohn

🤖
doing a bit here, a byte there.
  • Planet Earth (temporarily)
View GitHub Profile
@Kerryliu
Kerryliu / ugreen_truenas_led.md
Last active April 18, 2025 20:55
TrueNAS UGREEN DXP4800 Plus Status LED Guide

UGREEN DXP4800 Plus TrueNAS Status LED Guide

20240609_035951642_iOS

The following is a quick guide on getting basic status LED functionality working with TrueNAS running on the UGREEN DXP4800 Plus. Theoretically, it should work on all models (with some small revisions to the script), but I only have a DXP4800 Plus. :)

This guide is for cron job that runs a script to update the LEDs every couple minutes, but I'm sure the following can be modified for blinky LEDs as well.

Steps:

@praveenkumar
praveenkumar / clusterversion.yaml
Created March 4, 2020 12:27
Doc gist for cvo changes
$ oc get clusterversion -oyaml
apiVersion: v1
items:
- apiVersion: config.openshift.io/v1
kind: ClusterVersion
metadata:
creationTimestamp: "2020-02-29T17:11:09Z"
generation: 4
name: version
resourceVersion: "616039"
@welshstew
welshstew / cpu-memory-allocated-as-percentage.sh
Last active July 22, 2023 07:17
cpu and memory utilization on Openshift nodes
#NodeName, cpu requests, cpu limits, memory requests, memory limits
[root@host ~]# oc get node --no-headers | while read node stat role age ver; do echo -ne "$node\t"; oc describe node $node | egrep '^ (cpu|memory)' | sed -r 's/\(|\)//g' | while read lbl x p1 y p2; do echo -n \ $p1 $p2 ; done; echo ""; done
master0 43% 0% 28% 3%
master1 40% 0% 23% 3%
master2 44% 0% 27% 3%
worker0 33% 8% 17% 3%
worker1 35% 8% 19% 3%
worker2 22% 2% 15% 4%
@4nn0
4nn0 / kubernetes-openshift.md
Last active November 23, 2021 15:10
Openshift / Kubernetes

Description

Some example commands for openshift/kubernetes, replace the oc with kubectl or otherwise

get all pods from all namespaces comma separated with namespace, pod name, container name, container image, pod status

oc get pods --all-namespaces -o go-template='{{range .items}}{{$status := .status.phase}}{{$namespace := .metadata.namespace}}{{$podname := .metadata.name}}{{range .spec.containers}}{{$namespace}}{{","}}{{$podname}}{{","}}{{.name}}{{","}}{{.image}}{{","}}{{$status}}{{"\n"}}{{end}}{{end}}'

get all pods from all namespaces comma separated with namespace, pod name, scc

oc get pods --all-namespaces -o go-template='{{range .items}}{{.metadata.namespace}},{{.metadata.name}},{{range $key, $element := .metadata.annotations}}{{if eq $key "openshift.io/scc"}}{{$element}}{{end}}{{end}}{{"\n"}}{{end}}'

get all sccs with attrubite .allowPrivilegedContainer true

@joaofl
joaofl / Clean Samsung Galaxy A40 bloatwares
Last active January 20, 2024 16:36
Script I used to clean preinstalled shit out of my brand new Samsung A40 (while there is still no LineageOS for it)
#!/bin/sh
# ref: https://piunikaweb.com/2019/03/25/samsung-galaxy-s10-remove-bundled-bloatwares-without-root/
# install the following app to see the packages names:
# use the following command to generate the unistall command, for easy copy and paste:
# adb shell 'pm list packages' | sed -e 's/^/adb uninstall --user 0 /' | grep FILTER_HERE | sort
#things to install if removing keyboard
# F-Droid
# APK Analyser
# after an accidental "oc delete pv --all" all PVs on the cluster are marked as "Terminating".
# As a result all PV have to be re-created, which is done by the script.
# Before force-deleting the PV, all deployments accessing the PV via PVC are being scaled down, and scaled up again afterwards.
#
# (by the way, the "Terminating" status is not a real status, but is what oc/kubectl print out
# when an object has a DeletionTimestamp, which is immutable and cannot be deleted anymore. See
# https://github.com/kubernetes/kubernetes/blob/master/pkg/kubectl/describe/versioned/describe.go#L1374-L1378
# if pv.ObjectMeta.DeletionTimestamp != nil {
# w.Write(LEVEL_0, "Status:\tTerminating (lasts %s)\n", translateTimestampSince(*pv.ObjectMeta.DeletionTimestamp))
# } else {
  • log into a router pod (oc rsh -n default router-YY-XXXXX)
  • confirm the socket used by haproxy is /var/lib/haproxy/run/haproxy.sock (using ps ax)
  • connect to the socket with socat socat /var/lib/haproxy/run/haproxy.sock stdio
  • use "prompt" and "help" for the corrsponding actions, or directly call echo "prompt" | socat /var/lib/haproxy/run/haproxy.sock stdio echo "help" | socat /var/lib/haproxy/run/haproxy.sock stdio
  • get raw stats in CSV format. note the "iid" value for the backend you're debugging echo "show stat" | socat /var/lib/haproxy/run/haproxy.sock stdio
  • get "typed" stats in the format [BS].IID.x.FIELD-ID.FIELD-Description with the value in the last column
@dcode
dcode / README.md
Last active April 17, 2025 17:17
How to use CoreDNS w/ etcd backend

Setup CoreDNS w/ etcd backend

Why CoreDNS

[CoreDNS][coredns] was designed from the ground up to provide robust, plugin-based DNS server for use in cloud environments. Namely, it serves as the default primary service discovery mechanism for Kubernetes.

Using CoreDNS allows us to have a lightweight DNS server on RockNSM (11 Mb binary is all that's needed!) to facilitate multi-node service discovery. Alternatively, if another existing DNS service is available, this can be used instead. Aligning with the way the Kubernetes manages service discovery also allows us to build new RockNSM features in parallel with the coming Kubernetes support.

RockNSM Application

@felixkrohn
felixkrohn / openshift-notepad.md
Last active April 15, 2025 06:35
openshift notepad

node debug pod with custom image (tcpdump etc)

oc debug node/ip-1-2-3-4.internal --image=registry.tld/namespace/image:tag
echo '{ "propagationPolicy": "Background" }' | curl -k -X DELETE -d @-  -H "Authorization: Bearer $TOKEN" -H 'Accept: application/json' -H 'Content-Type: application/json'  https://openshift-master.$DOMAIN/api/v1/namespaces/$NAMESPACE/pods/$PODNAME

kill haproxy processes older than 12h

ps -eo pid,etimes,comm,user | awk '{if ($3 = /haproxy/ && $2>43200) print $1}' | xargs kill -15

add infra nodeselector to namespace with oc patch

oc patch namespace $NAMESPACE -p '{"metadata":{"annotations":{"openshift.io/node-selector":"region=infra"}}}'

get a table of canonical nodenames together with their name label:

oc get nodes -Lname --output=jsonpath='{range .items[*].metadata}{.name}{" "}{.labels.name}{"\n"}'

groups:
- name: datetime
rules:
- record: daily_saving_time_belgium
expr: |
(vector(0) and (month() < 3 or month() > 10))
or
(vector(1) and (month() > 3 and month() < 10))
or
(