Skip to content

Instantly share code, notes, and snippets.

View vi7's full-sized avatar
💭
smd

Vitaliy D. vi7

💭
smd
  • Krakow, Poland
View GitHub Profile
@vi7
vi7 / get_ip_address.sh
Created April 4, 2024 16:47
Oneliner to get IP address of the interface in Linux. Uses ip and jq commands
#!/usr/bin/env bash
INTERFACE_NAME=eth0
ip -family inet -json addr show $INTERFACE_NAME | jq --raw-output .[0].addr_info[0].local
@vi7
vi7 / k8s_nfs_pvc_pv_sc.yaml
Created February 23, 2024 17:10
Kubernetes NFS PVC PV SC example
---
apiVersion: v1
kind: PersistentVolume
metadata:
labels:
app.kubernetes.io/instance: storage
app.kubernetes.io/name: storage
name: my-awesome-nfs
spec:
accessModes:
@vi7
vi7 / alertmanager_templates_howto.md
Last active May 29, 2024 21:47
Alertmanager templates testing

Render Alertmanager templates locally

Normally to test Alertmanager templates you need to restart running Alertmanager and wait for alerts to arrive to Slack or email. To speed up this process parts of templates could be rendered locally using predefined alerts data without the need of the actual Alertmanager.

What you still need in this case is amtool which is a part of Alertmanager delivery which could be downloaded here https://github.com/prometheus/alertmanager/releases

Some examples of templates rendering:

# navigate to the templates dir
@vi7
vi7 / kube_cluster_info.sh
Created September 25, 2023 11:39
Kubernetes public API endpoint with the cluster info
!#/usr/bin/env bash
K8S_CLUSTER_API_URL="my-cluster.example.com"
curl -ks https://"$K8S_CLUSTER_API_URL":6443/api/v1/namespaces/kube-public/configmaps/cluster-info
@vi7
vi7 / autotyper.scpt
Last active August 14, 2023 15:13
Apple script to auto type clipboard contents. To use in the macOS Automator Quick Action
on run {input, parameters}
tell application "System Events"
set textToType to (get the clipboard as text)
delay 1
repeat with i from 1 to count characters of textToType
set c to character i of textToType
-- use codes to print some chars for compatibility reasons
-- see https://eastmanreference.com/complete-list-of-applescript-key-codes for all key codes
if c = "." then
@vi7
vi7 / smtp4dev_k8s_manifests.yaml
Created August 2, 2023 12:02
K8S deployment manifests for a dummy lightweight SMTP email server (smtp4dev) with WebUI useful for development and testing
---
apiVersion: v1
kind: Service
metadata:
name: smtp4dev
spec:
type: NodePort
selector:
app: smtp4dev
ports:
@vi7
vi7 / kernels_cleanup.sh
Last active November 11, 2022 09:37
Script that retains the latest kernel and removes old kernels if any. DNF compatible
#!/usr/bin/env bash
old_kernels=($(dnf repoquery --installonly --latest-limit=-1 -q))
if [ "${#old_kernels[@]}" -eq 0 ]; then
echo "No old kernels found"
exit 0
fi
if ! dnf remove "${old_kernels[@]}"; then
echo "Failed to remove old kernels"
@vi7
vi7 / check_version.sh
Created September 9, 2022 04:53
Script to check if app version has been bumped. To be used with Merge Request CI checks
#!/usr/bin/env sh
# Script to check if app version has been bumped
# To be used with Merge Request CI checks
set -e
VERSION_FILE="ci/build.env"
git fetch origin
@vi7
vi7 / kernel_v5_centos7.sh
Created August 3, 2022 13:15
Kernel v5 on CentOS 7
#!/usr/bin/env bash
# Based on the info from
# - http://elrepo.org/tiki/HomePage
# - https://www.golinuxcloud.com/set-default-boot-kernel-version-old-previous-rhel-linux/
# - https://www.casesup.com/category/knowledgebase/howtos/how-to-change-the-default-kernel-in-grub-for--rhel-and-centos
## !!!!!!!!!!!!!!!!!!!! ##
## ##
## !!! IMPORTANT: do not run this as-is, read all in-line comments ##