Skip to content

Instantly share code, notes, and snippets.

View jakefhyde's full-sized avatar
🏠
Working from home

Jake Hyde jakefhyde

🏠
Working from home
View GitHub Profile
@jakefhyde
jakefhyde / aws-external-cloud-provider-healthcheck.sh
Created February 20, 2024 22:43
Validates all Rancher and AWS infrastructure resources required for provisioning an RKE2/K3s cluster using the AWS out-of-tree external cloud-provider
#!/bin/bash
# shellcheck disable=SC2016
set -e
# Validates all Rancher and AWS infrastructure resources required for provisioning an RKE2/K3s cluster using the AWS
# out-of-tree external cloud-provider
display_help() {
#!/bin/bash
set -e
if [ $# -ne 1 ] || [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
echo "usage: update-go <version>"
exit 1
fi
cur_version="$(go version | awk '{print $3}' | sed 's/go//')"
@jakefhyde
jakefhyde / get-capi-resources.sh
Last active November 21, 2023 22:25
Gets all CAPI cluster resources for a rancher provisioned v2prov cluster
#!/usr/bin/env zsh
# This script will get all of the resources for a rancher v2prov (rke2/k3s) cluster, and optionally generate a tar ball containing the resources.
set -e
BASE="$(basename $0)"
function display_help() {
echo "Usage: ${BASE}"
@jakefhyde
jakefhyde / gist.sh
Last active November 21, 2023 22:50
Github gist manager
#!/usr/bin/env zsh
set -e
GIST_ROOT=${GIST_ROOT:-${HOME}/.gist}
GIST_LIMIT=${GIST_LIMIT:-100}
BASE="$(basename $0)"
function display_help() {
@jakefhyde
jakefhyde / mirror-image.sh
Last active November 7, 2023 06:31
Mirror image to personal docker repo
#!/usr/bin/env zsh
set -e
function display_help() {
echo "Usage: $(basename $0) --source [source tag] --dest [dest tag]"
echo
echo ' -s, --source [Required] source image and tag'
echo ' -d, --dest [Required] destination image and tag'
echo ' -p, --push [Optional] push files to docker hub'
@jakefhyde
jakefhyde / rancher-each-v2.sh
Last active January 3, 2024 20:30
Runs an ssh command on all nodes in a rancher v2prov cluster
#!/bin/bash
#
# Given a command, rancher server url, rancher admin token, namespace and name of a v2prov cluster:
# 1. Get the management cluster name
# 2. Download the kubeconfig
# 3. Get the list of CAPI machines
# 4. For each CAPI machine:
# a. Download the ssh keys to a temp directory
# b. Get the IP address of the node
# b. Run a command on the node via ssh
@jakefhyde
jakefhyde / clean-aws.sh
Last active November 7, 2023 05:48
clean-aws.sh
#!/bin/bash
REGION="us-east-2"
PREFIX="jhyde"
question () {
while true; do
read -p "$1" yn
case $yn in
[Yy]* ) break;;
@jakefhyde
jakefhyde / get-cluster-yaml.sh
Last active November 7, 2023 05:49
get-cluster-yaml.sh
#!/bin/bash
set -ex
KUBECTL_CMD=kubectl
build() {
echo "Building cluster.yml..."
IFS=''
while read line
@jakefhyde
jakefhyde / clean-do.sh
Last active February 20, 2024 20:21
Clean up Digital Ocean Droplets, Domains, and SSH Keys
#!/usr/bin/zsh
echo "Deleting droplets"
name=$1
while read -r entry;
do
if [[ -z $(echo $entry | xargs) ]];
then
@jakefhyde
jakefhyde / user-node-remove-test.sh
Last active November 7, 2023 05:52
Simulate user-node-remove issues before an upgrade
#!/bin/bash
PATCH=NO
NAMESPACE=$1
NODE=$2
NODEJSON=$(kubectl get -n $NAMESPACE node.management.cattle.io $NODE -o json)
echo $NODEJSON | jq -r '.metadata.finalizers += ["clusterscoped.controller.cattle.io/user-node-remove_abcde"]' | jq -r '.metadata.annotations += { cleanup.cattle.io/user-node-remove: null }' > node-0.json