Skip to content

Instantly share code, notes, and snippets.

@dkeightley
Last active June 3, 2022 04:47
Show Gist options
  • Save dkeightley/e3e80c5fc038faf0cc38427df4177608 to your computer and use it in GitHub Desktop.
Save dkeightley/e3e80c5fc038faf0cc38427df4177608 to your computer and use it in GitHub Desktop.
k3s-rancher-userdata
#!/bin/sh
PUBLIC_IP=$(curl ifconfig.io)
echo "Installing K3S"
# export INSTALL_K3S_VERSION="v1.19.5+k3s2"
curl -sfL https://get.k3s.io | sh -s - --tls-san ${PUBLIC_IP}
echo "Downlading cert-manager CRDs"
wget -q -P /var/lib/rancher/k3s/server/manifests/ https://github.com/jetstack/cert-manager/releases/download/v1.5.1/cert-manager.crds.yaml
cat > /var/lib/rancher/k3s/server/manifests/rancher.yaml << EOF
apiVersion: v1
kind: Namespace
metadata:
name: cattle-system
---
apiVersion: v1
kind: Namespace
metadata:
name: cert-manager
labels:
certmanager.k8s.io/disable-validation: "true"
---
apiVersion: helm.cattle.io/v1
kind: HelmChart
metadata:
name: cert-manager
namespace: kube-system
spec:
targetNamespace: cert-manager
repo: https://charts.jetstack.io
chart: cert-manager
version: v1.5.1
helmVersion: v3
---
apiVersion: helm.cattle.io/v1
kind: HelmChart
metadata:
name: rancher
namespace: kube-system
spec:
targetNamespace: cattle-system
repo: https://releases.rancher.com/server-charts/latest/
chart: rancher
version: v2.6.5 # change as needed!
set:
hostname: $PUBLIC_IP.nip.io
replicas: 1
helmVersion: v3
EOF
echo "Rancher should be booted up in a few mins"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment