Add k8s-server configuration and deployment scripts
This commit is contained in:
@@ -0,0 +1,92 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
### CONFIG ###
|
||||
OS_DISK=/dev/sda
|
||||
HOSTNAME=k8s-server
|
||||
STATE_VERSION="25.05"
|
||||
TIMEZONE="Europe/Berlin"
|
||||
USERNAME="danlin"
|
||||
PASSWORD="changeme"
|
||||
ROOT_PASS="root"
|
||||
|
||||
echo ">>> WARNUNG: ALLE DATEN auf ${OS_DISK} werden GELÖSCHT!"
|
||||
echo ">>> Warte 5 Sekunden... (STRG+C zum Abbrechen)"
|
||||
sleep 5
|
||||
|
||||
echo ">>> Partitioniere OS-Disk (${OS_DISK}) für EFI + ROOT..."
|
||||
parted "${OS_DISK}" --script mklabel gpt
|
||||
parted "${OS_DISK}" --script mkpart ESP fat32 1MiB 513MiB
|
||||
parted "${OS_DISK}" --script set 1 esp on
|
||||
parted "${OS_DISK}" --script mkpart primary ext4 513MiB 100%
|
||||
|
||||
echo ">>> Formatiere OS-Partitionen..."
|
||||
mkfs.fat -F32 "${OS_DISK}1"
|
||||
mkfs.ext4 -F "${OS_DISK}2"
|
||||
|
||||
echo ">>> Mounten..."
|
||||
mount "${OS_DISK}2" /mnt
|
||||
mkdir -p /mnt/boot
|
||||
mount "${OS_DISK}1" /mnt/boot
|
||||
|
||||
echo ">>> Generiere NixOS-Config..."
|
||||
nixos-generate-config --root /mnt
|
||||
|
||||
CONFIG=/mnt/etc/nixos/configuration.nix
|
||||
|
||||
cat > "${CONFIG}" <<EOF
|
||||
{ config, pkgs, ... }:
|
||||
|
||||
{
|
||||
imports = [ ./hardware-configuration.nix ];
|
||||
|
||||
boot.loader.systemd-boot.enable = true;
|
||||
boot.loader.efi.canTouchEfiVariables = true;
|
||||
|
||||
security.sudo.wheelNeedsPassword = false;
|
||||
|
||||
networking.hostName = "${HOSTNAME}";
|
||||
networking.useDHCP = false;
|
||||
networking.interfaces.ens18.ipv4.addresses = [
|
||||
{
|
||||
address = "10.202.82.7";
|
||||
prefixLength = 24;
|
||||
}
|
||||
];
|
||||
networking.defaultGateway = "10.202.82.1";
|
||||
networking.nameservers = [ "10.202.82.3" "10.202.82.4" ];
|
||||
|
||||
time.timeZone = "${TIMEZONE}";
|
||||
|
||||
services.openssh.enable = true;
|
||||
|
||||
networking.firewall = {
|
||||
enable = true;
|
||||
allowedTCPPorts = [ 22 6443 ];
|
||||
allowedUDPPorts = [ 8472 ];
|
||||
};
|
||||
|
||||
users.users.${USERNAME} = {
|
||||
isNormalUser = true;
|
||||
extraGroups = [ "wheel" ];
|
||||
initialPassword = "${PASSWORD}";
|
||||
openssh.authorizedKeys.keys = [
|
||||
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAzAW0DTpdQJaQOWDC3YJCmPc/veBQ0R3e1q9nOlWgxC danlin@MacBook-Pro-von-Daniel.fritz.box"
|
||||
];
|
||||
};
|
||||
|
||||
users.users.root.initialPassword = "${ROOT_PASS}";
|
||||
|
||||
environment.systemPackages = with pkgs; [
|
||||
vim
|
||||
htop
|
||||
];
|
||||
|
||||
system.stateVersion = "${STATE_VERSION}";
|
||||
}
|
||||
EOF
|
||||
|
||||
echo ">>> Starte nixos-install..."
|
||||
nixos-install
|
||||
|
||||
echo ">>> Fertig. Jetzt reboot ausführen."
|
||||
Reference in New Issue
Block a user