-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathcluster-oidcconfig.tf
78 lines (71 loc) · 1.67 KB
/
cluster-oidcconfig.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
68
69
70
71
72
73
74
75
76
77
78
resource "kubernetes_ingress_v1" "oidc" {
depends_on = [hcloud_load_balancer_service.management_lb_k8s_service]
count = var.expose_oidc_issuer_url != null ? 1 : 0
metadata {
name = "oidc-ingress"
namespace = "default"
annotations = {
"cert-manager.io/cluster-issuer" = "cloudflare"
"nginx.ingress.kubernetes.io/backend-protocol" = "HTTPS"
}
}
spec {
ingress_class_name = "nginx"
rule {
host = local.oidc_issuer_subdomain
http {
path {
backend {
service {
name = "kubernetes"
port {
number = 443
}
}
}
path = "/.well-known/openid-configuration"
path_type = "Exact"
}
path {
backend {
service {
name = "kubernetes"
port {
number = 443
}
}
}
path = "/openid/v1/jwks"
path_type = "Exact"
}
}
}
tls {
hosts = [
local.oidc_issuer_subdomain
]
secret_name = "oidc-tls"
}
}
lifecycle {
ignore_changes = [
metadata[0].annotations,
]
}
}
resource "kubernetes_cluster_role_binding" "oidc" {
count = var.expose_oidc_issuer_url != null ? 1 : 0
metadata {
name = "service-account-issuer-discovery"
}
role_ref {
kind = "ClusterRole"
name = "system:service-account-issuer-discovery"
api_group = "rbac.authorization.k8s.io"
}
subject {
kind = "Group"
name = "system:unauthenticated"
api_group = "rbac.authorization.k8s.io"
}
}