forked from instruqt/packer-k3s
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathk3s.pkr.hcl
62 lines (50 loc) · 1.55 KB
/
k3s.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
variable "k3s_version" {
type = string
}
source "googlecompute" "k3s" {
project_id = "training-and-enablement"
region = "europe-west1"
zone = "europe-west1-b"
image_family = regex_replace("k3s-${regex_replace(var.k3s_version, "\\+.*$", "")}", "[^a-zA-Z0-9_-]", "-")
image_name = regex_replace("k3s-${var.k3s_version}-${ uuidv4() }", "[^a-zA-Z0-9_-]", "-")
source_image_family = "ubuntu-minimal-2104"
machine_type = "n1-standard-4"
disk_size = 20
ssh_username = "root"
}
build {
sources = ["source.googlecompute.k3s"]
provisioner "shell" {
script = "files/k3s-install.sh"
environment_vars = [
"K3S_VERSION=${ var.k3s_version }"
]
}
provisioner "file" {
sources = [
"files/k3s.service",
"files/kubectl-proxy.service",
"files/kube-dashboard.service",
]
destination = "/etc/systemd/system/"
}
provisioner "file" {
source = "files/k3s-start.sh"
destination = "/usr/local/bin/k3s-start.sh"
}
provisioner "file" {
source = "files/start.sh"
destination = "/usr/bin/start.sh"
}
provisioner "shell" {
inline = ["mkdir -p /opt/kube-dashboard"]
}
provisioner "file" {
source = "files/dashboard.yml"
destination = "/opt/kube-dashboard/dashboard.yml"
}
provisioner "file" {
source = "files/dashboard-sa.yml"
destination = "/opt/kube-dashboard/dashboard-sa.yml"
}
}