Skip to content

Instantly share code, notes, and snippets.

@sat0yu
Created June 26, 2021 00:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sat0yu/3b6172553d8463fd25d65a56fd5aa82f to your computer and use it in GitHub Desktop.
Save sat0yu/3b6172553d8463fd25d65a56fd5aa82f to your computer and use it in GitHub Desktop.
#!/bin/bash -eux
if [[ $UID != 0 ]]; then
echo "Please run this script with sudo"
exit 1
fi
REGISTRIES_YAML_PATH=/etc/rancher/k3s/registries.yaml
if [ -e $REGISTRIES_YAML_PATH ]; then
echo "${REGISTRIES_YAML_PATH} already exists" 1>&2
exit 1
fi
if [ $# -ne 2 ]; then
echo "Usage: ${0##*/} USER_NAME PASSWORD" 1>&2
exit 1
fi
USERNAME=$1
PASSWORD=$2
mkdir -p ${REGISTRIES_YAML_PATH%/*}
cat << EOS > $REGISTRIES_YAML_PATH
mirrors:
ghcr:
endpoint:
- "https://ghcr.io"
configs:
"ghcr.io":
auth:
username: $USERNAME
password: $PASSWORD
EOS
curl -sfL https://get.k3s.io | sh -s - --kube-apiserver-arg service-node-port-range=1-65535
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment