-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgitlab-admin.tf
54 lines (50 loc) · 1.55 KB
/
gitlab-admin.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
provider "kubernetes" {
host = azurerm_kubernetes_cluster.aks.kube_config.0.host
cluster_ca_certificate = base64decode(azurerm_kubernetes_cluster.aks.kube_config.0.cluster_ca_certificate)
username = azurerm_kubernetes_cluster.aks.kube_config.0.username
password = azurerm_kubernetes_cluster.aks.kube_config.0.password
client_certificate = base64decode(azurerm_kubernetes_cluster.aks.kube_config.0.client_certificate)
client_key = base64decode(azurerm_kubernetes_cluster.aks.kube_config.0.client_key)
}
resource "kubernetes_service_account" "gitlab-admin" {
metadata {
name = "gitlab-admin"
namespace = "kube-system"
}
}
resource "kubernetes_secret" "gitlab-admin" {
metadata {
name = "gitlab-admin"
namespace = "kube-system"
annotations = {
"kubernetes.io/service-account.name" = kubernetes_service_account.gitlab-admin.metadata.0.name
}
}
lifecycle {
ignore_changes = [
data
]
}
type = "kubernetes.io/service-account-token"
}
data "kubernetes_secret" "gitlab-admin-token" {
metadata {
name = kubernetes_service_account.gitlab-admin.default_secret_name
namespace = "kube-system"
}
}
resource "kubernetes_cluster_role_binding" "gitlab-admin" {
metadata {
name = "gitlab-admin"
}
role_ref {
api_group = "rbac.authorization.k8s.io"
kind = "ClusterRole"
name = "cluster-admin"
}
subject {
kind = "ServiceAccount"
name = "gitlab-admin"
namespace = "kube-system"
}
}