curl -sfL https://get.rke2.io | INSTALL_RKE2_METHOD=rpm sh -
sudo cp -f /usr/share/rke2/rke2-cis-sysctl.conf /etc/sysctl.d/60-rke2-cis.conf
mkdir -p /etc/rancher/rke2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
PUBLIC_IP=$(curl ifconfig.io) | |
# export INSTALL_RKE2_VERSION="v1.20.5+rke2r1" | |
curl -sfL https://get.rke2.io | sh - | |
mkdir -p /etc/rancher/rke2 | |
cat > /etc/rancher/rke2/config.yaml <<EOF | |
write-kubeconfig-mode: "0640" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for clusterId in $(kubectl get clusters.management.cattle.io -o jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}'); | |
do | |
# empty recipients for cluster alert groups | |
for clusterAlertGroup in $(kubectl -n $clusterId get clusteralertgroups -o jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}'); | |
do | |
kubectl -n $clusterId patch clusteralertgroup $clusterAlertGroup --type merge --patch '{"spec": {"recipients": []}}' | |
done | |
# disable cluster monitoring | |
kubectl patch clusters.management.cattle.io $clusterId --type merge --patch '{"spec": {"enableClusterMonitoring": false}}' | |
for projectId in $(kubectl -n $clusterId get projects.management.cattle.io -o jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for i in $(kubectl get namespaces -o custom-columns=":metadata.name" --no-headers) | |
do | |
echo "------ $i" | |
kubectl get -n $i configmaps --no-headers > /dev/null | wc -l | |
done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export ETCDCTL_API=3 | |
for key in `etcdctl get --prefix --keys-only /registry/configmaps` | |
do | |
size=`etcdctl get $key --print-value-only | wc -c` | |
versions=`etcdctl get $key --write-out=fields | grep \"Version\" | cut -f2 -d':'` | |
total=$(( $size * $versions)) | |
echo $total $size $versions $key >> /tmp/etcdkeys-configmaps.txt | |
done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SERVICE=my-nginx | |
NAMESPACE=default | |
PORT=80 | |
for ingresspod in $(kubectl -n ingress-nginx get pods -l app=ingress-nginx --template '{{range.items}}{{.metadata.name}}{{"\n"}}{{end}}') | |
do | |
echo $ingresspod | |
for svcep in $(kubectl -n $NAMESPACE get ep $SERVICE -o json | jq -r '.subsets[].addresses[].ip') | |
do | |
echo "=> ${svcep}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
echo "Installing K3S" | |
curl -sfL https://get.k3s.io | INSTALL_K3S_VERSION="v1.19.5+k3s2" sh - | |
PUBLIC_IP=$(curl http://169.254.169.254/latest/meta-data/public-ipv4) | |
echo "Downlading cert-manager CRDs" | |
wget -q -P /var/lib/rancher/k3s/server/manifests/ https://github.com/jetstack/cert-manager/releases/download/v0.15.0/cert-manager.crds.yaml | |
cat > /var/lib/rancher/k3s/server/manifests/rancher.yaml << EOF |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
MYSQL_PASS= | |
MYSQL_USER=master | |
LIMIT=100000 | |
SELECT_STMT="select max(id) m, count(*) c, name from kine group by name order by c desc limit 100;" | |
# start compaction |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function box-request() | |
{ | |
_BEARER_TOKEN="<box app token>" | |
_FOLDER_NAME=$1 | |
echo -n "Creating ${_FOLDER_NAME}" | |
_FOLDER_ID=$(curl -sX POST https://api.box.com/2.0/folders \ | |
-H "Authorization: Bearer ${_BEARER_TOKEN}" \ | |
-H 'Content-Type: application/json' \ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Run within a etcd container | |
# etcd object sizes | |
export ETCDCTL_API=3 | |
for key in `etcdctl get --prefix --keys-only /` | |
do | |
size=`etcdctl get $key --print-value-only | wc -c` | |
versions=`etcdctl get $key --write-out=fields | grep \"Version\" | cut -f2 -d':'` | |
total=$(( $size * $versions)) | |
echo $total $size $versions $key >> /tmp/etcdkeys.txt |