Skip to content

Instantly share code, notes, and snippets.

View mattmattox's full-sized avatar

Matthew Mattox mattmattox

View GitHub Profile
@mattmattox
mattmattox / grab-rke2-bootstrap.sh
Created March 10, 2022 08:57
grab-rke2-bootstrap.sh
/var/lib/rancher/rke2/bin/kubectl --kubeconfig /etc/rancher/rke2/rke2.yaml exec -it $(/var/lib/rancher/rke2/bin/kubectl --kubeconfig /etc/rancher/rke2/rke2.yaml get po -l component=etcd -n kube-system \
-o jsonpath='{.items[0].metadata.name}') -n kube-system -- /bin/bash -c "ETCDCTL_API=3 etcdctl --endpoints=https://127.0.0.1:2379 \
--cacert=/var/lib/rancher/rke2/server/tls/etcd/server-ca.crt \
--cert=/var/lib/rancher/rke2/server/tls/etcd/server-client.crt \
--key=/var/lib/rancher/rke2/server/tls/etcd/server-client.key \
get /bootstrap --prefix "
@mattmattox
mattmattox / build-rke2.sh
Last active March 10, 2022 06:10
RKE2 build script
#!/bin/bash
usage() { echo "Usage: $0 [-m master|worker|all] [-v v1.21.6+rke2r1] [-s 192.168.1.100] [-t K1075c2da4946626e73...] " 1>&2; exit 1; }
while getopts ":m:v:s:t:" o; do
case "${o}" in
m)
m=${OPTARG}
((m == master || m == worker || m == all)) || usage
;;
@mattmattox
mattmattox / rke-clean-token.sh
Last active February 17, 2022 13:53
rke-clean-token.sh
#!/bin/bash
echo "Fixing tokens..."
for namespace in kube-system cattle-system ingress-nginx
do
echo "namespace: $namespace"
for token in $(kubectl --kubeconfig kube_config_cluster.yml get secret -n $namespace | grep 'kubernetes.io/service-account-token' | awk '{print $1}')
do
kubectl --kubeconfig kube_config_cluster.yml delete secret -n $namespace $token
done
@mattmattox
mattmattox / get_kube_config-all.sh
Created September 8, 2021 20:11
get kube configs from Rancher
#!/bin/bash
echo "Working on a1-rancher-prd.support.tools"
/usr/local/bin/get_kube_config -u 'a1-rancher-prd.support.tools' -a 'token-12345' -s '1234567989....'
#echo "Working on a1-rancher-lab.support.tools"
/usr/local/bin/get_kube_config -u 'a1-rancher-lab.support.tools' -a 'token-12345' -s '123456789.....'
@mattmattox
mattmattox / grab-ingress-logs.sh
Last active April 29, 2021 23:26
grab-ingress-logs.sh
#!/bin/bash
for POD in $(kubectl get pods -n ingress-nginx -l app=ingress-nginx -o NAME | awk -F'/' '{print $1}');
do
kubectl --kubeconfig $KUBECONFIG -n ingress-nginx logs $POD > ./logs-"$POD"
done
@mattmattox
mattmattox / install-etcd.sh
Last active April 24, 2021 15:41
Install etcd server
ETCD_VER=v3.4.15
GITHUB_URL=https://github.com/etcd-io/etcd/releases/download
DOWNLOAD_URL=${GITHUB_URL}
rm -f /tmp/etcd-${ETCD_VER}-linux-amd64.tar.gz
rm -rf /tmp/etcd-download-test && mkdir -p /tmp/etcd-download-test
curl -L ${DOWNLOAD_URL}/${ETCD_VER}/etcd-${ETCD_VER}-linux-amd64.tar.gz -o /tmp/etcd-${ETCD_VER}-linux-amd64.tar.gz
tar xzvf /tmp/etcd-${ETCD_VER}-linux-amd64.tar.gz -C /tmp/etcd-download-test --strip-components=1
rm -f /tmp/etcd-${ETCD_VER}-linux-amd64.tar.gz
/tmp/etcd-download-test/etcd --version
ETCDCTL_API=3 /tmp/etcd-download-test/etcdctl version
@mattmattox
mattmattox / cluster-to-node.sh
Last active January 6, 2021 03:53
rancher cluster-to-node
#!/bin/bash
CATTLE_ACCESS_KEY='token-abcde'
CATTLE_SECRET_KEY='1234567890'
CATTLE_URL='rancher.example.com
clusterids=$(
curl -q -s -u "${CATTLE_ACCESS_KEY}:${CATTLE_SECRET_KEY}" \
-X GET \
-H 'Accept: application/json' \
@mattmattox
mattmattox / default-http-backend.yaml
Last active November 18, 2020 15:06
Unlimited default-http-backend
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: default-http-backend
manager: kubectl
operation: Update
manager: kube-controller-manager
operation: Update
name: default-http-backend
@mattmattox
mattmattox / HideVirtualBox.bat
Created July 29, 2020 22:15 — forked from LiamKarlMitchell/HideVirtualBox.bat
Hide Virtual Machine.
@echo off
@reg copy HKLM\HARDWARE\ACPI\DSDT\VBOX__ HKLM\HARDWARE\ACPI\DSDT\NOBOX__ /s /f
@reg delete HKLM\HARDWARE\ACPI\DSDT\VBOX__ /f
@reg add HKLM\HARDWARE\DESCRIPTION\System /v SystemBiosVersion /t REG_MULTI_SZ /d "NOBOX - 1" /f
@reg add HKLM\HARDWARE\DESCRIPTION\System /v VideoBiosVersion /t REG_MULTI_SZ /d "NOBOX - 1" /f
@taskkill /f /im VBoxTray.exe
@exit
@mattmattox
mattmattox / runme.sh
Created June 1, 2020 16:49
Rolling HAProxy upgrade for Rancher v1.6.18-patch1-rc2 to v1.6.18-patch1-rc3
#!/bin/bash
CATTLE_URL="http://rancher.example.com/v2-beta"
CATTLE_ACCESS_KEY="AAAAAAAAAAAAAAAAAAA"
CATTLE_SECRET_KEY="BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
SLEEP=5
projects=`curl -s -u "${CATTLE_ACCESS_KEY}:${CATTLE_SECRET_KEY}" -X GET -H 'Accept: application/json' -H 'Content-Type: application/json' "${CATTLE_URL}/projects/" | jq -r .data | jq '.[]' | jq '.id' | tr -d '"'`
for project in $projects