Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

salt, build: automate catalogd install #4498

Draft
wants to merge 28 commits into
base: development/130.0
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
7a929e7
salt, build: automate catalogd install
eg-ayoub Dec 10, 2024
9a1491e
[WIP] salt, build: automate operator-controller install
eg-ayoub Dec 11, 2024
5177d36
salt: wait for cert-manager before installing olm
eg-ayoub Dec 12, 2024
4d16482
salt: move common olmv1 components to new folder
eg-ayoub Dec 13, 2024
4be186b
salt: install operatorhubio catalog
eg-ayoub Dec 23, 2024
a11d4ae
buildchain: generate nginx-operator bundle
eg-ayoub Dec 26, 2024
33dcf1a
build: metalk8s catalog source
eg-ayoub Dec 26, 2024
e8d94c0
hack registry to fix catalogsource
eg-ayoub Dec 27, 2024
4b473fc
fix registry config in OLM
eg-ayoub Jan 3, 2025
0e6b891
Add tolerations directly in nginx-operator bundle
eg-ayoub Jan 3, 2025
a8b8828
Automate nginx-operator install
eg-ayoub Jan 6, 2025
17d648f
Give nginx-operator priviledge for rbac management
eg-ayoub Jan 7, 2025
c4ffe25
Give nginx-operator priviledge for other kinds
eg-ayoub Jan 7, 2025
74f7ed3
Use minimal RBAC for nginx-operator isntall
eg-ayoub Jan 8, 2025
cdcd70f
install main ingress through ingress-operator
eg-ayoub Jan 8, 2025
46fdc59
patch nginx-ingress chart: disable CM generation
eg-ayoub Jan 9, 2025
6b31da3
fix image registry in ClusterExtension
eg-ayoub Jan 9, 2025
769325e
replace control plane ingress with operator generated
eg-ayoub Jan 9, 2025
670c151
completely remove ingress-nginx chart
eg-ayoub Jan 9, 2025
327db38
olm sanity tests
eg-ayoub Jan 9, 2025
dce0bce
nginx-operator sanity tests
eg-ayoub Jan 9, 2025
6d5d733
install only metalk8s catalog source
eg-ayoub Jan 9, 2025
5c5419b
buildchain: generate olm manifests manually
eg-ayoub Jan 14, 2025
0195d1d
buildchain, salt: bump OLMv1, generate sls
eg-ayoub Jan 14, 2025
304f6fd
salt, buildchain: fix multiline strings in OLM manifests
eg-ayoub Jan 14, 2025
3dd4f76
fix salt-tree
eg-ayoub Jan 14, 2025
9d7974f
fix salt renderer on olm manifest sls
eg-ayoub Jan 15, 2025
d57aad1
fix olm render merge step
eg-ayoub Jan 16, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions BUMPING.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,7 @@ REPO_URL=https://grafana.github.io/helm-charts

### ingress-nginx

```
CHART_NAME=ingress-nginx
REPO_NAME=ingress-nginx
REPO_URL=https://kubernetes.github.io/ingress-nginx
```
see [nginx-operator](./nginx-operator/BUMPING.md) and [metalk8s-catalog-source](./catalog-source/README.md)

set `$VERSION` with the appropriate value.

Expand Down
76 changes: 21 additions & 55 deletions buildchain/buildchain/codegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,60 +125,6 @@ def codegen_chart_fluent_bit() -> types.TaskDict:
}


def codegen_chart_ingress_nginx() -> types.TaskDict:
"""Generate the SLS file for NGINX Ingress using the chart render script."""
chart_dir = constants.CHART_ROOT / "ingress-nginx"
ingress_nginx_namespace = "metalk8s-ingress"
actions = []
file_dep = list(utils.git_ls(chart_dir))
file_dep.append(constants.CHART_RENDER_SCRIPT)

# Workload Plane Ingress
target_sls = (
constants.ROOT / "salt/metalk8s/addons/nginx-ingress/deployed/chart.sls"
)
chart_name = "ingress-nginx"
value_file = constants.CHART_ROOT / f"{chart_name}.yaml"
actions.append(
doit.action.CmdAction(
f"{constants.CHART_RENDER_CMD} {chart_name} {value_file} {chart_dir} "
f"--namespace {ingress_nginx_namespace} --remove-manifest ConfigMap "
f"{chart_name}-controller "
f"--output {target_sls}",
cwd=constants.ROOT,
)
)
file_dep.append(value_file)

