Created
February 23, 2018 03:29
-
-
Save hhoover/dc3149efcf248f4d210ff3b76793952f to your computer and use it in GitHub Desktop.
Raspberry Pi K8S disks
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 | |
set -x | |
# Localse, uncomment if user-data didn't fix these | |
export LANGUAGE=en_US.UTF-8; export LANG=en_US.UTF-8; export LC_ALL=en_US.UTF-8; locale-gen en_US.UTF-8 | |
# Set locale to en_US.UTF-8 | |
sudo cp /etc/locale.gen /etc/locale.gen.dist | |
sudo sed -i -e "/^[^#]/s/^/#/" -e "/en_US.UTF-8/s/^#//" /etc/locale.gen | |
cp /var/cache/debconf/config.dat /var/cache/debconf/config.dat.dist | |
sudo sed -i -e "s/Value: en_GB.UTF-8/Value: en_US.UTF-8/" \ | |
-e "s/ locales = en_GB.UTF-8/ locales = en_US.UTF-8/" /var/cache/debconf/config.dat | |
sudo locale-gen | |
sudo update-locale LANG=en_US.UTF-8 | |
exec "$BASH" <<EOF | |
set -x | |
# Updates | |
## Add the missing raspbian repo | |
echo "deb http://mirrordirector.raspbian.org/raspbian/ stretch main contrib non-free rpi firmware" | sudo tee -a /etc/apt/sources.list.d/raspi.list | |
sudo apt-get update -qq | |
## Get proper keys & update | |
sudo apt-get install -qy --force-yes debian-archive-keyring debian-keyring | |
sudo apt-get update -qq | |
## Run upgrades | |
export DEBIAN_FRONTEND=noninteractive | |
sudo apt-get dist-upgrade -qy --force-yes | |
# Install packages | |
## This installs some "handy" packages (vim, git, wget, curl) | |
## Along with avahi/netatalk so we can access the nodes by name | |
## Finally we add cloud-init to ease the flashing process | |
sudo apt-get install -qy \ | |
vim \ | |
git \ | |
wget \ | |
curl \ | |
unzip \ | |
avahi-daemon \ | |
dirmngr \ | |
cloud-init \ | |
netatalk | |
# Configure cloud-init | |
mkdir -p /var/lib/cloud/seed/nocloud-net | |
ln -s /boot/user-data /var/lib/cloud/seed/nocloud-net/user-data | |
ln -s /boot/meta-data /var/lib/cloud/seed/nocloud-net/meta-data | |
# Docker install | |
## Install Docker | |
curl -sSL get.docker.com | sh && \ | |
sudo usermod pi -aG docker | |
## Roll back Docker version for k8s | |
sudo apt-get autoremove -y --purge docker-ce | |
sudo rm -rf /var/lib/docker | |
sudo apt-get install -y docker-ce=17.09.0~ce-0~raspbian | |
# Enable ssh for remote access | |
sudo systemctl enable ssh | |
sudo systemctl start ssh | |
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
{ | |
"variables": { | |
}, | |
"builders": [{ | |
"type": "arm-image", | |
"iso_url" : "https://downloads.raspberrypi.org/raspbian_lite/images/raspbian_lite-2017-12-01/2017-11-29-raspbian-stretch-lite.zip", | |
"iso_checksum_type":"sha256", | |
"iso_checksum":"e942b70072f2e83c446b9de6f202eb8f9692c06e7d92c343361340cc016e0c9f", | |
"last_partition_extra_size" : 1073741824 | |
}], | |
"provisioners": [ | |
{ | |
"type": "shell", | |
"script": "/vagrant/customize.sh" | |
} | |
] | |
} |
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
#cloud-config | |
# vim: syntax=yaml | |
# | |
hostname: hostname | |
manage_etc_hosts: true | |
resize_rootfs: true | |
growpart: | |
mode: auto | |
devices: ["/"] | |
ignore_growroot_disabled: false | |
users: | |
- name: pi | |
gecos: "DefaultUser" | |
sudo: ALL=(ALL) NOPASSWD:ALL | |
shell: /bin/bash | |
groups: users,docker,video | |
ssh-authorized-keys: | |
- ssh-rsa REDACTED | |
lock_passwd: false | |
ssh_pwauth: false | |
chpasswd: { expire: false } | |
# WiFi connect to HotSpot | |
write_files: | |
- content: | | |
allow-hotplug eth0 | |
auto eth0 | |
iface eth0 inet static | |
address 192.168.1.101 | |
netmask 255.255.255.0 | |
gateway 192.168.1.1 | |
path: /etc/network/interfaces.d/eth0 | |
# These commands will be ran once on first boot only | |
runcmd: | |
# Pickup the hostname changes | |
- 'systemctl disable dhcpcd' | |
- 'systemctl enable networking' | |
- 'systemctl restart avahi-daemon' | |
power_state: | |
delay: "+10" | |
mode: reboot | |
message: cloud-init complete | |
timeout: 120 | |
condition: True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment