Skip to content

Commit 6b04074

Browse files
committed
addons: Add CRL Operator deployment by default
1 parent acfae78 commit 6b04074

File tree

15 files changed

+979
-1
lines changed

15 files changed

+979
-1
lines changed

.pylint-dict

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ cp
1919
checksum
2020
checksums
2121
containerd
22+
CRL
23+
crl
2224
dataset
2325
de
2426
debuild
@@ -37,6 +39,7 @@ getitem
3739
globals
3840
gofmt
3941
Kube
42+
kustomize
4043
html
4144
init
4245
io
@@ -52,6 +55,7 @@ metadata
5255
mkdir
5356
mkisofs
5457
mypy
58+
namespace
5559
nginx
5660
observability
5761
pdf

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
## Release 131.0.2 (in development)
44

5+
### Enhancements
6+
7+
- Install [crl-operator](https://github.com/scality/crl-operator) version
8+
[v1.0.0](https://github.com/scality/crl-operator/releases/tag/v1.0.0) by default
9+
(PR[#4692](https://github.com/scality/metalk8s/pull/4692))
10+
511
## Release 131.0.1
612

713
## Release 131.0.0

buildchain/buildchain/codegen.py

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@
55

66

77
import shlex
8-
from typing import Callable, Iterator, Tuple
8+
from typing import Callable, Iterator, Tuple, Dict
99

1010
import doit # type: ignore
1111

1212
from buildchain import constants
13+
from buildchain import targets
1314
from buildchain import types
1415
from buildchain import utils
1516

@@ -318,6 +319,65 @@ def codegen_chart_cert_manager() -> types.TaskDict:
318319
}
319320

320321

322+
def task_get_codegen_kustomize_crl_operator() -> types.TaskDict:
323+
"""Generate the kustomize manifests output for the CRL Operator."""
324+
kustomize_dir = constants.ROOT / "kustomizes/crl-operator"
325+
326+
cmd = f"kustomize build {kustomize_dir}"
327+
328+
return {
329+
"doc": task_get_codegen_kustomize_crl_operator.__doc__,
330+
"actions": [doit.action.CmdAction(cmd, cwd=constants.ROOT, save_out="stdout")],
331+
"file_dep": list(utils.git_ls(kustomize_dir)),
332+
"task_dep": ["check_for:kustomize"],
333+
}
334+
335+
336+
def task_transform_codegen_kustomize_crl_operator() -> types.TaskDict:
337+
"""Transform the kustomize manifests output for the CRL Operator."""
338+
339+
def _transform(stdout: str) -> Dict[str, str]:
340+
"""Transform the kustomize output."""
341+
# Note: We have to replace the namespace 'crl-operator-system' by
342+
# 'metalk8s-certs' as kustomize does not allow easily to patch every
343+
# occurrence in "custom resources fields" like Certificate dnsNames.
344+
return {
345+
"output": stdout.strip().replace("crl-operator-system", "metalk8s-certs")
346+
}
347+
348+
return {
349+
"doc": task_transform_codegen_kustomize_crl_operator.__doc__,
350+
"actions": [_transform],
351+
"task_dep": ["get_codegen_kustomize_crl_operator"],
352+
"getargs": {
353+
"stdout": ("get_codegen_kustomize_crl_operator", "stdout"),
354+
},
355+
}
356+
357+
358+
def codegen_kustomize_crl_operator() -> types.TaskDict:
359+
"""Generate the SLS file for the CRL Operator."""
360+
target_sls = constants.ROOT / "salt/metalk8s/addons/crl-operator/deployed/chart.sls"
361+
template_file = constants.ROOT / "kustomizes/template.sls.in"
362+
363+
tpl_task = targets.TemplateFile(
364+
task_name="kustomize_crl-operator",
365+
source=template_file,
366+
destination=target_sls,
367+
)
368+
tpl_task_dict = tpl_task.task
369+
tpl_task_dict.update(
370+
{
371+
"title": utils.title_with_subtask_name("CODEGEN"),
372+
"task_dep": ["transform_codegen_kustomize_crl_operator"],
373+
"getargs": {
374+
"Manifests": ("transform_codegen_kustomize_crl_operator", "output"),
375+
},
376+
}
377+
)
378+
return tpl_task_dict
379+
380+
321381
# List of available code generation tasks.
322382
CODEGEN: Tuple[Callable[[], types.TaskDict], ...] = (
323383
codegen_storage_operator,
@@ -330,6 +390,7 @@ def codegen_chart_cert_manager() -> types.TaskDict:
330390
codegen_chart_prometheus_adapter,
331391
codegen_chart_thanos,
332392
codegen_chart_cert_manager,
393+
codegen_kustomize_crl_operator,
333394
)
334395

335396

buildchain/buildchain/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ class ExtCommand(enum.Enum):
6565
SKOPEO = os.getenv("SKOPEO_BIN", "skopeo")
6666
TOX = os.getenv("TOX_BIN", "tox")
6767
VAGRANT = os.getenv("VAGRANT_BIN", "vagrant")
68+
KUSTOMIZE = os.getenv("KUSTOMIZE_BIN", "kustomize")
6869

6970
@property
7071
def command_name(self) -> str:

buildchain/buildchain/image.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ def _local_image(name: str, **kwargs: Any) -> targets.LocalImage:
219219
],
220220
constants.SCALITY_REPOSITORY: [
221221
"ui-operator",
222+
"crl-operator",
222223
],
223224
}
224225

buildchain/buildchain/salt_tree.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,8 @@ def _download_ui_operator_crds() -> str:
292292
Path("salt/metalk8s/addons/cert-manager/deployed/chart.sls"),
293293
Path("salt/metalk8s/addons/cert-manager/deployed/init.sls"),
294294
Path("salt/metalk8s/addons/cert-manager/deployed/namespace.sls"),
295+
Path("salt/metalk8s/addons/crl-operator/deployed/chart.sls"),
296+
Path("salt/metalk8s/addons/crl-operator/deployed/init.sls"),
295297
Path("salt/metalk8s/addons/dex/ca/init.sls"),
296298
Path("salt/metalk8s/addons/dex/ca/installed.sls"),
297299
Path("salt/metalk8s/addons/dex/ca/advertised.sls"),

buildchain/buildchain/versions.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,11 @@ def _version_prefix(version: str, prefix: str = "v") -> str:
302302
version=_version_prefix(CERT_MANAGER_VERSION),
303303
digest="sha256:a076f72f33a22dfd3a23727f1e1a069817819406b39e5b0fd9cb97d3338cb8d8",
304304
),
305+
Image(
306+
name="crl-operator",
307+
version="v1.0.0",
308+
digest="sha256:86b4198036c1f83f1d9363a1e2ae78015482ca4fe60cd706939b8730c179ac8a",
309+
),
305310
)
306311