# Control Plane Ingress
target_sls = (
constants.ROOT
/ "salt/metalk8s/addons/nginx-ingress-control-plane"
/ "deployed/chart.sls"
)
chart_name = "ingress-nginx-control-plane"
value_file = constants.CHART_ROOT / f"{chart_name}.yaml"
actions.append(
doit.action.CmdAction(
f"{constants.CHART_RENDER_CMD} {chart_name} {value_file} {chart_dir} "
f"--namespace {ingress_nginx_namespace} --remove-manifest ConfigMap "
f"{chart_name}-controller "
f"--output {target_sls}",
cwd=constants.ROOT,
)
)
file_dep.append(value_file)

return {
"name": "chart_ingress-nginx",
"title": utils.title_with_subtask_name("CODEGEN"),
"doc": codegen_chart_ingress_nginx.__doc__,
"actions": actions,
"file_dep": file_dep,
"task_dep": ["check_for:tox", "check_for:helm"],
}


def codegen_chart_kube_prometheus_stack() -> types.TaskDict:
"""Generate the SLS file for Kube Prometheus Stack using the chart render script."""
target_sls = (
Expand Down Expand Up @@ -332,19 +278,39 @@ def codegen_chart_cert_manager() -> types.TaskDict:
"task_dep": ["check_for:tox", "check_for:helm"],
}

def codegen_olm() -> types.TaskDict:
"""Generate the SLS file for OLMv1 using the OLM render script."""
target_sls = constants.ROOT / "salt/metalk8s/addons/olm/deployed/chart.sls"
cmd = (
f"{constants.OLM_RENDER_CMD} "
f"--output {target_sls}"
)

file_dep = [ constants.OLM_RENDER_SCRIPT ]

return {
"name": "olm",
"title": utils.title_with_subtask_name("CODEGEN"),
"doc": codegen_olm.__doc__,
"actions": [doit.action.CmdAction(cmd, cwd=constants.ROOT)],
"file_dep": file_dep,
"task_dep": ["check_for:tox"],
}



# List of available code generation tasks.
CODEGEN: Tuple[Callable[[], types.TaskDict], ...] = (
codegen_storage_operator,
codegen_metalk8s_operator,
codegen_chart_dex,
codegen_chart_fluent_bit,
codegen_chart_ingress_nginx,
codegen_chart_kube_prometheus_stack,
codegen_chart_loki,
codegen_chart_prometheus_adapter,
codegen_chart_thanos,
codegen_chart_cert_manager,
codegen_olm,
)


Expand Down
8 changes: 8 additions & 0 deletions buildchain/buildchain/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
PROMETHEUS_REPOSITORY: str = "quay.io/prometheus"
THANOS_REPOSITORY: str = "quay.io/thanos"
CERT_MANAGER_REPOSITORY: str = "quay.io/jetstack"
OPERATOR_FRAMEWORK_REPOSITORYT: str = "quay.io/operator-framework"

# Paths {{{

Expand All @@ -58,11 +59,15 @@
# Path to the MetalK8s operator source directory
METALK8S_OPERATOR_ROOT: Path = ROOT / "operator"
# Path to the storage-operator source directory.
NGINX_OPERATOR_ROOT: Path = ROOT / "nginx-operator"
# Path to the nginx-operator source directory.
STORAGE_OPERATOR_ROOT: Path = ROOT / "storage-operator"
# Path to the UI build root directory.
UI_BUILD_ROOT: Path = config.BUILD_ROOT / "ui"
# Path to the shell-ui build root directory.
SHELL_UI_BUILD_ROOT: Path = config.BUILD_ROOT / "shell-ui"
# Path to the MetalK8s Catalog Source root directory
CATALOG_SOURCE_ROOT: Path = ROOT / "catalog-source"

# Docker entrypoints.
REDHAT_ENTRYPOINT: Path = ROOT / "packages/redhat/common/entrypoint.sh"
Expand All @@ -76,6 +81,8 @@
CHART_ROOT: Path = ROOT / "charts"
CHART_RENDER_SCRIPT: Path = CHART_ROOT / "render.py"

OLM_RENDER_SCRIPT: Path = ROOT / "olm/render.py"

# }}}
# Vagrant parameters {{{

Expand Down Expand Up @@ -145,6 +152,7 @@ def git_ref() -> Optional[str]:
]

CHART_RENDER_CMD: str = f"tox -e chart-render -- --kube-version {versions.K8S_VERSION}"
OLM_RENDER_CMD: str = f"tox -e olm-render -- -v v{versions.OLM_VERSION}"

