Skip to content

Commit d2d018c

Browse files
authored
Merge pull request #228 from projectsyn/feat/cluster-info-configmap
Deploy configmap containing the cluster's Project Syn ID and tenant ID
2 parents b3163f2 + 3e2d255 commit d2d018c

File tree

15 files changed

+354
-0
lines changed

15 files changed

+354
-0
lines changed

class/argocd.yml

+4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ parameters:
99
input_type: jsonnet
1010
input_paths:
1111
- argocd/component/namespace.jsonnet
12+
- output_path: argocd/02_cluster_info/
13+
input_type: jsonnet
14+
input_paths:
15+
- argocd/component/cluster-info.jsonnet
1216
- output_path: argocd/20_rbac/
1317
input_type: jsonnet
1418
input_paths:

component/cluster-info.jsonnet

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
local kap = import 'lib/kapitan.libjsonnet';
2+
local kube = import 'lib/kube.libjsonnet';
3+
local inv = kap.inventory();
4+
local params = inv.parameters.argocd;
5+
6+
local cluster_info_configmap =
7+
kube.ConfigMap('cluster-info') {
8+
metadata+: {
9+
namespace: params.namespace,
10+
annotations+: {
11+
'syn.tools/description':
12+
'The cluster-info config map contains a selection of Project Syn metadata associated with the cluster. All authenticated users can access this configmap.',
13+
},
14+
},
15+
data: {
16+
cluster_id: inv.parameters.cluster.name,
17+
tenant_id: inv.parameters.cluster.tenant,
18+
},
19+
};
20+
21+
local cluster_info_configmap_role = kube.Role('cluster-info-access') {
22+
metadata+: {
23+
namespace: params.namespace,
24+
},
25+
rules: [
26+
{
27+
apiGroups: [ '' ],
28+
resources: [ 'configmaps' ],
29+
resourceNames: [ cluster_info_configmap.metadata.name ],
30+
verbs: [ 'get' ],
31+
},
32+
],
33+
};
34+
35+
local cluster_info_configmap_rolebinding = kube.RoleBinding('cluster-info-access') {
36+
metadata+: {
37+
namespace: params.namespace,
38+
},
39+
subjects: [
40+
{
41+
apiGroup: 'rbac.authorization.k8s.io',
42+
kind: 'Group',
43+
name: 'system:authenticated',
44+
},
45+
],
46+
roleRef_: cluster_info_configmap_role,
47+
};
48+
49+
{
50+
configmap: cluster_info_configmap,
51+
rbac: [
52+
cluster_info_configmap_role,
53+
cluster_info_configmap_rolebinding,
54+
],
55+
}

docs/modules/ROOT/pages/references/parameters.adoc

+7
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ default:: `syn`
1010

1111
The namespace in which to deploy this component.
1212

13+
[TIP]
14+
====
15+
The component deploys a configmap called `cluster-info` in this namespace.
16+
The configmap contains some Project Syn metadata associated with the cluster.
17+
All authenticated users (group `system:authenticated`) can read this configmap.
18+
====
19+
1320
== `distribution`
1421

