-
Notifications
You must be signed in to change notification settings - Fork 4
/
k3s.pkr.hcl
84 lines (69 loc) · 1.67 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
variable "k3s_version" {
type = string
}
variable "project_id" {
type = string
}
variable "region" {
type = string
default = "europe-west1"
}
variable "zone" {
type = string
default = "europe-west1-b"
}
packer {
required_plugins {
googlecompute = {
source = "github.com/hashicorp/googlecompute"
version = "~> 1"
}
}
}
source "googlecompute" "k3s" {
project_id = var.project_id
region = var.region
zone = var.zone
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-2204-lts"
machine_type = "n1-standard-4"
disk_size = 20
disable_default_service_account = true
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" {
sources = [
"files/dashboard.yml",
"files/dashboard-sa.yml",
]
destination = "/opt/kube-dashboard/"
}
}