# For mypy, see `--no-implicit-reexport` documentation.
__all__ = ["ROOT"]
23 changes: 23 additions & 0 deletions buildchain/buildchain/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,11 @@ def _local_image(name: str, **kwargs: Any) -> targets.LocalImage:
"cert-manager-cainjector",
"cert-manager-acmesolver",
],
constants.OPERATOR_FRAMEWORK_REPOSITORYT: [
"catalogd",
"operator-controller",
"opm"
],
}

REMOTE_NAMES: Dict[str, str] = {
Expand Down Expand Up @@ -323,6 +328,24 @@ def _local_image(name: str, **kwargs: Any) -> targets.LocalImage:
"VERSION": versions.VERSION,
},
),
_local_image(
name="nginx-operator",
dockerfile=constants.NGINX_OPERATOR_ROOT / "Dockerfile",
build_context=constants.NGINX_OPERATOR_ROOT,
),
_local_image(
name="nginx-operator-bundle",
dockerfile=constants.NGINX_OPERATOR_ROOT / "bundle.Dockerfile",
build_context=constants.NGINX_OPERATOR_ROOT,
),
_local_image(
name="metalk8s-catalog-source",
dockerfile=constants.CATALOG_SOURCE_ROOT / "catalog.Dockerfile",
build_context=constants.CATALOG_SOURCE_ROOT,
build_args={
"BASE_IMG": TO_PULL["opm"].remote_fullname_digest,
},
),
)
# }}}

Expand Down
9 changes: 9 additions & 0 deletions buildchain/buildchain/salt_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,14 @@ def task(self) -> types.TaskDict:
file_dep=[METALK8S_OPERATOR_MANIFESTS],
),
Path("salt/metalk8s/addons/metalk8s-operator/deployed/init.sls"),
Path("salt/metalk8s/addons/nginx-operator/deployed/clusterextension.sls"),
Path("salt/metalk8s/addons/nginx-operator/deployed/init.sls"),
Path("salt/metalk8s/addons/nginx-operator/deployed/namespace.sls"),
Path("salt/metalk8s/addons/nginx-operator/deployed/rbac.sls"),
Path("salt/metalk8s/addons/olm/catalog/deployed/cluster-catalog.sls"),
Path("salt/metalk8s/addons/olm/catalog/deployed/init.sls"),
Path("salt/metalk8s/addons/olm/deployed/chart.sls"),
Path("salt/metalk8s/addons/olm/deployed/init.sls"),
Path("salt/metalk8s/addons/prometheus-adapter/deployed/chart.sls"),
Path("salt/metalk8s/addons/prometheus-adapter/deployed/init.sls"),
Path("salt/metalk8s/addons/prometheus-operator/macros.j2"),
Expand Down Expand Up @@ -680,6 +688,7 @@ def task(self) -> types.TaskDict:
Path("salt/_modules/metalk8s_kubernetes_utils.py"),
Path("salt/_modules/metalk8s_monitoring.py"),
Path("salt/_modules/metalk8s_network.py"),
Path("salt/_modules/metalk8s_olm.py"),
Path("salt/_modules/metalk8s_os.py"),
Path("salt/_modules/metalk8s_package_manager_yum.py"),
Path("salt/_modules/metalk8s_service_configuration.py"),
Expand Down
33 changes: 33 additions & 0 deletions buildchain/buildchain/versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,13 @@
CALICO_VERSION: str = "3.29.0"
SALT_VERSION: str = "3002.9"
CONTAINERD_VERSION: str = "1.6.36"
NGINX_OPERATOR_VERSION: str = "4.11.3"

CONTAINERD_RELEASE: str = "1"
SOSREPORT_RELEASE: str = "2"

OLM_VERSION: str = "1.1.0"