1522
[horizontal]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
apiVersion: v1
2+
data:
3+
cluster_id: c-green-test-1234
4+
tenant_id: t-silent-test-1234
5+
kind: ConfigMap
6+
metadata:
7+
annotations:
8+
syn.tools/description: The cluster-info config map contains a selection of Project
9+
Syn metadata associated with the cluster. All authenticated users can access
10+
this configmap.
11+
labels:
12+
name: cluster-info
13+
name: cluster-info
14+
namespace: syn
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: Role
3+
metadata:
4+
annotations: {}
5+
labels:
6+
name: cluster-info-access
7+
name: cluster-info-access
8+
namespace: syn
9+
rules:
10+
- apiGroups:
11+
- ''
12+
resourceNames:
13+
- cluster-info
14+
resources:
15+
- configmaps
16+
verbs:
17+
- get
18+
---
19+
apiVersion: rbac.authorization.k8s.io/v1
20+
kind: RoleBinding
21+
metadata:
22+
annotations: {}
23+
labels:
24+
name: cluster-info-access
25+
name: cluster-info-access
26+
namespace: syn
27+
roleRef:
28+
apiGroup: rbac.authorization.k8s.io
29+
kind: Role
30+
name: cluster-info-access
31+
subjects:
32+
- apiGroup: rbac.authorization.k8s.io
33+
kind: Group
34+
name: system:authenticated
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
apiVersion: v1
2+
data:
3+
cluster_id: c-green-test-1234
4+
tenant_id: t-silent-test-1234
5+
kind: ConfigMap
6+
metadata:
7+
annotations:
8+
syn.tools/description: The cluster-info config map contains a selection of Project
9+
Syn metadata associated with the cluster. All authenticated users can access
10+
this configmap.
11+
labels:
12+
name: cluster-info
13+
name: cluster-info
14+
namespace: syn
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: Role
3+
metadata:
4+
annotations: {}
5+
labels:
6+
name: cluster-info-access
7+
name: cluster-info-access
8+
namespace: syn
9+
rules:
10+
- apiGroups:
11+
- ''
12+
resourceNames:
13+
- cluster-info
14+
resources:
15+
- configmaps
16+
verbs:
17+
- get
18+
---
19+
apiVersion: rbac.authorization.k8s.io/v1
20+
kind: RoleBinding
21+
metadata:
22+
annotations: {}
23+
labels:
24+
name: cluster-info-access
25+
name: cluster-info-access
26+
namespace: syn
27+
roleRef:
28+
apiGroup: rbac.authorization.k8s.io
29+
kind: Role
30+
name: cluster-info-access
31+
subjects:
32+
- apiGroup: rbac.authorization.k8s.io
33+
kind: Group
34+
name: system:authenticated
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
apiVersion: v1
2+
data:
3+
cluster_id: c-green-test-1234
4+
tenant_id: t-silent-test-1234
5+
kind: ConfigMap
6+
metadata:
7+
annotations:
8+
syn.tools/description: The cluster-info config map contains a selection of Project
9+
Syn metadata associated with the cluster. All authenticated users can access
10+
this configmap.
11+
labels:
12+
name: cluster-info
13+
name: cluster-info
14+
namespace: syn
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: Role
3+
metadata:
4+
annotations: {}
5+
labels:
6+
name: cluster-info-access
7+
name: cluster-info-access
8+
namespace: syn
9+
rules:
10+
- apiGroups:
11+
- ''
12+
resourceNames:
13+
- cluster-info
14+
resources:
15+
- configmaps
16+
verbs:
17+
- get
18+
---
19+
apiVersion: rbac.authorization.k8s.io/v1
20+
kind: RoleBinding
21+
metadata:
22+
annotations: {}
23+
labels:
24+
name: cluster-info-access
25+
name: cluster-info-access
26+
namespace: syn
27+
roleRef:
28+
apiGroup: rbac.authorization.k8s.io
29+
kind: Role
30+
name: cluster-info-access
31+
subjects:
32+
- apiGroup: rbac.authorization.k8s.io
33+
kind: Group
34+
name: system:authenticated
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
apiVersion: v1
2+
data:
3+
cluster_id: c-green-test-1234
4+
tenant_id: t-silent-test-1234
5+
kind: ConfigMap
6+
metadata:
7+
annotations:
8+
syn.tools/description: The cluster-info config map contains a selection of Project
9+
Syn metadata associated with the cluster. All authenticated users can access
10+
this configmap.
11+
labels:
12+
name: cluster-info
13+
name: cluster-info
14+
namespace: syn
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: Role
3+
metadata:
4+
annotations: {}
5+
labels:
6+
name: cluster-info-access
7+
name: cluster-info-access
8+
namespace: syn
9+
rules:
10+
- apiGroups:
11+
- ''
12+
resourceNames:
13+
- cluster-info
14+
resources:
15+
- configmaps
16+
verbs:
17+
- get
18+
---
19+
apiVersion: rbac.authorization.k8s.io/v1
20+
kind: RoleBinding
21+
metadata:
22+
annotations: {}
23+
labels:
24+
name: cluster-info-access
25+
name: cluster-info-access
26+
namespace: syn
27+
roleRef:
28+
apiGroup: rbac.authorization.k8s.io
29+
kind: Role
30+
name: cluster-info-access
31+
subjects:
32+
- apiGroup: rbac.authorization.k8s.io
33+
kind: Group
34+
name: system:authenticated
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
apiVersion: v1
2+
data:
3+
cluster_id: c-green-test-1234
4+
tenant_id: t-silent-test-1234
5+
kind: ConfigMap
6+
metadata:
7+
annotations:
8+
syn.tools/description: The cluster-info config map contains a selection of Project
9+
Syn metadata associated with the cluster. All authenticated users can access
10+
this configmap.
11+
labels:
12+
name: cluster-info
13+
name: cluster-info
14+
namespace: syn
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: Role
3+
metadata:
4+
annotations: {}
5+
labels:
6+
name: cluster-info-access
7+
name: cluster-info-access
8+
namespace: syn
9+
rules:
10+
- apiGroups:
11+
- ''
12+
resourceNames:
13+
- cluster-info
14+
resources:
15+
- configmaps
16+
verbs:
17+
- get
18+
---
19+
apiVersion: rbac.authorization.k8s.io/v1
20+
kind: RoleBinding
21+
metadata:
22+
annotations: {}
23+
labels:
24+
name: cluster-info-access
25+
name: cluster-info-access
26+
namespace: syn
27+
roleRef:
28+
apiGroup: rbac.authorization.k8s.io
29+
kind: Role
30+
name: cluster-info-access
31+
subjects:
32+
- apiGroup: rbac.authorization.k8s.io
33+
kind: Group
34+
name: system:authenticated
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
apiVersion: v1
2+
data:
3+
cluster_id: c-green-test-1234
4+
tenant_id: t-silent-test-1234
5+
kind: ConfigMap
6+
metadata:
7+
annotations:
8+
syn.tools/description: The cluster-info config map contains a selection of Project
9+
Syn metadata associated with the cluster. All authenticated users can access
10+
this configmap.
11+
labels:
12+
name: cluster-info
13+
name: cluster-info
14+
namespace: syn
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: Role
3+
metadata:
4+
annotations: {}
5+
labels:
6+
name: cluster-info-access
7+
name: cluster-info-access
8+
namespace: syn
9+
rules:
10+
- apiGroups:
11+
- ''
12+
resourceNames:
13+
- cluster-info
14+
resources:
15+
- configmaps
16+
verbs:
17+
- get
18+
---
19+
apiVersion: rbac.authorization.k8s.io/v1
20+
kind: RoleBinding
21+
metadata:
22+
annotations: {}
23+
labels:
24+
name: cluster-info-access
25+
name: cluster-info-access
26+
namespace: syn
27+
roleRef:
28+
apiGroup: rbac.authorization.k8s.io
29+
kind: Role
30+
name: cluster-info-access
31+
subjects:
32+
- apiGroup: rbac.authorization.k8s.io
33+
kind: Group
34+
name: system:authenticated

0 commit comments

Comments
 (0)