-
Notifications
You must be signed in to change notification settings - Fork 1
/
gitlab-admin.tf
59 lines (53 loc) · 1.38 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
55
56
57
58
59
data "aws_eks_cluster" "my-cluster" {
name = module.eks.cluster_id
}
data "aws_eks_cluster_auth" "my-auth" {
name = module.eks.cluster_id
}
provider "kubernetes" {
host = data.aws_eks_cluster.my-cluster.endpoint
cluster_ca_certificate = base64decode(data.aws_eks_cluster.my-cluster.certificate_authority.0.data)
token = data.aws_eks_cluster_auth.my-auth.token
}
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"
}
}