Skip to content

Instantly share code, notes, and snippets.

View mpepping's full-sized avatar

Martijn Pepping mpepping

View GitHub Profile
@mpepping
mpepping / generate_new_kubeconfig.sh
Created May 25, 2023 08:37 — forked from Oats87/generate_new_kubeconfig.sh
This bash script will sign an x509 certificate using the kube-ca located on any rancher node. This allows you to gain access back to your RKE-created kubernetes cluster should you lose the kube_config and cluster.yml for it, but still have SSH access to the hosts.
#!/bin/bash
echo "This will generate a new kube config for accessing your RKE-created kubernetes cluster. This script MUST be run on a Kubernetes node."
echo "Please enter the IP of one of your control plane hosts, followed by [ENTER]:"
read cphost
openssl genrsa -out kube-admin.key 2048
openssl req -new -sha256 -key kube-admin.key -subj "/O=system:masters/CN=kube-admin" -out kube-admin.csr
sudo openssl x509 -req -in kube-admin.csr -CA /etc/kubernetes/ssl/kube-ca.pem -CAcreateserial -CAkey /etc/kubernetes/ssl/kube-ca-key.pem -out kube-admin.crt -days 365 -sha256
sudo rm -f /etc/kubernetes/ssl/kube-ca.srl
#!/bin/bash
#
# https://support.1password.com/command-line-getting-started/
#
# Full docs: https://support.1password.com/command-line/
#
# gpg --receive-keys 3FEF9748469ADBE15DA7CA80AC2D62742012EA22
# gpg --verify op.sig op
#