Skip to content

Commit ccd93f9

Browse files
committed
Add how-to for making components multi-tenant aware
1 parent a8c5341 commit ccd93f9

File tree

2 files changed

+65
-0
lines changed

2 files changed

+65
-0
lines changed

docs/modules/ROOT/nav.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ include::steward:ROOT:partial$nav-tutorials.adoc[]
4242
* xref:how-tos/change-parameter.adoc[Change a parameter]
4343
* xref:how-tos/prepare_for_component_sync.adoc[Prepare component for template updates]
4444
* xref:how-tos/tenant-version-pins.adoc[Renovate version pins]
45+
* xref:how-tos/component-multi-tenancy.adoc[]
4546
* Commodore
4647
+
4748
--
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
= Make a Commodore component multi-tenant aware
2+
3+
Project Syn supports xref:explanations/argocd-multitenancy.adoc[multi-tenancy in the Project Syn ArgoCD instance].
4+
5+
Currently components need to be marked as multi-tenant aware explicitly.
6+
This how-to provides the bare minimum configuration that's necessary to make an existing component multi-tenant aware.
7+
8+
[NOTE]
9+
====
10+
The default https://github.com/projectsyn/commodore-component-template[Commodore component template] is updated to generate multi-tenant aware components by default.
11+
12+
Components which receive template updates should already be updated to be multi-tenant aware.
13+
====
14+
15+
. Adjust the component's ArgoCD application manifest generation (usually in `component/app.jsonnet`)
16+
+
17+
.`component/app.jsonnet`
18+
[source,jsonnet]
19+
----
20+
local kap = import 'lib/kapitan.libjsonnet';
21+
local kube = import 'lib/kube.libjsonnet';
22+
local inv = kap.inventory();
23+
local params = inv.parameters.<component>; <1>
24+
local argocd = import 'lib/argocd.libjsonnet';
25+
26+
local app = argocd.App(<component>, params.namespace, secrets=true); <1>
27+
28+
local appPath =
29+
local project = std.get(app, 'spec', { project: 'syn' }).project; <2>
30+
if project == 'syn' then 'apps' else 'apps-%s' % project;
31+
32+
{
33+
['%s/<component>' % appPath]: app, <1>
34+
}
35+
----
36+
<1> Replace `<component> with the component's name.
37+
<2> We use `std.get()` here because `commodore component compile` generates an empty application manifest by default.
38+
39+
. Adjust the component's Kapitan compile step for the application manifests (in `class/<component-name>.yml`)
40+
+
41+
.`class/<component-name>.yml`
42+
[source,yaml]
43+
----
44+
parameters:
45+
kapitan:
46+
compile:
47+
- input_paths:
48+
- ${_instance}/component/app.jsonnet
49+
input_type: jsonnet
50+
output_path: apps/
51+
output_path: .
52+
----
53+
54+
. Mark the component as multi-tenant aware
55+
+
56+
[source,yaml]
57+
----
58+
parameters:
59+
<component_name>: <1>
60+
=_metadata: <2>
61+
multi_tenant: true
62+
----
63+
<1> Replace `component_name` with the component's parameter key.
64+
<2> We recommend making the component's metadata constant if it isn't already.

0 commit comments

Comments
 (0)