-
-
Notifications
You must be signed in to change notification settings - Fork 103
/
auth.tf
68 lines (61 loc) · 2.54 KB
/
auth.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
63
64
65
66
67
locals {
# component kubeconfigs assets map
auth_kubeconfigs = {
"auth/admin.conf" = local.kubeconfig-admin,
"auth/controller-manager.conf" = local.kubeconfig-controller-manager
"auth/scheduler.conf" = local.kubeconfig-scheduler
}
}
locals {
# Generated admin kubeconfig to bootstrap control plane
kubeconfig-admin = templatefile("${path.module}/resources/kubeconfig-admin",
{
name = var.cluster_name
ca_cert = base64encode(tls_self_signed_cert.kube-ca.cert_pem)
kubelet_cert = base64encode(tls_locally_signed_cert.admin.cert_pem)
kubelet_key = base64encode(tls_private_key.admin.private_key_pem)
server = format("https://%s:%s", var.api_servers[0], var.external_apiserver_port)
}
)
# Generated kube-controller-manager kubeconfig
kubeconfig-controller-manager = templatefile("${path.module}/resources/kubeconfig-admin",
{
name = var.cluster_name
ca_cert = base64encode(tls_self_signed_cert.kube-ca.cert_pem)
kubelet_cert = base64encode(tls_locally_signed_cert.controller-manager.cert_pem)
kubelet_key = base64encode(tls_private_key.controller-manager.private_key_pem)
server = format("https://%s:%s", var.api_servers[0], var.external_apiserver_port)
}
)
# Generated kube-controller-manager kubeconfig
kubeconfig-scheduler = templatefile("${path.module}/resources/kubeconfig-admin",
{
name = var.cluster_name
ca_cert = base64encode(tls_self_signed_cert.kube-ca.cert_pem)
kubelet_cert = base64encode(tls_locally_signed_cert.scheduler.cert_pem)
kubelet_key = base64encode(tls_private_key.scheduler.private_key_pem)
server = format("https://%s:%s", var.api_servers[0], var.external_apiserver_port)
}
)
# Generated kubeconfig to bootstrap Kubelets
kubeconfig-bootstrap = templatefile("${path.module}/resources/kubeconfig-bootstrap",
{
ca_cert = base64encode(tls_self_signed_cert.kube-ca.cert_pem)
server = format("https://%s:%s", var.api_servers[0], var.external_apiserver_port)
token_id = random_password.bootstrap-token-id.result
token_secret = random_password.bootstrap-token-secret.result
}
)
}
# Generate a cryptographically random token id (public)
resource "random_password" "bootstrap-token-id" {
length = 6
upper = false
special = false
}
# Generate a cryptographically random token secret
resource "random_password" "bootstrap-token-secret" {
length = 16
upper = false
special = false
}