307312
CONTAINER_IMAGES_MAP = {image.name: image for image in CONTAINER_IMAGES}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
$patch: delete
2+
apiVersion: v1
3+
kind: Namespace
4+
metadata:
5+
name: system
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: not-important
5+
spec:
6+
template:
7+
nodeSelector:
8+
node-role.kubernetes.io/master: ""
9+
spec:
10+
tolerations:
11+
- key: "node-role.kubernetes.io/bootstrap"
12+
operator: "Exists"
13+
effect: "NoSchedule"
14+
- key: "node-role.kubernetes.io/infra"
15+
operator: "Exists"
16+
effect: "NoSchedule"
17+
- key: "node-role.kubernetes.io/master"
18+
operator: "Exists"
19+
effect: "NoSchedule"
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
namespace: metalk8s-certs
2+
3+
resources:
4+
- github.com/scality/crl-operator.git/config/default?ref=v1.0.0
5+
6+
images:
7+
- name: controller
8+
newName: '{% endraw -%}{{ build_image_name("crl-operator", False) }}{%- raw %}'
9+
newTag: v1.0.0
10+
11+
patches:
12+
- patch: |-
13+
- op: add
14+
path: /spec/template/spec/containers/0/args/-
15+
value: "--cert-manager-namespace=metalk8s-certs"
16+
target:
17+
kind: Deployment
18+
- path: deploy_patch.yaml
19+
target:
20+
kind: Deployment
21+
- path: delete_ns.yaml

0 commit comments

Comments
 (0)