-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathca.tf
62 lines (51 loc) · 1.55 KB
/
ca.tf
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
# Borrowed from the Tectonic installer: (https://github.com/coreos/tectonic-installer/blob/master/modules/tls/kube/self-signed/ca.tf)
resource "tls_private_key" "kube_ca" {
algorithm = "RSA"
rsa_bits = "2048"
}
resource "tls_self_signed_cert" "kube_ca" {
key_algorithm = "${tls_private_key.kube_ca.algorithm}"
private_key_pem = "${tls_private_key.kube_ca.private_key_pem}"
subject {
common_name = "Kubernetes"
organization = "Kubernetes"
country = "US"
locality = "Portland"
organizational_unit = "CA"
province = "Oregon"
}
is_ca_certificate = true
validity_period_hours = 8760
allowed_uses = [
"key_encipherment",
"digital_signature",
"cert_signing",
"client_auth",
"server_auth",
]
}
resource "local_file" "kube_ca_key" {
content = "${tls_private_key.kube_ca.private_key_pem}"
filename = "./generated/tls/ca-key.pem"
}
resource "local_file" "kube_ca_crt" {
content = "${tls_self_signed_cert.kube_ca.cert_pem}"
filename = "./generated/tls/ca.pem"
}
resource "null_resource" "ca_certs" {
count = "${length(var.apiserver_node_names)}"
connection {
type = "ssh"
user = "${var.node_user}"
host = "${element(var.apiserver_node_names, count.index)}"
bastion_host = "${var.apiserver_public_ip}"
}
provisioner "file" {
source = "./generated/tls/ca.pem"
destination = "~/ca.pem"
}
provisioner "file" {
source = "./generated/tls/ca-key.pem"
destination = "~/ca-key.pem"
}
}