-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmaster-template.pkr.hcl
90 lines (82 loc) · 2.83 KB
/
master-template.pkr.hcl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
variable "box_description" {
type = string
default = "k3OS(Master) is a Linux distribution designed to remove as much OS maintenance as possible in a Kubernetes cluster"
}
variable "box_version" {
type = string
default = "v0.21.5-k3s2r1"
}
variable "iso_checksum" {
type = string
default = "a465b0c52ce415173f6ef38fda5d090580fbaae0970556a62f21c7db8eeb72b1"
}
variable "iso_url" {
type = string
default = "https://github.com/rancher/k3os/releases/download/v0.21.5-k3s2r1/k3os-amd64.iso"
}
variable "iso_target_path" {
type = string
default = "E:\\Program Files\\VirtualBox VMs\\k3os-amd64-0.21.iso"
}
variable "password" {
type = string
default = "rancher"
}
source "virtualbox-iso" "k3os" {
boot_command = [
"<down>", "<enter>",
"<wait20s>",
"y", "<enter>",
"http://{{ .HTTPIP }}:{{ .HTTPPort }}/master-config.yml", "<enter>",
"y", "<enter>",
]
boot_wait = "5s"
disk_size = "8000"
export_opts = ["--manifest", "--vsys", "0", "--description", "${var.box_description}", "--version", "${var.box_version}"]
format = "ova"
guest_os_type = "Linux_64"
rtc_time_base = "UTC"
http_directory = "."
iso_checksum = "sha256:${var.iso_checksum}"
iso_url = "${var.iso_url}"
iso_target_path = "${var.iso_target_path}"
post_shutdown_delay = "10s"
shutdown_command = "sudo poweroff"
ssh_keypair_name = ""
ssh_private_key_file = "packer_rsa"
ssh_timeout = "1000s"
ssh_username = "rancher"
guest_additions_mode = "disable"
vboxmanage = [
["modifyvm", "{{.Name}}", "--memory", "2048"],
["modifyvm", "{{.Name}}", "--cpus", "1"]
]
}
build {
sources = ["source.virtualbox-iso.k3os"]
provisioner "file" {
source = "master-images.tar"
destination = "~/master-images.tar"
}
provisioner "file" {
source = "./kubernetes-node-exporter"
destination = "~"
}
provisioner "file" {
source = "./kub-objects"
destination = "~"
}
provisioner "shell" {
execute_command = "{{.Vars}} bash '{{.Path}}'"
inline = ["sudo bash -c \"echo -e 'write_files:\n- path: /var/lib/connman/default.config\n content: |-\n [service_eth0]\n Type=ethernet\n IPv4=192.168.1.200/255.255.255.0/192.168.1.1\n Ipv6=off\n Nameservers=192.168.1.1\n' > /var/lib/rancher/k3os/config.yaml\"",
"sudo ctr images import ~/master-images.tar",
"sudo rm ~/master-images.tar",
"kubectl create ns monitoring",
"kubectl apply -f ~/kub-objects/rbac_scheduler.yaml -f ~/kubernetes-node-exporter",
"sudo bash -c \"echo -e '#!/bin/bash\nsudo poweroff' > /usr/local/bin/shutdown \"",
"sudo chmod 755 /usr/local/bin/shutdown"]
}
post-processor "vagrant" {
output = "master_k3os_{{.Provider}}.box"
}
}