def load_version_information() -> None:
"""Load version information from `VERSION`."""
Expand Down Expand Up @@ -225,6 +228,16 @@ def _version_prefix(version: str, prefix: str = "v") -> str:
version="v0.36.1",
digest="sha256:e542959e1b36d5046083d1b64a7049c356b68a44a173c58b3ae7c0c9ada932d5",
),
Image(
name="catalogd",
version=_version_prefix(OLM_VERSION),
digest="sha256:95477a136772765fa2cfb02a6e5fb52bcc167ef7b5333f9e238b0b13b9e72f7b",
),
Image(
name="operator-controller",
version=_version_prefix(OLM_VERSION),
digest="sha256:6272919257e695fcdadf0b57cc0a272084ebf2caca7571e2e5d79d6a56a788fa",
),
# Local images
Image(
name="metalk8s-alert-logger",
Expand Down Expand Up @@ -266,6 +279,26 @@ def _version_prefix(version: str, prefix: str = "v") -> str:
version=VERSION,
digest=None,
),
Image(
name="nginx-operator",
version=_version_prefix(NGINX_OPERATOR_VERSION),
digest=None,
),
Image(
name="nginx-operator-bundle",
version=_version_prefix(NGINX_OPERATOR_VERSION),
digest=None,
),
Image(
name="opm",
version="v1.49.0",
digest="sha256:0bbe4054f2f88410ae364169379639c06b0e253d6e233bc24fcf2c0cd2d9803d",
),
Image(
name="metalk8s-catalog-source",
version=VERSION,
digest=None,
),
Image(
name="loki",
version="3.2.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ def create_config(
types {{ }} default_type "application/json";
return 200 '{payload:s}';
}}
location = /v2/{name:s}/tags/list {{
types {{ }} default_type "application/json";
return 200 '{payload:s}';
}}
""".format(
name=name,
name_prefix=name_prefix.lstrip("/"),
Expand Down Expand Up @@ -145,6 +149,13 @@ def create_config(
try_files manifest.json =404;
error_page 404 @404_tag;
}}
location = "/v2/{name:s}/manifests/{tag:s}" {{
alias {server_root:s}/{name:s}/{tag:s}/;
types {{ }} default_type "application/vnd.docker.distribution.manifest.v2+json";
add_header 'Docker-Content-Digest' 'sha256:{digest:s}';
try_files manifest.json =404;
error_page 404 @404_tag;
}}
""".format(
name=name,
tag=tag,
Expand All @@ -162,6 +173,13 @@ def create_config(
try_files manifest.json =404;
error_page 404 @404_tag;
}}
location = "/v2/{name:s}/manifests/sha256:{digest:s}" {{
alias {server_root:s}/{name:s}/{tag:s}/;
types {{ }} default_type "application/vnd.docker.distribution.manifest.v2+json";
add_header 'Docker-Content-Digest' 'sha256:{digest:s}';
try_files manifest.json =404;
error_page 404 @404_tag;
}}
""".format(
name=name,
tag=tag,
Expand All @@ -184,6 +202,10 @@ def create_config(
alias {server_root:s}/{name:s}/;
try_files {paths:s} =404;
}}
location ~ "/v2/{name:s}/blobs/sha256:([a-f0-9]{{64}})" {{
alias {server_root:s}/{name:s}/;
try_files {paths:s} =404;
}}
""".format(
name_prefix=name_prefix.lstrip("/"),
server_root=server_root,
Expand Down
2 changes: 2 additions & 0 deletions catalog-source/.indexignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
README.md
*.Dockerfile
5 changes: 5 additions & 0 deletions catalog-source/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# MetalK8s catalog source for OLMv1

contains the current operators:

- MetalK8s [nginx-operator](../nginx-operator)
23 changes: 23 additions & 0 deletions catalog-source/catalog.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
ARG BASE_IMG=quay.io/operator-framework/opm:latest
# The builder image is expected to contain
# /bin/opm (with serve subcommand)
FROM ${BASE_IMG} as builder

# Copy FBC root into image at /configs and pre-populate serve cache
ADD catalog /configs
RUN ["/bin/opm", "serve", "/configs", "--cache-dir=/tmp/cache", "--cache-only"]

FROM ${BASE_IMG}
# The base image is expected to contain
# /bin/opm (with serve subcommand) and /bin/grpc_health_probe

# Configure the entrypoint and command
ENTRYPOINT ["/bin/opm"]
CMD ["serve", "/configs", "--cache-dir=/tmp/cache"]

COPY --from=builder /configs /configs
COPY --from=builder /tmp/cache /tmp/cache

# Set FBC-specific label for the location of the FBC root directory
# in the image
LABEL operators.operatorframework.io.index.configs.v1=/configs
1 change: 1 addition & 0 deletions catalog-source/catalog/.indexignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
README.md
38 changes: 38 additions & 0 deletions catalog-source/catalog/nginx-operator/bundles/v4.11.3.yaml

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions catalog-source/catalog/nginx-operator/channels/stable.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
schema: olm.channel
package: nginx-operator
name: stable
entries:
- name: nginx-operator.v4.11.3
8 changes: 8 additions & 0 deletions catalog-source/catalog/nginx-operator/package.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
defaultChannel: stable
description: |
# NGINX-operator

This operator manages IngressNginx CRs and uses them as a values file for the [ingress-nginx](https://github.com/kubernetes/ingress-nginx) helm chart.
name: nginx-operator
schema: olm.package
Loading
Loading