-
Notifications
You must be signed in to change notification settings - Fork 0
/
project.tf
128 lines (116 loc) · 2.37 KB
/
project.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
terraform {
backend "pg" {}
}
provider "kubernetes" {
host = var.host
token = var.token
cluster_ca_certificate = base64decode(
var.ca_certificate
)
}
resource "kubernetes_namespace" "namespace" {
metadata {
name = var.namespace
labels = {
from = "shapeblock"
}
}
}
data "kubernetes_secret" "registry_creds" {
metadata {
name = "registry-creds"
namespace = "default"
}
}
resource "kubernetes_secret" "registry_creds" {
metadata {
name = "registry-creds"
namespace = var.namespace
labels = {
from = "shapeblock"
}
}
data = data.kubernetes_secret.registry_creds.data
type = "kubernetes.io/dockerconfigjson"
}
// service account
resource "kubernetes_service_account" "sa" {
metadata {
name = var.namespace
namespace = var.namespace
labels = {
from = "shapeblock"
}
}
secret {
name = "registry-creds"
}
// TODO: add another secret
image_pull_secret {
name = "registry-creds"
}
}
// role binding
resource "kubernetes_role_binding" "rb" {
metadata {
name = var.namespace
namespace = var.namespace
labels = {
from = "shapeblock"
}
}
role_ref {
api_group = "rbac.authorization.k8s.io"
kind = "ClusterRole"
name = "admin"
}
subject {
kind = "ServiceAccount"
name = var.namespace
namespace = var.namespace
}
}
resource "kubernetes_role_binding" "rb_kpack" {
metadata {
name = "${var.namespace}-kpack"
namespace = var.namespace
labels = {
from = "shapeblock"
}
}
role_ref {
api_group = "rbac.authorization.k8s.io"
kind = "ClusterRole"
name = "kpack-controller-admin"
}
subject {
kind = "ServiceAccount"
name = var.namespace
namespace = var.namespace
}
}
resource "kubernetes_role_binding" "rb_helm" {
metadata {
name = "${var.namespace}-helm"
namespace = var.namespace
labels = {
from = "shapeblock"
}
}
role_ref {
api_group = "rbac.authorization.k8s.io"
kind = "ClusterRole"
name = "helm-operator"
}
subject {
kind = "ServiceAccount"
name = var.namespace
namespace = var.namespace
}
}
data "kubernetes_secret" "token" {
metadata {
name = kubernetes_service_account.sa.default_secret_name
namespace = var.namespace
}
}