Skip to content

salt, build: automate catalogd install #4498

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

Draft
wants to merge 12 commits into
base: development/130.0
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
73 changes: 18 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 @@ -333,18 +279,35 @@ def codegen_chart_cert_manager() -> types.TaskDict:
}


def codegen_olm() -> types.TaskDict:
"""Generate the SLS file for OLMv1 using the 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 @@ -57,12 +58,16 @@
STATIC_CONTAINER_REGISTRY: Path = Path(ROOT, "buildchain/static-container-registry")
# Path to the MetalK8s operator source directory
METALK8S_OPERATOR_ROOT: Path = ROOT / "operator"
# Path to the nginx-operator source directory.
NGINX_OPERATOR_ROOT: Path = ROOT / "nginx-operator"
# Path to the storage-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"]
29 changes: 29 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,30 @@ 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,
build_args={
"BUILDER_IMG": TO_PULL["alpine"].remote_fullname_digest,
"METALK8S_VERSION": versions.VERSION,
},
),
_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,
"SED_IMG": TO_PULL["alpine"].remote_fullname_digest,
"METALK8S_VERSION": versions.VERSION,
},
),
)
# }}}

Expand Down
13 changes: 13 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 @@ -434,6 +442,7 @@ def task(self) -> types.TaskDict:
Path("salt/metalk8s/addons/nginx-ingress/deployed/namespace.sls"),
Path("salt/metalk8s/addons/nginx-ingress/deployed/tls-secret.sls"),
Path("salt/metalk8s/addons/nginx-ingress/deployed/service-configuration.sls"),
Path("salt/metalk8s/addons/nginx-ingress/deployed/update-metadata.sls"),
Path("salt/metalk8s/addons/nginx-ingress/deployed/config-map.sls"),
Path("salt/metalk8s/addons/nginx-ingress/config/ingress-controller.yaml.j2"),
Path("salt/metalk8s/addons/nginx-ingress/deployed/dashboards.sls"),
Expand All @@ -456,6 +465,9 @@ def task(self) -> types.TaskDict:
"ingress-controller.yaml.j2",
),
Path("salt/metalk8s/addons/nginx-ingress-control-plane/deployed/tls-secret.sls"),
Path(
"salt/metalk8s/addons/nginx-ingress-control-plane/deployed/update-metadata.sls"
),
Path("salt/metalk8s/backup/certs/ca.sls"),
Path("salt/metalk8s/backup/certs/server.sls"),
Path("salt/metalk8s/backup/configured.sls"),
Expand Down Expand Up @@ -680,6 +692,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
37 changes: 35 additions & 2 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.12.0"

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 @@ -187,8 +190,8 @@ def _version_prefix(version: str, prefix: str = "v") -> str:
),
Image(
name="nginx-ingress-controller",
version="v1.11.3",
digest="sha256:d56f135b6462cfc476447cfe564b83a45e8bb7da2774963b00d12161112270b7",
version="v1.12.0",
digest="sha256:e6b8de175acda6ca913891f0f727bca4527e797d52688cbe9fec9040d6f6b6fa",
),
Image(
name="node-exporter",
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
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)
31 changes: 31 additions & 0 deletions catalog-source/catalog.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
ARG SED_IMG=alpine:latest
ARG BASE_IMG=quay.io/operator-framework/opm:latest

# replace MK8S_VERSION_STUB with the actual version
FROM ${SED_IMG} as sed_step
ARG METALK8S_VERSION
ADD catalog /catalog
RUN find /catalog -type f -exec sed -i "s/MK8S_VERSION_STUB/${METALK8S_VERSION}/g" {} \;

# 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
COPY --from=sed_step /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
Loading
Loading