Skip to content

Instantly share code, notes, and snippets.

let quote = @"When solving problems, it's smart to keep things simple. Don't overthink it, Just look for what makes sense. There's always another way, maybe easier than you first thought. Tools like kusto help a lot by making hard tasks feel easy. A real hacker doesn't work harder—they work smarter.";
let words = split(quote, " ");
print phrase = strcat_array(pack_array(words[12], words[20], words[30], words[42]), " ")
@mohatb
mohatb / mergekubeconfig.sh
Created June 14, 2023 10:18
merge two kubeconfig file with existing ~/.kube/config. this would be helpful for clusters created by Kubeadm which has similar fields in context
#!/bin/bash
# Input validation
if [ "$#" -ne 2 ]; then
echo "Usage: ./mergekubeconfig.sh <kubeconfig1> <kubeconfig2>"
exit 1
fi
# Function to generate a random string
generate_random_string() {
@mohatb
mohatb / kubeadm-CP.sh
Created June 12, 2023 10:28
kubeadm CP
#!/bin/sh
# Source: http://kubernetes.io/docs/getting-started-guides/kubeadm
set -e
source /etc/lsb-release
if [ "$DISTRIB_RELEASE" != "20.04" ]; then
echo "################################# "
echo "############ WARNING ############ "
@mohatb
mohatb / download_kubeproxy.sh
Created May 30, 2023 10:43
download kube-proxy from all aks nodes
#!/bin/bash
# Start kubectl proxy in the background
kubectl proxy &
# Save the process ID of kubectl proxy
kubectl_proxy_pid=$!
# Base URL to the logs directory on the node
base_url="http://localhost:8001/api/v1/nodes"
@mohatb
mohatb / getContainerInfoOmitEmpty.go
Last active April 30, 2023 15:27
get container info (omit empty) sample to compare with the map
package main
import (
"context"
"encoding/json"
"fmt"
"log"
"github.com/containerd/containerd"
"github.com/containerd/containerd/namespaces"
@mohatb
mohatb / collectLabels.go
Created April 30, 2023 13:32
collect containerd k8s labels
package main
import (
"context"
"fmt"
"log"
"github.com/containerd/containerd"
"github.com/containerd/containerd/namespaces"
cadvisorapi "github.com/google/cadvisor/info/v1"
package main
import (
"context"
"fmt"
"github.com/containerd/containerd"
"github.com/containerd/containerd/namespaces"
)
@mohatb
mohatb / collectlabelsfromcontainerd1.go
Created April 29, 2023 11:32
script that calls containerd api and prints the labels
package main
import (
"context"
"fmt"
"strings"
"github.com/containerd/containerd"
"github.com/containerd/containerd/namespaces"
)
#!/bin/bash
# Variables for the Azure AKS cluster and Log Analytics workspace
clusterrg="akscilium"
clustername="akscilium"
workspaceRG="ammanrg"
workspacename="ammaninternal"
# Get the variables with CLI.
# if you are running on a node, replace the variables with static entries.
@mohatb
mohatb / script.ps1
Last active January 31, 2023 08:31
Backup-restore WSL Powershell
# Backup WSL
# Backup WSL
#.\script.ps1 backup 'C:\wsl-backup'
# Restore WSL
#.\script.ps1 restore 'C:\wsl-backup'
function Backup-WSL {
[CmdletBinding()]
param (