Skip to content

Instantly share code, notes, and snippets.

View bartvdbraak's full-sized avatar
🏗️
Building clusters

Bart van der Braak bartvdbraak

🏗️
Building clusters
View GitHub Profile
{"label":"lighthouse","message":"99","schemaVersion":1,"color":"4c1","namedLogo":"Lighthouse"}
@bartvdbraak
bartvdbraak / backup-wwwroot.py
Created January 30, 2024 20:07
(unfinished) Download wwwroot of Linux Web App on Azure using ssh and tar
import os
import sys
import time
import subprocess
import re
import paramiko
from paramiko import SSHClient, AutoAddPolicy
REMOTE_FILE_OUTPUT = "/home/site/wwwroot.tar"
{"label":"lighthouse","message":"99","schemaVersion":1,"color":"4c1","namedLogo":"Lighthouse"}
@bartvdbraak
bartvdbraak / remove-pipeline-retention.ps1
Created June 26, 2023 02:34
This PowerShell script deletes a specified Azure DevOps pipeline and its builds.
param (
[Parameter(Mandatory=$true)]
[string]$PersonalToken,
[Parameter(Mandatory=$true)]
[string]$Organization,
[Parameter(Mandatory=$true)]
[string]$Project
)
@bartvdbraak
bartvdbraak / monitor-ip-changes.sh
Created June 20, 2023 14:33
Quick one-liner that will print any changes of the public IP of your machine
while true; do result=$(curl -s ifconfig.wearetriple.com); if [[ "$result" != "$previous_result" ]]; then echo "$(date) $result"; previous_result=$result; fi; sleep 1; done
@bartvdbraak
bartvdbraak / domain_check.sh
Created June 6, 2023 14:30
This script can be used to check a list of domains against a desired outcome by utilizing the `dig` command. It provides information on whether each domain matches or mismatches the expected outcome.
#!/bin/bash
print_help() {
echo "Usage: ./domain_check.sh DESIRED_OUTCOME DOMAIN1 [DOMAIN2 ...]"
echo "Check a list of domains against a desired outcome using the dig command."
echo ""
echo "Arguments:"
echo " DESIRED_OUTCOME The expected outcome for the domains."
echo " DOMAIN1 The first domain to check."
echo " DOMAIN2 ... Additional domains to check."
@bartvdbraak
bartvdbraak / move_images_between_acrs.sh
Created May 31, 2023 10:01
A Bash script to move all images from one Azure Container Registry to another, with prompts for repository selection and confirmation, while retaining the order or date based on creation time.
#!/bin/bash
# Function to prompt for user input with a default value
prompt_input() {
local prompt_message="$1"
local default_value="$2"
local user_input
read -p "$prompt_message [$default_value]: " user_input
echo "${user_input:-$default_value}"
}
@bartvdbraak
bartvdbraak / list-apiversions.sh
Created May 15, 2023 19:38
List all apiVersions for each resource type in a Kubernetes cluster
#!/bin/bash
# Get the list of resource types
resource_types=$(kubectl api-resources | tail +2 | awk '{ print $1 }')
# Iterate over each resource type
for resource_type in $resource_types; do
echo "Resource Type: $resource_type"
# Get the latest usable apiVersion
@bartvdbraak
bartvdbraak / download-acr-helm-charts.sh
Created May 15, 2023 19:11
script to download all latest helm charts on your Azure Container Registry
#!/bin/bash
# Destination directory to save YAML files
DESTINATION_DIR="${1:-.}"
# Prompt for Azure Container Registry name if not provided
read -p "Enter Azure Container Registry name: " ACR_NAME
# Add Azure Container Registry to helm repositories
echo "Enter the password for your Azure Container Registry"
@bartvdbraak
bartvdbraak / cluster-backup.sh
Last active May 15, 2023 19:09
A way to quickly create a backup of your Kubernetes cluster with manifests for each resource per resource type per namespace (don't use this as a serious backup strategy)
#!/bin/bash
# Check if the backup directory is provided as an argument
if [ -z "$1" ]; then
echo "Usage: $0 <backup_directory>"
exit 1
fi
# Get the backup directory from the command line argument
BACKUP_DIR="$1"