-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathk8s.tf
43 lines (34 loc) · 1.26 KB
/
k8s.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
# ---------------------------------------------------------------------------------------------------------------------
# CONFIGURE KUBECTL AND RBAC ROLE PERMISSIONS
# ---------------------------------------------------------------------------------------------------------------------
# configure kubectl with the credentials of the GKE cluster
resource "null_resource" "configure_kubectl" {
provisioner "local-exec" {
command = "gcloud beta container clusters get-credentials ${module.gke_cluster.name} --region ${var.region} --project ${var.project}"
# Use environment variables to allow custom kubectl config paths
environment = {
KUBECONFIG = var.kubectl_config_path != "" ? var.kubectl_config_path : ""
}
}
depends_on = [google_container_node_pool.node_pool]
}
resource "kubernetes_cluster_role_binding" "user" {
metadata {
name = "admin-user"
}
role_ref {
kind = "ClusterRole"
name = "cluster-admin"
api_group = "rbac.authorization.k8s.io"
}
subject {
kind = "User"
name = data.google_client_openid_userinfo.terraform_user.email
api_group = "rbac.authorization.k8s.io"
}
subject {
kind = "Group"
name = "system:masters"
api_group = "rbac.authorization.k8s.io"
}
}